Skip to content

fix(a2a): drain output_rx until Flush to prevent response shift (#2326, #2313)#2328

Merged
bug-ops merged 1 commit intomainfrom
2326-a2a-message-send-shifted
Mar 28, 2026
Merged

fix(a2a): drain output_rx until Flush to prevent response shift (#2326, #2313)#2328
bug-ops merged 1 commit intomainfrom
2326-a2a-message-send-shifted

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 28, 2026

Summary

Test plan

  • cargo +nightly fmt --check passes
  • cargo clippy --features full --workspace -- -D warnings passes (0 warnings)
  • cargo nextest run --workspace --features full --lib --bins — 6927 passed (+1 new test)
  • New test a2a_response_shift_drain_until_flush_prevents_leak verifies the drain loop consumes FullMessage + delayed Usage + Flush and leaves the channel empty before the next request
  • Follow-up: consider filing P3 issue for a configurable drain timeout to guard against agent loop panics mid-turn (currently recv().await falls back to None on channel close)

Replace the non-blocking try_recv drain with a blocking recv-until-Flush
loop after process() exits on FullMessage. The previous try_recv was a
TOCTOU race: the agent loop continued emitting Usage/Flush tail events
after the drain completed, leaving them buffered for the next request and
causing each message/send to return the previous request's response.

Flush is the universal end-of-turn sentinel across all agent paths. The
drain loop handles channel close (None) as a fallback exit.

Also fix a silent tx.send() error discard in EmbeddingAnomalyGuard
check_async(): log a tracing::warn when the result channel is closed
instead of silently swallowing the error (#2313).

Fixes #2326, #2313
@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 28, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 28, 2026 09:03
@bug-ops bug-ops merged commit 9b4a67a into main Mar 28, 2026
25 checks passed
@bug-ops bug-ops deleted the 2326-a2a-message-send-shifted branch March 28, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

1 participant