Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Streaming drops XML tool-call output that non-streaming parses…

  1. 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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Claude Assistant

    Now let's write the simulator script.

  3. Claude Assistant

    Looks fine, no special chars. Let me open the file and use edit with explicit line numbers instead.

  4. Claude Assistant

    Now update reset():

  5. Claude Assistant

    Now let's find and update _detect_tool_calls:

  6. Claude Assistant

    I have a duplicate block. Let me fix lines 539-550.

  7. Claude Assistant

    Good, that's fixed now. Let's verify the whole file compiles and re-check surrounding context.

  8. Claude Assistant

    Now let's also check the _fallback_text computation still works fine, and view the whole file end to confirm no leftover duplication elsewhere.

  9. Claude Assistant

    There's a leftover dead line return {"content": tool_result.get("content", "")} from the old code. Let's remove it.

  10. Claude Assistant

    Now let's verify syntax and run existing postprocessor tests.

  11. Claude Assistant

    All existing tests pass. Now let's re-run my repro script to verify the leak is fixed.

  12. Claude Assistant

    Duplicate leftover lines 627-628. Let's remove them.

  13. Claude Assistant

    Now let's verify syntax and run tests + repros.

  14. Claude Assistant

    Now let's re-test.

  15. Claude Assistant

    All parsers now show zero leaked content with correct tool_calls recovered. Let's also test edge cases: plain text with </[ that's not a tool call (false positive), malformed JSON inside tags, and multiple tool calls / reasoning mode.

  16. Claude Assistant

    Now let's run the test suite and repro again.

  17. Claude Assistant

    All pass. Now re-run the repro6 comprehensive scenario checks.

  18. Claude Assistant

    Now let's syntax-check chat.py and run relevant tests (skip mlx-dependent ones since they can't run here).

  19. Claude Assistant

    All runnable tests pass. Let's run the entire tool_parsers/postprocessor/api_utils related test files together plus a broader sanity sweep of all tests that can import without mlx.

  20. Claude Assistant

    Now let's run all these runnable tests together to check for regressions.

  21. Claude Assistant

    Good, sanitize_output tests pass individually too. Let's confirm those "166 failed" tests aren't affected by test-order pollution and are truly identical (diff the two runs precisely) for extra safety.

  22. Claude Assistant

    Confirmed byte-for-byte identical failure sets — these are pre-existing environment/test-isolation issues unrelated to my changes, and no regressions were introduced.

    Now let's run ruff (or similar linter) if available, to keep code style consistent.

  23. Claude Assistant

    Just a formatting nit. Let's apply ruff format.

  24. Claude Assistant

    Let's re-run the full targeted test suite once more to be safe after formatting.

  25. Claude Assistant

    All good. Let's also verify request tool-selection (tools_requested) doesn't alter recovery, and check the _MAX_AMBIGUOUS_HOLD_LEN/cap edge cases (adversarial long unresolved < chain) don't hang or blow up memory.

  26. Claude Assistant

    Excellent — all edge cases pass, and content reconstruction is exact even under adversarial input, with no performance blow-up. Let's clean up temp scripts and do a final review of the diff.

  27. Claude Assistant

    This diff looks clean and complete. Let's do one final full test pass on the core test files plus a broader integration-style check.

  28. Claude Assistant

    All tests pass. Now let's go through the checklist.

  29. Claude Assistant

    Everything is clean. Let's do one last comprehensive summary run and then submit.

  30. Claude Assistant

    Summary

    Root cause: In StreamingPostProcessor._detect_tool_calls (vllm_mlx/service/postprocessor.py), each per-model ToolParser.extract_tool_calls_streaming() only recognizes an opening tag (<tool_call>, <minimax:tool_call>, [TOOL_CALLS], <|tool▁calls▁begin|>, etc.) once the complete literal has accumulated. When a real streaming engine splits that literal across multiple deltas/tokens (the normal case — token boundaries rarely align with tag boundaries), the parser reports the partial fragment ("<to", "ol_", "cal", …) as ordinary content before it can recognize and suppress the completed tag. This leaked raw tool-call markup into the visible content stream instead of cleanly hiding it and emitting tool_calls, unlike non-streaming extract_tool_calls() which sees the whole text at once and never leaks markup. A few parsers (DeepSeek V3.1's two-marker wrapper, Seed-OSS's single-delta-only literal check) never suppressed at all under chunked input, leaking the whole tag.

    Fix:

    1. Added a generic, parser-agnostic holdback (_split_pending_tag / _parser_flags_pending) in StreamingPostProcessor that buffers an ambiguous trailing <...>/[...]-shaped fragment instead of emitting it immediately, releasing it once it's provably safe (closed and not flagged pending by the parser's own has_pending_tool_call) or bounded caps are hit — with a fallback flush in finalize() so genuinely-plain text (false positives like a < b) is never silently dropped, and true tool calls recovered by the existing non-stream fallback correctly discard the buffered fragment instead of double-emitting it.
    2. Fixed sanitize_output() (vllm_mlx/api/utils.py) to only .strip() when its regex actually removed something — it was unconditionally stripping per-delta chunks that merely contained </[, silently eating legitimate whitespace at chunk boundaries.
    3. Updated stream_chat_completion (vllm_mlx/routes/chat.py) to forward the new trailing content events from finalize() (previously only tool_call events were forwarded).

    Verified against real parsers (hermes, qwen, llama, mistral, minimax, kimi, glm47, seed_oss, deepseek_v31, xlam) with char-by-char chunking: zero leaked markup, correct multi-call recovery, correct finish_reason="tool_calls", reasoning-mode and tools_requested don't affect recovery, malformed/false-positive markup produces no spurious calls and doesn't crash, and adversarial unbounded input is bounded/fast. Full relevant test suite (and a before/after diff of all mlx-independent tests) shows zero regressions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.