Skip to content

[Bugifx] [Qwen3CoderTool] Restore supports_required_and_named for required tool_choice#42292

Merged
chaunceyjiang merged 4 commits into
vllm-project:mainfrom
chaunceyjiang:code3_coder
May 12, 2026
Merged

[Bugifx] [Qwen3CoderTool] Restore supports_required_and_named for required tool_choice#42292
chaunceyjiang merged 4 commits into
vllm-project:mainfrom
chaunceyjiang:code3_coder

Conversation

@chaunceyjiang
Copy link
Copy Markdown
Collaborator

@chaunceyjiang chaunceyjiang commented May 11, 2026

Purpose

Follow of #40894

As a widely used tool parser, Qwen3Coder should still support supports_required_and_named = True at this stage.

Otherwise, tool_choice="required" no longer works correctly now.

I think this should continue to be properly supported at least before structural_tag is enabled by default.
@sfeng33 @aarnphm @Seven-Streams @aarnphm @bbrowning

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

…uired tool_choice

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the supports_required_and_named attribute from the Qwen3CoderToolParser class. The review feedback indicates that this change introduces a conflict with the parser's XML-based structural tags, as it forces the system to use a JSON extractor that is incompatible with the XML output, leading to failures when tool_choice is set to 'required'.

Comment thread vllm/tool_parsers/qwen3coder_tool_parser.py
…uired tool_choice

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
…uired tool_choice

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
Copy link
Copy Markdown
Collaborator

@bbrowning bbrowning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree we don't want to regress here for user's that have not opted into the strict tool calling enforcement via Xgrammar.

@chaunceyjiang chaunceyjiang added the ready ONLY add when PR is ready to merge/full CI is needed label May 11, 2026
@chaunceyjiang chaunceyjiang enabled auto-merge (squash) May 11, 2026 15:52
@cjackal
Copy link
Copy Markdown
Contributor

cjackal commented May 11, 2026

A thought - it feels like to integrate xgrammar's stag templates better with more model archs, major refactoring of output parser (like RFC #32713) is necessary.

xgrammar clearly moves toward a "unified" parser; it supports full-time structured decoding (contrary to the in-the-middle-of-tool-calling structured decoding that vllm currently takes) and each stag template binds tightly to the target model, and this kind of movement is not unique to xgrammar, smg as another example - any token parser framework that works atop of token-in-token-out inference engine would naturally look like that.

And vllm's current parser system that guarantees independency of reasoning and tool call parser makes it hard to develop such a unified parser design without a sort of backward incompatibility - one instance is this bugfix, and supporting a request-level thinking on/off alongside forced stag is also quite messy in its current form (currently stag is bound to a tool call parser, which has little info on reasoning parser counterpart). There are several places in the scheduler code that handle reasoning / tool call boundary which explicitly assume that reasoning / tool call parser are independent.

If a backward incompatibility is unavoidable, it might be better starting to write "vllm parser V2" that lies in separate codepath from the vllm parser status quo and put xgrammar stag feature to parser V2 I think.

@chaunceyjiang chaunceyjiang merged commit 920bf3e into vllm-project:main May 12, 2026
40 checks passed
weifang231 pushed a commit to weifang231/eb-vllm that referenced this pull request May 13, 2026
…uired tool_choice (vllm-project#42292)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
mfylcek pushed a commit to mfylcek/vllm that referenced this pull request May 19, 2026
…uired tool_choice (vllm-project#42292)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
jhu960213 pushed a commit to jhu960213/vllm that referenced this pull request May 20, 2026
…uired tool_choice (vllm-project#42292)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
h1t35h pushed a commit to h1t35h/vllm that referenced this pull request May 21, 2026
…uired tool_choice (vllm-project#42292)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
ExtReMLapin added a commit to ExtReMLapin/vllm that referenced this pull request May 27, 2026
Conflict resolutions (qwen3coder_tool_parser.py + its test file):

- _convert_param_value: kept this branch's detailed type-coercion logic
  (nullable string/None handling, container double-decode for buggy
  templates) instead of main's refactor to utils.coerce_to_schema_type /
  extract_types_from_schema (vllm-project#38973). Restored `import ast` that vllm-project#38973
  had removed. Kept main's vllm-project#42292 change
  (supports_required_and_named = not VLLM_ENFORCE_STRICT_TOOL_CALLING).

- Tests: kept this branch's rewritten Coder test file. Re-integrated the
  two anyOf tests vllm-project#38973 added: the comprehensive non-streaming + streaming
  cases stay Coder-specific (they assert {"type": ["integer","null"]} -> int
  and whitespace-stripped values, which only hold for the Coder parser);
  the genuinely cross-parser anyOf[array,null] -> list case was added to the
  shared test file, parametrized over both XML and Coder parsers.

All 190 qwen3 tool-parser tests pass; ruff check/format unchanged vs the
pre-merge branch head.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed tool-calling

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants