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
Now let's view
_detect_tool_callsfully to add a counter there for announced calls.Assistant
Now update
_detect_tool_callsto increment the announced counter:Assistant
Now let's update
finalize()to recover additional/missed calls even when some were already detected, and add exception safety:Assistant
Now let's re-run the reproduction script to see if this fixes the multi-call drop scenario, and run existing tests.
Assistant
Good,
finish_reasonandtool_calls_detectedfields exist and are set. Let's update repro2.py to print those too, and run full test suite.Assistant
Now the second call is properly recovered with
finish_reason="tool_calls". Let's run full existing test suite to check nothing broke.Assistant
Let's run the full test suite for the tool_parsers directory and any broader tests referencing tool calls to be safe.
Assistant
All pass. Let's verify those two errors pre-exist regardless of our change (git stash check):
Assistant
Confirmed pre-existing environment issue (missing
mlxnative library), unrelated to our change.Now let's test additional edge cases: reasoning mode (with reasoning parser active), tools_requested variations, and plain text / malformed markup not creating false calls.
Assistant
Good, plain text and malformed markup don't create false tool calls, and don't abort the stream. Now let's test with reasoning mode active + minimax tool call inside reasoning, and with
tools_requested=False.Assistant
Now let's rewrite this block to try multiple fallback text candidates and pick the richer parse result.
Assistant
Now let's clean up the outdated docstring comment lines that reference the old
_fallback_text/_has_plausible_markupvariable names no longer used, then re-test.Assistant
Syntax is fine. Now let's tidy the stale comment block (referring to old cheap pre-check wording that's now duplicated) for clarity, then re-run tests.
Assistant
Now let's re-run all reproduction scripts and the existing test suite:
Assistant
All scenarios now correctly recover 2 tool calls regardless of reasoning mode or chunk size. Let's re-run the other repro scripts and full test suite.
Assistant
Now let's run the full existing test suite (excluding the environment-broken ones) plus targeted postprocessor/tool tests.
Assistant
All pass. Now let's run a broader test across the whole repo (excluding those requiring native mlx lib) to check nothing else broke.
Assistant
Confirmed pre-existing environment limitation, not caused by our change. Let's run all tests that don't depend on mlx/docker to maximize coverage of our change's blast radius.
Assistant
Identical results with and without our change:
166 failed, 2937 passed, 178 skipped, 81 errors— confirming all failures/errors are pre-existing environment issues (missingmlxnative library), and our change introduces zero regressions.Assistant
Let's view the full diff to review the change quality once more before finalizing.
Assistant
No crashes on malformed/garbage input across all tested parsers and chunk sizes. Let's also double check none of these garbage inputs falsely produced tool_calls (should not create false positives on things like
"<tool_call>"alone with no body).Assistant
No false positives at all. Now let's clean up the temporary reproduction scripts (not part of the repo) and do a final review.
Assistant
Let's do one final full targeted test run to confirm everything is green before submission.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.