fix(buzz-acp): refresh idle clocks on turn completion and steer ack - #7173
Stalker23b wants to merge 2 commits into
Conversation
The idle-pool sleep and exit-after-inactivity clocks were only refreshed at dispatch, so any turn longer than the idle bound was torn down on the first reaper tick after it completed — killing the CLI process together with its live background tasks and pending wake-ups (observed in production: a 28-minute turn ended and the pool was reaped 13 seconds later, orphaning two background tasks whose completion the agent was waiting on). Turn completion and steer acks now count as activity. Heartbeat results are excluded: heartbeat dispatch is gated on an idle slot with no flushable work, so counting them would keep a heartbeat-enabled pool awake forever. Signed-off-by: Stalker23b <stalker.23b@gmail.com> Co-authored-by: Пчелинский <pchelinsky@agents.buzz.local> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Review findings: - The refresh now lives inside handle_prompt_result, so the unit tests covering that function also guard the wiring — previously deleting the call-site line left the suite green. - result_refreshes_idle_clock uses an exhaustive match: a new PromptSource variant must decide explicitly whether its completion keeps the pool alive. - Corrected the heartbeat comment: dispatch is gated on an idle slot with no flushable work (not "only into an idle pool" — in a multi-agent pool a heartbeat can fire while another agent's turn is live). - Two wiring tests: a channel result refreshes the idle clock through handle_prompt_result; a heartbeat result leaves it stale. Signed-off-by: Stalker23b <stalker.23b@gmail.com> Co-authored-by: Пчелинский <pchelinsky@agents.buzz.local> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
🔐 Codex Security Review
|
|
Tested this PR on top of desktop-v0.5.23 on Windows 11 (Hyper-V VM, Claude runtime), same agent identity and environment in both runs, only the buzz-acp binary differs: with the release binary the pool was torn down 30 s after an 18-minute turn completed (900 s counted from turn start); with this PR applied the teardown came 906 s after turn complete and never earlier. No teardown during a turn in either run, both completion messages arrived. Details with UTC log lines: (#6378 (comment)). Works as described. |
Fixes #7171
Problem
The idle-pool reaper clocks (idle-pool sleep, exit-after-inactivity) are refreshed only at dispatch time. Any turn that runs longer than the idle bound is guaranteed to look idle the moment it completes, so the first reaper tick after completion tears the pool down — killing the CLI process together with its live background tasks and pending wake-ups.
Observed in production: a 28-minute turn completed and the pool was reaped 13 seconds later, orphaning two background tasks whose completion the agent was waiting on (details in #7171).
Fix
Turn completion and steer acks now count as activity:
handle_prompt_result, so the existing unit tests around result handling also guard the wiring.matchonPromptSource: a new variant must explicitly decide whether its completion keeps the pool alive.Known edges (unchanged, noted for reviewers)
max_turn_duration + 100s; a turn exceeding it auto-expires and the pool can still be reaped before the turn ends (pre-existing).Testing
result_refreshes_idle_clock(mapping, exhaustive match) plus wiring tests that a channel result refreshes the idle clock throughhandle_prompt_resultand a heartbeat result leaves it stale.cargo test -p buzz-acp: 28 failures on this (heavily loaded) machine, in modules this patch does not touch (acp::testssteer/session,pool::model_switch_tests,pool::startup_effort_tests) — the failure set is byte-identical on the clean base commit under the same conditions, i.e. pre-existing machine-local flakes, zero new failures from this patch. The four new idle-clock tests pass.🤖 Generated with Claude Code