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 trace how streaming and non-streaming paths recover XML tool calls and compare them.
- Assistant
I'll reproduce the streaming vs non-streaming gap with a quick script focused on Qwen's streaming parser.
- Assistant
Implementing a shared streaming helper aligned with non-streaming
extract_tool_calls, then fixing parsers that suppress content after tool-call completion. - Assistant
Implementing a shared streaming helper and fixing reasoning-mode redirect so split XML tool-call chunks recover the same way as non-streaming.
- Assistant
Adding parity tests and running the suite.
- Assistant
Simplifying the streaming helper to detect new tool calls by comparing parsed counts, so lenient recovery before the canonical close tag still emits correctly.
- Assistant
Fixed streaming XML tool-call recovery so it matches non-streaming behavior.
Root cause
Streaming parsers used simpler heuristics (close-tag counting, per-parser state) that could diverge from
extract_tool_calls. That led to:- Dropped tool calls when tags were split across chunks
- Suppressed trailing content after a completed call (Qwen returned
Noneinstead of passthrough) - Reasoning-mode tool XML missed when opening tags were split across deltas
- Early lenient recovery desyncing emission from canonical close tags (Hermes)
Changes
-
abstract_tool_parser.py— Added_stream_tool_calls_via_extract()and_format_streaming_tool_calls():- Delegates recovery to
extract_tool_calls(same logic as non-streaming) - Tracks
_streaming_emitted_countto dedupe and keep indices correct
- Delegates recovery to
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.