Repository navigation
Studio: offer only the reasoning levels a template allows and show its raise message - #16502
Merged
Lyxot merged 3 commits intoNov 3, 2026
Merged
Conversation
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. |
Member
Author
|
Reached Codex review convergence at oobabooga#451 on b9fded5. |
oobabooga
added a commit
that referenced
this pull request
Nov 4, 2026
Follow-up to #16502. That PR publishes the reasoning levels a template enforces with a `raise_exception` guard. For Mistral Small 4 and Mistral Medium 3.5 those levels are `none` and `high`, so the chat UI now moves Low or Medium to High. Other paths can still send a level the template rejects, and the render then fails on every request: - **API requests** with `minimal`, `low`, `medium`, `xhigh` or `max`. OpenAI-compatible clients that default to `medium` fail against these models. On GGUF the error now quotes the template; on safetensors and MLX it is still "An internal error occurred". - **A GGUF launch with reasoning off** sends `low` as the server default, which breaks every request that does not name a level. - **`xhigh` and `max` on GGUF** fall through and send no level, so the template's default (`none`) silently turns thinking off. ## Fix `_fit_reasoning_effort_to_template` maps a level the template's enforced allowlist rejects to the nearest one it accepts. It uses the same clamp as the UI (`_clamp_reasoning_effort_to_levels`, mirrored in `provider-capabilities.ts`). Thinking off maps to `none` when the template offers it. It is applied in: - `LlamaCppBackend._request_reasoning_kwargs` (per-request kwargs for llama-server) - `LlamaCppBackend._reasoning_kwargs` (launch default) - `apply_chat_template_for_generation` (the shared transformers and MLX renderer) The template used is the active override if one is set, otherwise the embedded template. Templates without such a guard are untouched, including gpt-oss and every family whose levels come from scanning. This follows the existing precedents: the `enable_thinking_effort` style already clamps requests to the template's levels, and Muse Spark coerces into its raising template's accepted set. Tradeoff: an explicit API level is substituted silently rather than rejected, which is how the `enable_thinking_effort` clamp already treats it. The transformers/MLX renderer imports `core.inference.llama_cpp` lazily on its first render with an effort. ## Validation Rendered the real `chat_template.jinja` of Mistral Small 4 (also the template embedded in the GGUF), Mistral Medium 3.5 and gpt-oss with every combination of `enable_thinking` and effort, plus both launch defaults: ```text before: Mistral Small 4 fails for minimal/low/medium/xhigh/max requests and for the reasoning-off launch after: 0 failures on all three templates; gpt-oss kwargs unchanged ``` ```bash pytest studio/backend/tests/test_reasoning_effort_allowlist.py studio/backend/tests/test_muse_spark.py \ studio/backend/tests/test_deepseek_v4_thinking_effort.py studio/backend/tests/test_kimi_k3_reasoning_defaults.py \ studio/backend/tests/test_chat_template_continuation.py studio/backend/tests/test_launch_reasoning_flag.py \ studio/backend/tests/test_thinking_parameter.py # 245 passed ``` Each new test was mutation-checked: reverting each of the four call sites (request, launch, override preference, transformers/MLX renderer) or the thinking-off mapping makes it fail. --------- Co-authored-by: oobabooga <[email protected]>
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.
Mistral Small 4 GGUFs fail in Studio when thinking is set to Low or Medium, showing only "An internal error occurred". The model's chat template accepts only
noneandhigh. Reported on r/unsloth: https://www.reddit.com/r/unsloth/comments/1xksg60/Cause
Studio already detects thinking levels and adjusts unsupported selections. For templates using
reasoning_effortalone, detection scans for quoted level names and only trusts the result when it contains bothlowandhigh. This avoids mistaking a default for the complete list: GPT-OSS's template only quotesmedium, but supports Low and High too.That check discards Mistral's
none/highlist. The UI then falls back to Low / Medium / High, so Medium looks supported and the existing adjustment leaves it unchanged.Fix
This PR first looks for an explicit validation block:
if reasoning_effort not in [...]followed byraise_exception(...). It uses that allowed list when present and keeps the existing detection otherwise. Mistral now reports['none', 'high'], so the existing UI adjustment moves Low or Medium to High and the menu offers only High. No frontend changes are needed; adding Off remains separate.It also surfaces the template's error message by decoding llama-server's JSON before extracting it, preserving embedded quotes, and checking against the active template override when one is set. Only text found in the template is shown. An API request explicitly sending
lowstill fails, but now explains that the accepted values are "none" and "high".Verification
mediumtohigh, the request completes, and an explicitlowrequest returns the template's explanation. The full Mistral model was not used for this test.