Streaming drops XML tool-call output that non-streaming parses correctly Streaming must…
- User
Streaming drops XML tool-call output that non-streaming parses correctly
Streaming must emit the same recovered XML tool calls as non-streaming, including calls split across chunks and multiple calls, and finish with
tool_calls. Reasoning mode and request tool selection must not alter recovery. Plain text or malformed markup must not create calls or abort the stream.Interface
No new interfaces are introduced.
- Assistant
I'll investigate how streaming and non-streaming XML tool-call recovery differ in the codebase.
- Assistant
I'll trace streaming vs non-streaming recovery paths and add tests for the gaps—split chunks, reasoning mode, and finalize fallback text selection.
- Assistant
Implementing fixes: finalize was using
tool_accumulated_textoveraccumulated_texton the reasoning path, and the reasoning redirect only checked the current delta instead of accumulated text. - Assistant
Adding regression tests for the streaming XML recovery fixes.
- Assistant
Refining the first test to directly target the finalize buffer-selection bug.
- Assistant
Malformed XML was leaving the stream stuck in suppression; I'll add logic to exit that state after closed-but-unparsed blocks.
- Assistant
The redirect check needs to include the current reasoning delta, not just accumulated text.
- Assistant
Streaming XML tool-call recovery is fixed in
StreamingPostProcessor. The main gaps were finalize reading the wrong buffer on the reasoning path, split-tag redirect checks, and streams getting stuck after malformed markup.Root causes
-
Finalize used the wrong text buffer on the reasoning path —
tool_accumulated_text or accumulated_textpreferred the shorter content-channel buffer, so XML that only appeared in reasoning (or split across reasoning chunks) was invisible to end-of-stream recovery. -
Split
<tool_call>tags in reasoning — The redirect check only looked at (current delta), so a tag split across chunks like / never routed to the tool parser.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.