fix(gateway): deliver interim commentary when the consumer gets no deltas
When the agent streams to an execution observer instead of the adapter, already_streamed is true while the GatewayStreamConsumer never accepted a delta. on_segment_break() only queues a segment marker and carries no text, so the commentary was dropped and the platform never saw it (reproducible with streaming.enabled: false, where stream_deltas_enabled is false). Deduplicate against deltas this consumer actually accepted, and otherwise hand the text to on_commentary().
This commit is contained in:
@@ -377,7 +377,14 @@ class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):
|
||||
if unseen:
|
||||
return
|
||||
if stream_consumer is not None:
|
||||
stream_consumer.on_segment_break() if already_streamed else stream_consumer.on_commentary(text)
|
||||
# The agent's own streaming may be feeding an execution observer rather than this
|
||||
# adapter, so ``already_streamed`` alone does not mean the consumer saw the deltas.
|
||||
# Deduplicate only against deltas this consumer actually accepted; otherwise the
|
||||
# commentary would be dropped (``on_segment_break`` carries no text).
|
||||
if already_streamed and stream_consumer.stream_deltas_enabled:
|
||||
stream_consumer.on_segment_break()
|
||||
else:
|
||||
stream_consumer.on_commentary(text)
|
||||
elif not already_streamed and ctx._status_adapter and str(text or "").strip():
|
||||
self._send_status_text(text, ctx._status_thread_metadata, "interim_assistant_callback scheduling error")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user