buzz-agent: never silently drop an acknowledged steer at turn completion - #5069
Open
iroiro147 wants to merge 1 commit into
Open
buzz-agent: never silently drop an acknowledged steer at turn completion#5069iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4942.
Root cause
run_promptacknowledges a steer wheneversteer_tx.send()succeeds. But the run loop drains that queue only at the start of each provider round (RunCtx::run→drain_steers(), non-blockingtry_recv). When the last drain has already happened and the run is tearing down, a steer is still accepted —cleanupthen clearssteer_txand persistshistorywithout the queued message. The message is acknowledged, never delivered, and lost.Fix
After the session stops accepting new steers (
steer_tx = None),run_promptperforms a final drain of whatever remains insteer_rx, folding each accepted steer intohistoryas aUseritem before persisting. Rejected-render (empty/unrenderable) steers still get dropped with log lines, matchingdrain_steers(). AWARNnotes the occurrence so the race is visible when it matters; the next turn now carries the message as its first user ground.Tests
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_promptunchanged: 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=5could 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-targetsclean.