fix(gateway): stream synthesized recovery finals - #31478
Conversation
|
This is a resubmission of the closed #31475 (identical diff). Competes with #31477 for fixing #31449. Both PRs address the same gap: recovery-path final text not streamed to SSE/TUI clients. This PR covers 3 sites (guardrail halt + partial_stream_recovery + fallback_prior_turn_content) using a helper function. #31477 covers only the 2 recovery sites but includes a |
…stream-deltas-v2 # Conflicts: # agent/conversation_loop.py
|
Follow-up pushed in 1140d26 to align the helper with the stream-close behavior called out in the duplicate-scope comparison: Validation:
|
…stream-deltas-v2 # Conflicts: # agent/conversation_loop.py
|
Closing this as stale: there has been no activity or maintainer follow-up for over a week, and I don't want to leave inactive work open. Happy to reopen/rework if this becomes useful. |
Summary
stream_delta_callbackbefore recovery/guardrail branches close the turn.Why
partial_stream_recoveryandfallback_prior_turn_contentassignfinal_responsefrom local recovery text and then break without another model delta.Changes
agent/conversation_loop.py: adds a small helper for synthesized final deltas and uses it for guardrail halt, partial stream recovery, and prior-turn fallback finals.tests/run_agent/test_run_agent.py: asserts partial-stream recovery and prior-turn fallback text is emitted to stream consumers.Validation
python -m ruff check agent/conversation_loop.py tests/run_agent/test_run_agent.pypython -m pytest tests/run_agent/test_tool_call_guardrail_runtime.py tests/run_agent/test_run_agent.py::TestRunConversation::test_partial_stream_recovery_on_empty_stub tests/run_agent/test_run_agent.py::TestRunConversation::test_prior_turn_fallback_emits_stream_delta -o 'addopts=' -qScope