Skip to content

[Rust Frontend] Integrate xgrammar-structural-tag for strict and required tool calling - #46057

Merged
BugenZhao merged 7 commits into
mainfrom
bz/xgrammar-overwhelming-jackal
Jun 24, 2026
Merged

BugenZhao merged 7 commits into
mainfrom
bz/xgrammar-overwhelming-jackal

Conversation

@BugenZhao

@BugenZhao BugenZhao commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

Purpose

Integrates xgrammar-structural-tag into the Rust frontend tool-calling path:

  • Adds the xgrammar-structural-tag dependency and exposes structural-tag model mappings from supported Rust tool parsers.
  • Applies structural-tag guided decoding in the chat output processor for tool_choice=required, named function choices, and tool_choice=auto with strict tools.
  • Lowers tool_choice=required and named function choices through the OpenAI chat request conversion path.
  • Keeps explicit response_format / structured_outputs lowering at the server boundary while the chat parser adjustment layer owns structural-tag overrides.

AI assistance was used to help prepare this change.

Test Plan

  • cargo nextest run -p vllm-server validate_request_compat prepare_chat_request
  • cargo nextest run -p vllm-chat structural_tag

Test Result

  • cargo nextest run -p vllm-server validate_request_compat prepare_chat_request: 49 passed, 206 skipped.
  • cargo nextest run -p vllm-chat structural_tag: 8 passed, 187 skipped.

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.

@mergify mergify Bot added the rust label Jun 18, 2026
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao
BugenZhao force-pushed the bz/xgrammar-overwhelming-jackal branch from 12ab6b2 to fd79067 Compare June 22, 2026 11:47
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao
BugenZhao marked this pull request as ready for review June 22, 2026 12:16
@BugenZhao
BugenZhao requested a review from njhill as a code owner June 22, 2026 12:16
Comment thread rust/Cargo.toml Outdated
vllm-tokenizer = { path = "src/tokenizer" }
vllm-tool-parser = { path = "src/tool-parser" }
winnow = "1.0.2"
xgrammar-structural-tag = { git = "https://github.com/Inferact/xgrammar-structural-tag.git", rev = "8c74b8c415834170364f075bd04457955639744d" }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can release it to crates.io once it's stabilized.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao BugenZhao added the ready ONLY add when PR is ready to merge/full CI is needed label Jun 23, 2026
@BugenZhao
BugenZhao merged commit 4ed8eaa into main Jun 24, 2026
27 checks passed
@BugenZhao
BugenZhao deleted the bz/xgrammar-overwhelming-jackal branch June 24, 2026 02:46
nkzhenhua pushed a commit to nkzhenhua/vllm that referenced this pull request Jun 24, 2026
…`required` tool calling (vllm-project#46057)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
wincent8 pushed a commit to wincent8/vllm that referenced this pull request Jun 29, 2026
…`required` tool calling (vllm-project#46057)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
efschu pushed a commit to efschu/shvllm that referenced this pull request Jul 18, 2026
…`required` tool calling (vllm-project#46057)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
michael-gpu pushed a commit to practical-inference/vllm-ampere-extended that referenced this pull request Oct 20, 2026
…`required` tool calling (vllm-project#46057)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants