Repository navigation
Default preserve thinking on for Qwen3.8 - #9096
Conversation
Playwright A/B evidenceBoth isolated Studio sides received the same mocked Qwen3.8 status (
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6b4132bc4
ℹ️ 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".
| ...(hydratingExistingModel && { | ||
| preserveThinking: preserveThinkingDefault, | ||
| }), |
There was a problem hiding this comment.
Fence the model default against settings hydration
When a model status/load races the asynchronous hydratePersistedSettings() call, this direct setState does not advance the scalar-setting mutation version, while the hydration loop can independently assign the stored preserveThinking value. Consequently, on startup with a resident Qwen3.8 model and any previously stored value, whichever request finishes last wins: hydration may turn the advertised default back off, or a later status may overwrite the user's saved choice. Coordinate this model-default update with the hydration fence or apply it only after hydration so the result is deterministic.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 2743bd8. Reproduced against the real store: with a stored preserveThinking: false the settings GET and /api/inference/status race on a cold boot with a resident Qwen3.8, and the raw setState here advanced no scalar mutation version, so whichever landed last won.
Both writers now go through resolvePreserveThinkingOnLoad in chat-runtime-store, which returns the installation's stored answer when there is one and the advertised family default only when there is none. That makes the two orderings agree: a status that overtakes hydration seeds the default and hydration then applies the stored value through the existing fence, and a status that lands after hydration no longer overwrites it. Same rule resolveToolsEnabledOnLoad already applies to the tool pills.
Covered by studio/frontend/tests/preserve-thinking-user-preference.test.ts, which drives the real store through the held settings GET.
|
Confirmed the launch path in studio/backend/core/inference/llama_cpp.py still forces preserve_thinking to false, so a Qwen3.8 load never matches the model's own template default, and the resolved value now reaches the frontend through load and status. Could you get the lint and backend CPU test failures green so this can be reviewed? |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a17ded8ce3
ℹ️ 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".
| preserveThinking: | ||
| reloadingSameModel && supportsPreserveThinking | ||
| ? stateBeforeUnload.preserveThinking | ||
| : preserveThinkingDefaultFromLoad(loadResponse), |
There was a problem hiding this comment.
Preserve the user's setting when returning to Qwen3.8
After settings hydration, switching away from Qwen3.8 and later loading it again makes reloadingSameModel false, so this replaces an explicitly persisted preserveThinking: false with the advertised true default. The direct setState does not update persistence, leaving the current session enabled even though the saved preference remains disabled, and subsequent requests include prior reasoning contrary to the user's choice. Apply the family default only when no user preference exists, rather than on every cross-model load.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 2743bd8. With reloadingSameModel false this branch published the family default unconditionally, so leaving Qwen3.8 and coming back replaced a persisted preserveThinking: false with true in the store while the saved preference stayed false. The same expression also forced the switch off on every cross-family load, which discarded a preference the user had turned on.
It now calls resolvePreserveThinkingOnLoad, so the family default applies only when the installation has never answered; a stored preference and a toggle made this session both win. The regression test covers the away-and-back path and the toggle case.
|
@codex review |
|
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 |
|
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". |
…ff the Qwen3.8 preserve_thinking default (unslothai#15170) Fixes unslothai#15115 Before: on a Qwen3.8 GGUF, Studio always launched llama-server with `--chat-template-kwargs {"preserve_thinking": true}`. llama-server applies that kwarg after `--[no-]reasoning-preserve`, so passing `--no-reasoning-preserve` through `llama_extra_args` did nothing, and a user's `chat_template_override` written as `preserve_thinking|default(false)` was overruled. API clients that can't send `chat_template_kwargs` per request re-sent every past turn's reasoning. After: - The launch `preserve_thinking` value follows an explicit `--reasoning-preserve` / `--no-reasoning-preserve` in the extra args (last flag wins, as in llama.cpp's parser), else an inherited `LLAMA_ARG_REASONING_PRESERVE`. - A `chat_template_override` gets the default its own text renders: Studio renders the override once in a sandboxed Jinja environment with `preserve_thinking` omitted and checks whether an earlier turn's reasoning survives. A copy of Qwen3.8's own template (`preserve_thinking is undefined or ...`) keeps the on default; a `|default(false)` template gets off; a template that does not render falls back to off. - The Qwen3.8 default with its own GGUF template is unchanged (unslothai#9096). - `_preserve_thinking_default` is updated too, so `/load`, `/status`, the Studio toggle and the `/v1/messages` replay path report the value the server actually runs with. Testing: - `TestThePreserveThinkingLaunchDefault` in `tests/test_launch_reasoning_flag.py` drives the real `load_model` with a faked `Popen`: 13 cases, 9 fail on the merge base and all pass here. Reverting the render step to a plain off default fails the two "override that keeps reasoning stays on" cases. - Related suites (`test_launch_reasoning_flag`, `test_gemma4_chat_template_override`, `test_external_preserve_thinking`, `test_anthropic_messages`, `test_safetensors_capability_advertise`, `test_llama_thinking_budget`, `test_managed_engine_reasoning`, `test_openai_auto_switch`): 1738 passed; the 5 `test_openai_auto_switch` MCP cache failures are identical on the merge base. - `test_launch_reasoning_flag.py` on Linux, macOS (Apple Silicon) and Windows: 97 passed on each. - Live llama-server (b11869, CPU, tiny GGUF) `/apply-template` with a historical `reasoning_content` marker, using the reporter's template: the old launch argv keeps the marker even with `--no-reasoning-preserve`; the new argv drops it, and `--reasoning-preserve` brings it back. With Qwen3.8's own template as the override, the marker stays.

Summary
preserve_thinkingon for Qwen3.8 models whose chat template supports itWhy
Qwen3.8 enables
preserve_thinkingby default for all workloads, and its official template retains historical reasoning when the option is omitted or true:Studio initialized
preserveThinkingto false globally and sent that value on every supported chat request. The llama.cpp launch path also explicitly set the option to false. Together, those overrides made Qwen3.8 forget prior reasoning despite the model's documented default.Implementation
The backend now resolves
preserve_thinking_defaultfrom both the model identifier and actual template support. Only a bounded Qwen3.8 family match opts in. The value is exposed on load/status responses and consumed by each frontend model-load and status-adoption path, including queued empty-model auto-loads.Validation
54 passed— focused safetensors capability and template A/B tests417 passed— inference status, GGUF loading, Gemma 4, OpenAI passthrough, tunnel, and active-generation tests3490 passed— complete frontend Node test suitegit diff --checkpasseda41f77853: Qwen3.8 Preserve thinking uncheckede2bdf0502: Qwen3.8 Preserve thinking checked