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 search the codebase for streaming XML tool-call recovery and compare it with the non-streaming path.
- Assistant
Implementing fixes: adding a shared streaming dedup helper, updating parsers that mishandle split closing tags, and ensuring finalize emits
finish_reason=tool_calls. - Assistant
Fixing dedup:
extract_tool_callswas matching incomplete<tool_call>blocks via lenient patterns. I'll only count tool calls through the last closing marker. - Assistant
Fixed streaming XML tool-call recovery so it matches non-streaming extraction.
Root causes
- Close-marker detection used
delta_textonly — tags split across chunks (e.g.</tool_call+>) were missed by parsers like GLM47 and Llama. - Multi-tool dedup was wrong —
AutoToolParserre-emitted all calls on every close; Hermes used raw close counts that desynced on malformed bodies. - Premature dedup — lenient parsing of incomplete
<tool_call>blocks made streaming think a call was already emitted before the closing tag arrived. - Missing terminal finish — streams that detected tool calls but never got
finished=Trueended withoutfinish_reason: tool_calls. - Request gating — Hermes raw-JSON fallback ignored calls not listed in
request.tools.
- Close-marker detection used
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.