fix(agent): emit guardrail halt explanation to client stream (#30770)#30808
Open
Bartok9 wants to merge 1 commit into
Open
fix(agent): emit guardrail halt explanation to client stream (#30770)#30808Bartok9 wants to merge 1 commit into
Bartok9 wants to merge 1 commit into
Conversation
Collaborator
19 tasks
…earch#30770) When _tool_guardrail_halt_decision fires, the conversation loop appended the halt message to `messages` (so it persisted to history) but never called `_fire_stream_delta`, leaving SSE / TUI clients with a silent stream close indistinguishable from a crash. Fix: call `agent._fire_stream_delta(final_response)` immediately before the messages.append so every registered stream consumer (display, TTS, gateway SSE) receives the explanation. Adds a regression test that verifies _fire_stream_delta is called with the halt text whenever _tool_guardrail_halt_decision is set. Fixes NousResearch#30770
f788491 to
91f84f9
Compare
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.
Summary
When
_tool_guardrail_halt_decisionfires the turn loop appended the haltmessage to
messages(conversation history) but never called_fire_stream_delta, leaving SSE / TUI clients with a silent stream closeindistinguishable from a crash.
Root Cause
final_responsewas written to internal message history but never pushed tothe stream consumers (
stream_delta_callback, TTS, gateway SSE).Fix
Add a single
_fire_stream_delta(final_response)call beforemessages.append:This matches how the normal (non-guardrail) response path delivers text to clients.
Testing
test_guardrail_halt_emits_final_response_to_streamtotests/agent/test_tool_guardrails.py— verifies_fire_stream_deltaiscalled with the halt explanation text whenever
_tool_guardrail_halt_decisionis set.
Fixes #30770