ISSUE DESCRIPTION Streaming drops XML tool-call output that non-streaming parses…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /Rapid-MLX, current file: none) bash-$
Assistant
Let me start by understanding the repository structure and the issue. The issue is about "Streaming drops XML tool-call output that non-streaming parses correctly". This seems to be related to an MLX-based framework (Rapid-MLX). Let me explore the repository first.
Assistant
Let me explore the structure more. This appears to be the vllm_mlx project. Let me look for streaming-related code and XML tool-call parsing.
Assistant
Let me look for XML tool-call parsing related code.
Assistant
Let me look at the source code structure for tool calling and streaming.
Assistant
Let me look at the key source files related to streaming and tool calling.
Assistant
Let me see the rest of the file and the streaming module
Assistant
Let me look at the streaming module and the rest of the tool_calling module.
Assistant
Let me look at the postprocessor and output collector, which likely handle streaming output and tool call parsing.
Assistant
Let me look at the tool parsers and the test files related to streaming and tool calls
Assistant
Let me look at the test files for streaming and tool calling.
Assistant
Let me look at the streaming spec test and the abstract tool parser to understand the streaming interface
Assistant
Now let me look at the abstract tool parser to understand the streaming interface
Assistant
Let me look at the full tool_calling.py and one of the tool parsers to understand the XML streaming issue better.
Assistant
Let me look at the rest of the tool_calling.py
Assistant
Let me look at the Qwen tool parser and the gemma4 tool parser to understand XML streaming
Assistant
Let me look at the gemma4 tool parser since the issue mentions XML tool calls
Assistant
Let me look at the qwen3coder_tool_parser and the minimax_tool_parser
Assistant
Let me look at how the chat route handles streaming and the other test files for tool parsers.
Assistant
Let me look at the tests related to tool parsing and streaming.
Assistant
Let me look at the output_collector and the domain/events module
Assistant
Let me look at the git history to understand recent changes and the current state of the issue.
Assistant
Let me check if there are any uncommitted changes and look at the domain events
Assistant
Let me look at the domain events module and understand the streaming flow better.
Assistant
Let me read the events module.
Assistant
Let me look at the chat route to understand the streaming flow.
Assistant
Let me run the tests related to tool calling and streaming to see the current state.
Assistant
MLX is not available in this environment. Let me check what packages are available and install what's needed.
Assistant
Let me write a quick script to understand the streaming behavior and reproduce the issue.
Assistant
Let me test more scenarios to understand the streaming behavior better.
Assistant
Let me test split tool calls across
Assistant
Let me look more closely at the streaming behavior in the postprocessor and the tool parsers.
Assistant
Let me test various edge cases with the streaming tool parser.
Assistant
Let me fix the imports and run the test.
Assistant
Let me investigate the LlamaToolParser streaming behavior more closely
Assistant
Let me check which tool parsers have their own streaming implementation.
Assistant
Let me look at the LlamaToolParser's streaming method
Assistant
Let me look at the minimax tool parser and the postprocessor more carefully, and check for any failing tests.
Assistant
Let me create a reproduction script that simulates the full postprocessor flow.
Assistant
Let me look at the recent changes to understand what was fixed and what still needs fixing
Assistant
The last commit just bumped the version. Let me look at the previous commit which was the big fix.
Assistant
Now I have a clear picture of the issues. Let me examine the specific bugs and devise fixes. Let me start by looking at the exact problem in the QwenToolParser and other parsers.
Assistant
Now let me also check content between/after tool calls:
Assistant
Let me look at the HermesToolParser streaming implementation to see if it has the same
Assistant
Now I have a clear understanding of the bugs. Let me look at all parsers to understand the pattern, then implement fixes
Assistant
Now I understand the issues. Let me implement the fixes. I'll start with the QwenToolParser.
Assistant
Let me try opening the file differently.
Assistant
Now let me fix the QwenToolParser's streaming method:
Assistant
Let me try using a different approach. I'll write the fix using a Python script
Assistant
Let me verify the QwenToolParser fix
Assistant
There's still a gap with partial tag detection. Let me refine the fix.
Assistant
Let me check what was actually written to the file:
Assistant
Let me debug the partial tag detection
Assistant
I see the bug - my prefix list was incomplete and the
endswithapproach is fragile. Let me use a more robust approach.Assistant
Now verify the fix
Assistant
There's still a gap with very short prefixes like
<to. Let me refine the partial tag detection to be more generalAssistant
Let me verify the fix
Assistant
There's still a gap: partial tags that appear after a completed tool call leak. Let me fix this.
Assistant
Let me verify the fix
Assistant
The fix is too aggressive -
<alone triggers partial detection. Let me refine.Assistant
Let me verify again
Assistant
Let me debug the multi-tool case step
Assistant
I see the issue - when a chunk contains both legitimate content and a partial tag start, the whole chunk is suppressed. Let me fix this to only suppress the partial tag portion
Assistant
Let me verify again
Assistant
The changes are getting complex. Let me take a simpler approach - rewrite the QwenToolParser's streaming method cleanly.
Assistant
Let me verify
Assistant
Let me debug the multi-tool case step by
Assistant
I see the bug - the safe delta is computed incorrectly. Let me fix
Assistant
Let me verify
Assistant
The safe delta calculation is wrong. Let me fix it properly
Assistant
Let me verify
Assistant
Let me trace through the multi-tool case in
Assistant
Let me step back and run existing tests to see the current state, and focus on ensuring tool call detection works correctly.
Assistant
All streaming tests pass. Let me run the full tool parser test suite
Assistant
Let me look at the specific Qwen streaming tests to make sure my changes align
Assistant
Let me check the Llama streaming tests and fix the LlamaToolParser
Assistant
Now let me fix the LlamaToolParser's streaming method with the
Assistant
Now let me fix the LlamaToolParser
Assistant
Let me verify the Llama fix and run tests
Assistant
Let me run all tests to check for reg
Assistant
Let me check other parsers for the same pattern and fix them. Let me start with HermesToolParser
Assistant
Let me fix the HermesToolParser's streaming method to handle partial tags
Assistant
Let me fix the HermesToolParser's partial tag leak
Assistant
Let me verify and run all
Assistant
Let me check the remaining parsers for the partial
Assistant
Let me check the parsers that use XML-like tags for partial tag leaks
Assistant
There are many parsers with this issue. Let me add a helper method to the base class and fix the remaining parsers
Assistant
Let me run the tests to ensure the base class change doesn't break
Assistant
Now let me fix the NemotronToolParser
Assistant
Let me fix all three remaining parsers at
Assistant
Now fix GraniteTool
Assistant
Fix GraniteToolParser
Assistant
Fix Gemma4ToolParser
Assistant
Fix Gemma4Tool
Assistant
Let me run all tests to verify
Assistant
Let me run the broader test suite to check for reg
Assistant
Let me do a comprehensive final verification
Assistant
Let me run all tests in the repository that could
Assistant
Let me run only the relevant test
Assistant
Good - all 379 tool-related tests pass. The 11 failures are pre-existing (MLX library not available). Let me now simplify the QwenToolParser and LlamaToolParser to use the helper method
Assistant
Now simplify the after-close check in Qwen and Llama parsers
Assistant
Let me verify everything still works after the simplifications
Assistant
Let me do one final comprehensive
Assistant
The
<and[single char "leaks" are intentional - we require at least 2 characters to avoid suppressing legitimate content like "5 < 10". Let me verify with the correct test:Assistant
Let me check all changes made
Assistant
Let me review the complete diff to ensure correctness
Assistant
Let me run the full test suite one
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.