Repository navigation
[Bugfix][Structured Output] Preserve reasoning adapters for shared parser engines - #52830
Merged
Merged
Conversation
sfeng33
marked this pull request as ready for review
August 20, 2026 22:16
sfeng33
requested review from
aarnphm,
bbrowning and
chaunceyjiang
as code owners
August 20, 2026 22:16
Member
Author
|
/ci run |
|
✅ Triggered Buildkite CI #85559 for commit |
yewentao256
approved these changes
Aug 25, 2026
yewentao256
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for the work!
1 task done
am-cohere
pushed a commit
to am-cohere/vllm
that referenced
this pull request
Sep 1, 2026
…rser engines (vllm-project#52830) Signed-off-by: sfeng33 <4florafeng@gmail.com>
mikeshawcode
pushed a commit
to mikeshawcode/vllm
that referenced
this pull request
Sep 1, 2026
…rser engines (vllm-project#52830) Signed-off-by: sfeng33 <4florafeng@gmail.com> Signed-off-by: mikeshawcode <michaelwshaw2@gmail.com>
1 task done
mylibrar
pushed a commit
to tanyuqian/vllm
that referenced
this pull request
Sep 3, 2026
…rser engines (vllm-project#52830) Signed-off-by: sfeng33 <4florafeng@gmail.com>
0xjunhao
added a commit
to 0xjunhao/vllm
that referenced
this pull request
Sep 3, 2026
Signed-off-by: Junhao Li <junhao@ubicloud.com>
wtdcode
added a commit
to wtdcode/vllm
that referenced
this pull request
Sep 10, 2026
…quest
_apply_structural_tag hardcodes reasoning=False. The two grammars xgrammar
builds are not interchangeable -- for deepseek_v4 with tools and
tool_choice="auto":
reasoning=False
TriggeredTagsFormat(triggers=['<|DSML|tool_calls>'], tags=[...],
excludes=['<think>', '</think>'])
reasoning=True
SequenceFormat(elements=[
TagFormat(begin='', content=AnyTextFormat(excludes=[]), end='</think>'),
TriggeredTagsFormat(...)])
reasoning=False puts </think> in the free-text excludes, so a model whose
prompt ends inside an open thinking block can never close it. reasoning=True
opens with an any-text span terminated by </think>, so a non-thinking request
waits for a marker its prompt already consumed and EOS stays masked. Verified
with an xgrammar GrammarMatcher on a DeepSeek-V4-Flash-0731 tokenizer:
reasoning=False reasoning=True
"...</think>answer" rejected accepted
"...</think>" + call rejected accepted
runaway invoke name rejected rejected
This was latent while ParserManager collapsed matching parsers into a bare
ParserEngine, since _apply_structural_tag never ran for them. vllm-project#52830 removed
that shortcut, so the path is now live for every engine-backed parser
(deepseek_v3_2/v4, qwen3, glm47_moe, kimi_k2, minimax_m2, ...) whenever a
structural tag is applied -- today that is tool_choice=required/named, or
auto with a strict tool.
Add ReasoningParser.emits_reasoning_span, defaulting to False so existing
parsers keep their current behaviour, and override it in ParserEngine from
parser_engine_config.initial_state, which is derived per request from
chat_template_kwargs.
The same root cause was reported in vllm-project#46149 (Qwen3.6-27B, tool_choice="auto"
with per-tool strict=true) and closed without a fix.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: lazymio <mio@lazym.io>
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.
Purpose
Fix structured-output reasoning configuration being silently disabled when the reasoning and tool parsers use the same parser engine.
ParserManager.get_parser()returned the raw sharedParserEngine, whosereasoning_parserattribute isNone. The Chat Completions and Responses serving paths interpreted this as reasoning being disabled and skipped forwardingrequest-specific parser kwargs such as
enable_thinking=False.The structured-output backend could then use the parser's default thinking mode and wait for a reasoning boundary that the model was instructed not to emit, leaving schema generation unconstrained or running until
max_tokens.Test Plan