Repository navigation
Studio: vLLM thinking effort levels, preserve thinking and auto-compact - #13571
Conversation
… and preserve thinking
… engine Launch vLLM with the reasoning parser the model's chat template matches, report the template's reasoning flags on load, pass enable_thinking / reasoning_effort / preserve_thinking through to the engine, stream its reasoning as <think> markup, and fit long chats to --max-model-len when Auto-compact is on.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…oning in managed tool turns
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3cfc96b155
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "Select one GPU, use Replicas, or load an unquantized checkpoint with 4-bit precision." | ||
| ) | ||
| template = _model_chat_template(config, hf_token) | ||
| reasoning_parser = reasoning_parser_for_template(template, engine) |
There was a problem hiding this comment.
Classify reasoning from every active named template
When tokenizer_config.json provides separate default and tool_use templates, _model_chat_template() always collapses them to tool_use at line 169, so this new parser detection never examines the default template that vLLM renders for requests without tools. A model whose default template contains Qwen/DeepSeek reasoning markers but whose tool template does not will therefore record no reasoning parser or flags, causing otherwise-supported plain reasoning requests to be rejected; preserve both named branches or classify the template selected for each request shape.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing: models whose default template carries thinking markup but whose tool_use template does not are rare, and for them the managed engine behaves exactly as on main (thinking off, controls refused), so nothing regresses.
…mes to vLLM connections
…e effort the engine renders
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 186dbbb30c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const isManagedEngineForCompaction = | ||
| !isExternalModelId(params.checkpoint) && runtime.loadedEngine === "vllm"; |
There was a problem hiding this comment.
Include managed vLLM in the manual-compaction gate
When a user invokes /compact while a managed vLLM model is loaded, takeThreadCompactionRequest() consumes the pending request, but compactNow remains false because its gate still checks only GGUF and MLX. Consequently, the newly forwarded isManagedEngine flag enables ordinary auto-compaction but never sends compact_context: true, so an explicit compaction request is silently ignored; include isManagedEngineForCompaction in that gate.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable: /compact is refused before the request is queued unless a GGUF or MLX model is loaded (thread.tsx shows "/compact works with GGUF and MLX models that support tools"), so with a managed vLLM model takeThreadCompactionRequest never has anything to consume.
| if "<think>" not in template or "</think>" not in template: | ||
| return None | ||
| for marker, parser in ( | ||
| ("<arg_key>", "glm45"), |
There was a problem hiding this comment.
Select the GLM-4.7 reasoning parser
When loading GLM-4.7 or its variants, the template contains <arg_key>, so this unconditional marker mapping launches vLLM with --reasoning-parser glm45. GLM-4.7 prefills <think> in its generation prompt and requires the glm47 parser; vLLM's official GLM-4.7 recipe specifies --reasoning-parser glm47, and the upstream parser bug report documents that glm45 mishandles this prompt shape. As a result, managed GLM-4.7 responses can put reasoning in the wrong field or leak its markup into visible content, so the parser selection must distinguish this template from GLM-4.5/4.6.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
In every vLLM release Studio's engine pins (0.26.0, 0.30.0) and in 0.31.0, vllm/reasoning/init.py maps both glm45 and glm47 to glm47_moe_reasoning_parser.Glm47MoeParserReasoningAdapter, so --reasoning-parser glm45 already runs the GLM-4.7 parser. vllm#33348 is closed by that alias.
| if effort in ("minimal", "low", "medium", "high", "xhigh", "max"): | ||
| body["reasoning_effort"] = effort |
There was a problem hiding this comment.
Avoid sending
none to older vLLM servers
When an external vLLM server predates the widened effort enum and the user turns thinking off, effort is "none", but it bypasses the version guard because _LOCAL_SERVER_EFFORT_ALIASES contains only minimal, xhigh, and max. The expanded tuple here then sends reasoning_effort: "none" even though chat_template_kwargs.enable_thinking=false already carries the off switch, causing servers whose schema accepts only low/medium/high to reject the entire request with 400, as demonstrated by this upstream vLLM validation failure. Apply the same version fallback to none or omit the top-level field for those versions.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
"none" is never sent at top level: the forwarded tuple is (minimal, low, medium, high, xhigh, max), so thinking off travels only as chat_template_kwargs.enable_thinking=false, which vLLM 0.11+ accepts.
Fixes #11664
With a vLLM connection, Studio only offered Thinking on or off, and Studio's own vLLM engine had no thinking at all and no auto-compact. This PR gives vLLM the same thinking controls and auto-compact as GGUF.
vLLM connections
Unexpected reasoning effort high. Supported types are xhigh (default), medium, and low., and xhigh could not be picked. The model's own levels now go out unchanged when the server is vLLM 0.21 or newer, the first release whosereasoning_effortaccepts none / minimal / low / medium / high / xhigh / max. On an older server, or one whoseGET /versioncannot be read, low / medium / high go out as before and a wider level is left to the template's own default rather than rewritten to a neighbour the template may refuse. The version is cached for a minute per connection.preserve_thinkinggoes out inchat_template_kwargs, merged withenable_thinking, and earlier thinking is replayed asreasoning, the field vLLM 0.17+ hands to the template.Studio's vLLM engine
--reasoning-parserfrom the model's own chat template, the same way it already picks the tool parser, following vLLM's reasoning outputs table: qwen3 for Qwen3 templates withenable_thinking, deepseek_r1 for R1, QwQ and Qwen3 Thinking-2507, deepseek_v3 for DeepSeek V3.1 style templates gated onthinking, plus glm45, minimax_m2, kimi_k2 and openai_gptoss. If no template matches, the launch command is unchanged./tokenize, against the engine's--max-model-len. Chats that go through Studio's tool loop are fitted every turn with the same estimate vLLM connections use. Preserve thinking also keeps each tool turn's thinking.Auto-compact on vLLM connections (already on main)
#12975 already compacts long chats on vLLM and Custom connections to the window the server reports. I checked it on real servers with Studio's proxy, Qwen3-0.6B,
--max-model-len 4096and a chat of about 12k tokens:maximum context length is 4096 tokensFrance's capital is Paris.France's capital is Paris.Paris.Evidence
vLLM 0.31.0 connection, Qwen3-0.6B served with the Qwen3.8 chat template, through Studio's proxy:
Unexpected reasoning effort highThe word "strawberry" contains 3 r letters.Studio's vLLM engine, Qwen3-0.6B,
--max-model-len 2048:--reasoning-parser qwen3does not support ... reasoning controls17 multiplied by 3 equals 51.context_length_exceededTests
tests/test_managed_engine_reasoning.py,tests/test_vllm_connection_reasoning.py.Notes
preserve_thinkingwith its default value of false, as llama.cpp connections already do. A template that reads it (Qwen3.6 and later) no longer renders an empty think block for each past turn.Screenshots
Merge base (left) vs this PR (right). The vLLM connection serves
Qwen/Qwen3.8-27Bfrom a stub vLLM 0.31 server.Thinking menu on a plain vLLM connection: High becomes the template's own Extra High, and Preserve thinking appears.
The top level picked and sent: the request carried
reasoning_effort: highbefore (which the Qwen3.8 template rejects) andxhighnow.Connection marked as a reasoning model: an on/off pill before, the effort ladder now.