Skip to content

fix(buzz-acp): refresh idle clocks on turn completion and steer ack - #7173

Open
Stalker23b wants to merge 2 commits into
block:mainfrom
Stalker23b:fix/buzz-acp-idle-clock-p1
Open

fix(buzz-acp): refresh idle clocks on turn completion and steer ack#7173
Stalker23b wants to merge 2 commits into
block:mainfrom
Stalker23b:fix/buzz-acp-idle-clock-p1

Conversation

@Stalker23b

Copy link
Copy Markdown

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:

  • The idle-clock refresh lives inside handle_prompt_result, so the existing unit tests around result handling also guard the wiring.
  • The refresh decision is an exhaustive match on PromptSource: a new variant must explicitly decide whether its completion keeps the pool alive.
  • 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.

Known edges (unchanged, noted for reviewers)

  • The in-flight deadline is max_turn_duration + 100s; a turn exceeding it auto-expires and the pool can still be reaped before the turn ends (pre-existing).
  • The panic path does not refresh the clocks (pre-existing).

Testing

  • New unit tests: result_refreshes_idle_clock (mapping, exhaustive match) plus wiring tests that a channel result refreshes the idle clock through handle_prompt_result and 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::tests steer/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.
  • Running in production across 18 agents since 2026-09-01: no premature teardowns after long turns.

🤖 Generated with Claude Code

Stalker23b and others added 2 commits September 1, 2026 21:31
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>
@Stalker23b
Stalker23b requested a review from a team as a code owner September 1, 2026 13:58
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 59328d5ae38a51a618dd2fddd7faf1343d42096f...91957a5493f44b2e5ef20ee00d5b62c503eba78e.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 91957a5493f44b2e5ef20ee00d5b62c503eba78e to authorize a new review.
Any previous review applies only to its recorded range.

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.

buzz-acp: idle-pool reaper tears down the pool right after a long turn, orphaning background tasks

1 participant