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
I'll start by exploring the repository structure and understanding how streaming vs non-streaming XML tool-call parsing works.
- Assistant
I'll search for XML tool-call parsing and streaming-related code next.
- Assistant
rg is not available, let me use grep.
- Assistant
Focusing on streaming tool parsing and related tests that mention XML recovery.
- Assistant
Looking at recent streaming tool-call commits and the relevant failing tests.
- Assistant
Checking todo notes and the streaming recovery path for XML tool calls.
- Assistant
Let me look at the StreamingToolCallFilter and chat streaming path more carefully. Also look at test_chat_streaming_spec.py and any recent changes.
- Assistant
Inspecting StreamingPostProcessor and related service code for tool-call recovery.
- Assistant
Let me read the full _detect_tool_calls method and related fallback logic in the postprocessor.
- Assistant
Let me read the full finalize and _detect_tool_calls methods, and also look at tests that might be related to this bug.
- Assistant
Let me check for uncommitted work and review relevant code about XML tool call recovery.
- Assistant
Retrying git status after the pager mess.
- Assistant
Running related streaming/XML tool tests and inspecting recovery-related code.
- Assistant
Checking how tests handle the missing mlx dependency and isolating tool-parser tests.
- Assistant
MLX can't load here; I'll inspect parsers and unit-level recovery logic without the full engine stack.
- Assistant
Inspecting abstract parsers and the shared XML recovery path in parse_tool_calls.
- Assistant
Let me try to look at git history for uncommitted patches or look at how tests describe the issue more carefully. There might be a failing test that was recently added but not implemented.
- Assistant
Let me look more carefully. The issue description sounds like an acceptance criteria for a fix. Perhaps there's something broken in the current finalize path or in a specific XML parser.
- Assistant
Let me read the rest of qwen_tool_parser and also look at how streaming extract works. Also let me check the issue description once more - maybe there's natural language offline tests without mlx.
- Assistant
Checking abstract recovery helpers and stream postprocessor interaction with reasoning.
- Assistant
Looking at potential issues more carefully... The issue says: I need to address the streaming XML tool-call recovery issue. Let me start by examining the current implementation to identify where the streaming vs non-streaming parity might be breaking down.
First, let me explore the codebase to find where the XML tool call parsing and streaming logic lives.
- Assistant
Let me look at reasoning path for MiniMax more carefully - maybe XML in think is lost?
- Assistant
Looking at multi-tool XML streaming regressions and the hermes parser, which often handles tool XML.
- Assistant
Continuing through Hermes streaming and checking for XML-related test failures.
- Assistant
Checking ROADMAP and review notes for this exact issue, and scanning for incomplete work.
- Assistant
Stubbing mlx so we can run the tool-parser and postprocessor tests.
- Assistant
Need a better mlx stub.
- Assistant
Checking tool call recovery helpers for streaming/non-streaming parity.
- Assistant
Inspecting stream_chat_completion event handling and any StreamingPostProcessor tests.
- Assistant
Let me see the rest of stream_chat_completion where finalize is called and tool_calls are emitted.
- Assistant
Let me continue reading finalize usage
- Assistant
Reading the Gemma4 tool parser against the streaming postprocessor path.
- Assistant
Let me look at the git refs, maybe there's a stash or a branch with the issue. Also look at PR templates or issue templates.
- Assistant
Let me look at the Anthropic streaming path - maybe the bug is there. Or maybe look at output_router. Also let me search for bugs related to "recovered"
- Assistant
Creating a proper mlx stub and comparing streaming vs non-streaming tool recovery.
- Assistant
Rewriting the comparison script cleanly.
- Assistant
Fixing the script syntax carefully.
- Assistant
Writing the file with Python to avoid text corruption.
- Assistant
Improving the stub and importing engine modules carefully.
- Assistant
Stubbing more of the dependency stack so real imports work.
- Assistant
Writing the harness as a file to avoid quoting issues.
- Assistant
Bypassing config and using a minimal stuber config object.
- Assistant
Encoding the test script in base64 to avoid shell interpretation of XML tags.
- Assistant
Checking the MiniMax parser class name.
- Assistant
It's MiniMaxToolParser not MinimaxToolParser.
- Assistant
All basic cases pass. Testing with a reasoning parser next, since that's called out in the issue.
- Assistant
Confirmed: with reasoning, streaming corrupts tool accumulation and finalize ignores full text. Verifying the fix approach.
- Assistant
Identified the bug: finalize prefers corrupted
tool_accumulated_textover fullaccumulated_text. Implementing a fix that tries both. - Assistant
I'll replace the fallback section to try multiple candidate texts.
- Assistant
Re-running reasoning and baseline recovery tests.
- Assistant
Writing a clean test file with Python only.
- Assistant
Using pathlib to write the file with a list of lines to avoid corruption.
- Assistant
Using different quote styles to avoid nesting issues.
- Assistant
Wrapping extract in try/except so malformed markup can't abort the stream.
- Assistant
Checking that logger is available in the postprocessor module.
- Assistant
Checking anthropic streaming for duplicated fallback logic.
- Assistant
Final verification of plain-text no-op and exception tolerance, then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.