buzz-acp: a failed steer/interrupt cancel (error or idle timeout) goes through plain requeue(), losing the steer framing and any cancelled carryover
Describe the bug
buzz-acp already has a rule for control-signal cancels: the batch survives with its steer/interrupt framing and gets no retry accounting. lib.rs:5297-5316 routes PromptOutcome::Cancelled | PromptOutcome::CancelDrainTimeout(_) to queue.requeue_as_cancelled(batch, reason). The comment there explains that a failed drain after a control-signal cancel "must survive with no retry/dead-letter accounting, same as a clean cancel."
That rule covers only those two outcomes. classify_control_cancel_failure (pool.rs:4961) maps the other cancel failures differently:
AcpError::IdleTimeout(_) => PromptOutcome::Timeout(TimeoutKind::Idle)
other => PromptOutcome::Error(other)
requeue_cancelled_batch (pool.rs:4918) stamps cancel_reason = Some(Steer | Interrupt) on the batch. But these outcomes aren't Cancelled, so the batch falls through to the generic queue.requeue(batch) (lib.rs:5388). requeue() (queue.rs:693-765) only pushes batch.events back onto the queue. It never reads batch.cancel_reason or batch.cancelled_events.
This has two effects:
A. The steer framing is lost, and the user's steer is counted as a failure.
On the next flush, cancel_reason comes back as None (queue.rs:609-610) and format_prompt's has_cancelled is false (queue.rs:2428). The agent gets a plain batch with no sign that its previous request was interrupted or superseded. On top of that, the user's own steer now has retry_counts and backoff applied, and it can eventually be dead-lettered.
B. Cancelled carryover can be dropped for good.
After an earlier steer succeeds, the interrupted request X waits in cancelled_batches. flush_next removes it from there and moves it into FlushBatch.cancelled_events (queue.rs:609). From then on, that is the only copy. If that turn fails with a non-Cancelled outcome, requeue() returns only events, and X disappears.
requeue_preserve_timestamps (queue.rs:786) restores the carryover. Its docstring says: "Dropping them here would silently lose the original request of an interrupted turn." It also has a dedicated test (test_requeue_preserve_timestamps_round_trips_cancelled_carryover, queue.rs:4102). requeue() has neither.
Steps to reproduce
Two steps are enough for B. It doesn't need two steers in a row:
- A turn is running for message X.
- The user steers with message Y. The cancel succeeds, and
requeue_as_cancelledstores X as cancelled carryover. - The next flush builds
FlushBatch { events: [Y], cancelled_events: [X] }. - That turn fails with a non-
Cancelledoutcome (agent error, idle timeout, etc.). requeue()puts back only[Y]. X is gone, and Y is re-prompted without the merged framing.
A happens on its own whenever a steer/interrupt cancel fails with IdleTimeout or an agent error.
B needs the carryover and new events to meet in the same flush. When there are no new events, the fallback at queue.rs:553-572 moves the carryover into events, and requeue() keeps it.
Expected behavior
- A control-signal cancel that fails with
IdleTimeoutor an agent error should be handled likeCancelDrainTimeout: keep the batch as a cancelled merge with its reason, and apply no retry accounting. Or, if retry accounting is intended there,requeue()should at least keepcancel_reason. requeue()should restorecancelled_events/cancel_reasonto the cancelled carryover, the wayrequeue_preserve_timestampsalready does. It should also get a matching round-trip test.
Version and platform
- Buzz version:
buzz-acpbuilt from7c789dee0(September 2026). I re-read the relevant paths onmain@744f394(2026-11-06), and the logic is unchanged. Line numbers above are frommain. - OS: Linux x86_64 and macOS (two deployments)
Logs / additional context
These numbers come from about two weeks of default-level (buzz_acp=info) logs from one deployment. Its adapter didn't advertise _session/steering, so steers took the cancel+merge path:
steer fell back to cancel+merge (ExpectedRunIdMissing) 99
"requeueing failed batch with backoff" right after a steer 29
outcome = error, all with the identical message:
Agent reported error (code -32603): Internal error
attempts went up to 6, max delay 254.66 s, none dead-lettered
successful cancel+merge whose next turn failed and requeued 16 ← precondition for B
All 29 requeues hit A. None of them should have gone through requeue(): "requeueing failed batch with backoff" is logged only inside requeue() (queue.rs:737), while requeue_as_cancelled logs nothing.
B can't be observed directly at the default log level. Nothing logs cancelled_events, and the Cancelled outcome is logged at debug. So the 16 cases show that the precondition happened, not that a loss was observed. The code path above is what makes the loss happen.
I'm happy to open a PR if this direction sounds right.