Skip to content

buzz-agent: never silently drop an acknowledged steer at turn completion - #5069

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4942-steer-ack-drop
Open

buzz-agent: never silently drop an acknowledged steer at turn completion#5069
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4942-steer-ack-drop

Conversation

@iroiro147

Copy link
Copy Markdown
Contributor

Fixes #4942.

Root cause

run_prompt acknowledges a steer whenever steer_tx.send() succeeds. But the run loop drains that queue only at the start of each provider round (RunCtx::rundrain_steers(), non-blocking try_recv). When the last drain has already happened and the run is tearing down, a steer is still accepted — cleanup then clears steer_tx and persists history without the queued message. The message is acknowledged, never delivered, and lost.

Fix

After the session stops accepting new steers (steer_tx = None), run_prompt performs a final drain of whatever remains in steer_rx, folding each accepted steer into history as a User item before persisting. Rejected-render (empty/unrenderable) steers still get dropped with log lines, matching drain_steers(). A WARN notes the occurrence so the race is visible when it matters; the next turn now carries the message as its first user ground.

Tests

  • New delayed-response fake-LLM mode: test picks + releases each canned response, so the steer is fired deterministically into the exact window (queued while the round is in flight, before the last drain).
  • Regression test acknowledged_steer_is_never_lost_across_turn_boundary: asserts the invariant — an acknowledged steer reaches the provider either folded into the live turn or into the next turn; it is never lost.
  • steer_rejected_when_no_active_run / steer_rejected_on_run_id_mismatch / steer_rejected_on_empty_prompt unchanged: genuinely-idle steers still rejected fast.
  • steer_folds_into_active_turn_without_cancelling (previously flaky in parallel full-suite runs — BUZZ_AGENT_LLM_TIMEOUT_SECS=5 could exhaust mid-steer) now passes; the steer suite is 10/10 clean on repeat, and the full crate suite (497 tests) passes.

cargo fmt -p buzz-agent + cargo clippy -p buzz-agent --all-targets clean.

Fixes block#4942. A steer could be acknowledged while the run was still live but
already racing the completion teardown, past the final round-boundary drain —
the accepted message then vanished without ever reaching the provider.

run_prompt now drains any late accepted steer into session history after the
session stops accepting new steers (steer_tx cleared), so the message persists
and surfaces as the NEXT turn's first user message, with a WARN log noting the
occurrence. Steer rejection for genuinely-idle sessions is unaffected.

A new delayed-response fake-LLM mode (test picks and releases each canned
response) drives the race deterministically, and a regression test proves an
acknowledged steer reaches the provider in the same or the next turn.

Tests: cargo test -p buzz-agent (497 passed); steer suite 10/10 clean —
the previously flaky steer_folds_into_active_turn_without_cancelling included.

Signed-off-by: iroiro147 <sarthak.singh@mastersunion.org>
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-agent can acknowledge a steer that is dropped during turn completion

1 participant