Repository navigation
[Security] Keep copied tool closers inside Qwen parameter values - #58407
Open
jperezdealgaba wants to merge 1 commit into
Open
jperezdealgaba wants to merge 1 commit into
jperezdealgaba wants to merge 1 commit into
Conversation
A parameter value that repeats the format's closing tags was parsed as a second tool call. When closers outnumber openers, keep that text in the first parameter and do not emit the later call. Co-authored-by: Cursor Agent Signed-off-by: Juan Pérez de Algaba <jperezde@redhat.com>
jperezdealgaba
requested review from
aarnphm,
bbrowning,
chaunceyjiang and
sfeng33
as code owners
September 23, 2026 16:29
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
6 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Qwen-family XML tool parsers treat a
</parameter>that appears inside a parameter value as the end of that value. When the copied text continues with another tool-call block, and the model then emits its own closing tags, the parser returns that block as a second tool call. The fix detects the extra closer (more closing tags than opening tags) and keeps the copied text in the first parameter. Later calls are held until the generation finishes, then dropped when the output is unbalanced. Balanced parallel calls are unchanged.Changes
vllm/parser/qwen3.py: when closers outnumber openers, rebuild one call whose first parameter runs through the final closer. Streaming holds calls after the first untilfinish_streaming.tests/parser/engine/test_qwen3.py: copied closers stay inside the parameter for the parser and the serving adapter, streaming does not emit the copied call, and balanced parallel calls still both return.tests/parser/engine/test_seed_oss.py: same copied-closer case with seed wrapper tokens.Codepath coverage
Qwen3ParserToolAdapter.extract_tool_calls(qwen3_coder,qwen3_xml, andmimoall use that adapter). Covered.extract_tool_calls_streamingandfinish_streaming, which serving calls when the stream finishes. Covered.seed_osssubclassesQwen3Parserand uses its own wrapper tokens. Covered.Duplicate-work check
No open or merged diff stops an extra closer inside a parameter value from becoming another call.
</function>arrives without</parameter>.Tests
test_copied_closer_stays_inside_the_parametertest_serving_adapter_keeps_copied_closer_in_the_parametertest_streaming_does_not_emit_the_copied_calltest_balanced_parallel_calls_still_both_returntest_streaming_balanced_parallel_calls_flush_at_finishtest_copied_closer_stays_inside_the_parameter(seed_oss)AI assistance
This PR was developed with AI assistance.
Made with Cursor