fix(gateway): suppress NO_REPLY/[SILENT] markers on the streaming path - #56099
Merged
Conversation
The agent emits a bare control marker (NO_REPLY / [SILENT] / …) when it
intentionally chooses not to reply. The gateway's whole-response filter
(is_intentional_silence_agent_result) suppresses this on the non-streaming
delivery path, but the streaming path (GatewayStreamConsumer) had no silence
awareness: it edited the raw marker onto the screen delta-by-delta and
finalized it BEFORE the whole-response filter could run. On any
streaming-capable adapter (Slack, Telegram, Discord, …) users saw a literal
'NO_REPLY' message leak into chat.
Fix (contained in the stream consumer + a shared predicate; no new config,
no platform-specific code):
- gateway/response_filters.py: add is_partial_silence_marker() — the
streaming counterpart to is_intentional_silence_response(), sharing the
same marker set and canonicalization so the two never drift.
- gateway/stream_consumer.py:
- Mid-stream hold-back: defer edits while the accumulated buffer is still a
prefix of a silence marker, so a partial marker never flashes on an
interval tick.
- On stream end (got_done): if the final buffer is exactly a marker, retract
any preview already shown (best-effort delete_message, reusing the
_try_fresh_final cleanup path) and leave the delivery flags False so the
gateway's own filter turns the marker into '' and no fallback send fires.
Substantive prose that merely mentions a marker is still delivered normally.
Tests: tests/gateway/test_stream_consumer_silence.py — predicate truth table
+ end-to-end run() suppression (single-shot + token-by-token), preview
retraction, no-delete-support best-effort, [SILENT] parity, and
prose-passthrough. Prove-fail verified by reverting only the consumer change
(the 4 behavioral tests fail: 'NO_REPLY'/'[SILENT]' leaks).
Collaborator
Related: salvage of #56042 (still open) onto current |
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.
Infographic
Summary
Intentional-silence markers (
NO_REPLY/[SILENT]/SILENT/NO REPLY) are now suppressed on the streaming delivery path, not just the non-streaming one. A user reported a literalNO_REPLYbubble leaking into Slack.The gateway already suppressed whole-response silence markers via
response_filters.is_intentional_silence_response+run.py's whole-response filter — but only on the non-streaming path.GatewayStreamConsumeredits the reply onto the screen delta-by-delta, before that filter runs, so by the time the filter fires the marker is already visible. This affects any streaming-capable adapter (Slack, Telegram, Discord, Matrix, …); Slack has editing on by default, which is where it was caught.Both streaming call sites (
run.pyproxy SSE and local) funnel throughon_delta, so the fix has a single correct home: the consumer.Changes
gateway/response_filters.py: addis_partial_silence_marker(), the streaming counterpart tois_intentional_silence_response(). Shares the sameLIVE_GATEWAY_SILENT_MARKERSset + canonicalization so the two never drift.gateway/stream_consumer.py:got_done, if the final buffer is exactly a marker, retract any preview (best-effortdelete_message, reusing the_try_fresh_finalcleanup path) and leave delivery flags False so the gateway's own filter drops it and no fallback send fires.tests/gateway/test_stream_consumer_silence.py: predicate truth table + end-to-endrun()suppression (single-shot and token-by-tokenNO_REPLY,[SILENT]parity, preview retraction, no-delete-support best-effort, prose-passthrough).No new config, no platform-specific code.
Validation
NO_REPLYNO_REPLY30 tests pass (
scripts/run_tests.sh tests/gateway/test_stream_consumer_silence.py). Matches the narrow intentional-silence contract: suppress only when the whole response is an exact marker; never substring-match prose.Salvaged from #56042 by @benbarclay; authorship preserved via rebase-merge.