Skip to content

engine: a quit with replies mid-stream finishes in seconds; idle CPU cuts (r9) - #2521

Merged
santoshkumarradha merged 9 commits into
factory/general-intakefrom
t3/engine-shutdown-idle-cpu
Nov 8, 2026
Merged

santoshkumarradha merged 9 commits into
factory/general-intakefrom
t3/engine-shutdown-idle-cpu

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Fixes the engine findings of WorkAF live e2e round 9: quits with jobs running hit the desk's 30 s kill, an idle quit exited 1 with "codeaf could not save this chat", the old codeaf clock stayed ~30 s after its engine, and the idle engine read 6.3–7.4% of a core on macOS.

Quit

  • Cut streams' receipts are hurried. A goroutine dump of a 41 s rig quit showed every conversation's close in provider.reconcile's retry pauses (1/4/15/20 s, ReceiptWait 70 s) for the price of the call the quit cut. appBackend.Close calls provider.HurryReceipts: a pause ends, each owed receipt asks once more within 2 s and is recorded unpriced with its tokens; the app's close waits at most 3 s per conversation for receipts.
  • A gone checkout is not a failed save. A job chat whose folder was deleted failed its next capture and Flush reported it at exit (exit 1). A capture or seal of a missing folder is cellstore.ErrWorkspaceGone: nothing to save. Rig: 3/3 exit 1 before, 0/3 after.
  • An orphaned clock with no window open leaves at once instead of waiting out its 30 s closingGrace.

Idle

Every write under the factory root wakes its watchers; on macOS each one re-lists the root through kqueue (13% of the before profile). Writes that said nothing new are gone:

  • lease renewals reach leases.json once the stored renewal is 10 s old (lease.RenewalSettles), not every 2 s;
  • a machine busy on two jobs keeps the job it was announced with — before, every beat flipped it between the two and wrote two live events (18 events in 10 beats → 0);
  • a followed AgentField run whose reading changes nothing no longer rewrites its job every 500 ms (50 writes → 0);
  • a watched root is re-read every 30 s, not 2 s;
  • an idle chat's knowledge tick does not re-read a journal unchanged since a read that reached its end.

Numbers

Rig: 84 + 2 held jobs, 35 open chats, 15 slots, stub model; idle = engine CPU over 120 s from 200 s after start; quit with 6 held step streams + 14 chats mid-reply.

linux before linux after macOS before macOS after
idle CPU 0.97% 0.60% 4.19% 2.60%
leases.json rewrites 0.90/s 0.17/s 1.00/s 0.18/s
quit, 20 streams mid-reply 41.3 s 1.7 s, exit 0 40.6 s 2.2 s, exit 0
clock after the engine exits 33 s 2 s 28 s 1 s

macOS steady profile: 3.03% → 2.10% of a core; what remains is lease reads on runner requests (17%) and the chat presence beat (13%). The rig does not follow a live AgentField run, which the live round's idle did; the AgentField write fix covers that path, and a live round confirms it.

make pr-ready BASE=origin/factory/general-intake: exit 0. Its 8-shard cmd/codeaf run had one failure, TestFactoryRetryActionsDoNotReportStopped/try_again (its rerun read revision 19 while the job was at 20); run alone it passes 2/2 on this head and 2/2 on the base, so it reads as load-dependent and is not from this change, which only removes writes.

Manual: quitting the desktop app (receipts, gone folders) and the clock's leaving. PERF.md: "Quit and idle, the ninth live round". Change entry: docs/changes/unreleased/2521-r9-quit-and-idle.md. Rebased onto #2520.

🤖 Generated with Claude Code

@santoshkumarradha
santoshkumarradha merged commit d8cf0a7 into factory/general-intake Nov 8, 2026
1 check passed
@santoshkumarradha
santoshkumarradha deleted the t3/engine-shutdown-idle-cpu branch November 8, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant