Skip to content

Studio: keep <think> text visible in the reply when Thinking is off - #11481

Merged
Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:chat-literal-think-when-thinking-off
Sep 22, 2026
Merged

Lyxot merged 4 commits into
unslothai:mainfrom
NilayYadav:chat-literal-think-when-thinking-off

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Follow up to #10662. With Thinking off, if the model writes <think> in its answer, for example while explaining the tag, Chat hides that part as a collapsed thinking block. With Qwen3 this hid almost the whole answer, and it stayed hidden after a reload. #10662 fixed this on the server, but the Chat page still split the text on its own.

Chat now leaves the text as it is when Thinking is off, and still shows a thinking block whenever the model really sends its thinking. Tested with Qwen3 in the browser: main showed only "The `" and a thinking block, this branch showed the full answer. Thinking on works the same as before.

@NilayYadav

NilayYadav commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review + UI evidence

Head 7f3f0a7c. Real Studio in Chromium at 1280×900, two separate installs: BEFORE is the merge base b37bddb4 (which already has #10662), AFTER is this branch. Both run gemma-3-270m-it Q4_K_M loaded with a hybrid enable_thinking template whose answer is Use <think>hi</think> in your prompt.. The Thinking pill is clicked off in the composer and the turn is sent from the composer.

BEFORE AFTER
server reply (/v1/chat/completions, thinking off) Use <think>hi</think> in your prompt. same
chat bubble Use · Worked for 0s · in your prompt. Use hi in your prompt.
stored message parts text, reasoning, text text
stored parseThinkTags absent false
thread reopened after reload still split one reply
Thinking on (control, fresh chat) folded into reasoning folded into reasoning (unchanged)

Live reply
PR 11481 live reply

Same thread reopened
PR 11481 reopened thread

Control: Thinking on still folds the tags
PR 11481 thinking-on control

The bare tags render as Use hi in your prompt. because the markdown renderer drops unknown raw HTML tags, as it does for any <tag> on main. Inside backticks they show literally. What this PR fixes is the answer being folded into a thinking block.

Review fixes pushed

  • 4212a7f6: a reload before the first client save used to recover the reply with think parsing on, because the server-created placeholder has no parseThinkTags. Recovery now reads the choice from the run's request (thinking: disabled, enable_thinking: false or reasoning_effort: none) and stores it.
  • 7f3f0a7c: the think-parse decision now runs before Continue's first yield. Before, a Stop during model load could save a literal <think> partial as reasoning.

Both come with regression tests that fail on the commit before the fix. The frontend suite passes 8224/8224, and typecheck matches base: its one error, sidebar-row-drag.test.ts, is also on main. The screenshots and table are from the AFTER install at 7f3f0a7c.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the client side still splits unconditionally in studio/frontend/src/features/chat/utils/parse-assistant-content.ts, so the reply gets folded away even after the server fix, and the reasoning-arrives fallback plus the recovery path both look right here. Will get this reviewed.

@Lyxot Lyxot self-assigned this Sep 22, 2026
The live stream used its own thinking-off rule while recovery read the stored request, so an effort of none (Inkling-style local templates, OpenAI-style external ladders) still split literal <think> text live even though the server leaves it as reply text. Build the reasoning fields once, send them, and decide parsing from them with requestParsesThinkTags.
@Lyxot

Lyxot commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Pushed e78f0d4 on top of your three commits. It fixes one gap. The live stream decided "Thinking off" with its own boolean, while recovery read the stored request with requestParsesThinkTags, and the two disagreed when the effort level is none:

  • Local effort-dial templates (Inkling-style). These offer none as a level, and the composer shows it as Thinking off. The request sends reasoning_effort: "none", so the server leaves <think> as reply text, but the adapter still parsed it because reasoningStyle === "reasoning_effort" always parsed. The original bug stayed for these models, and recovery disagreed with the live stream.
  • External effort ladders that include none (for example OpenAI gpt-5.x). The same mismatch between live and recovery.

The reasoning request fields are now built once, before the continuation yield. Both payloads send them, and the parse decision is requestParsesThinkTags applied to those same fields, plus reasoningAlwaysOn for local models. The live stream and recovery now apply one rule to the same input, and request payloads are unchanged. Tests cover the local effort, GLM-style and non-reasoning cases and an external effort of none. The external-thinking-wire extractor is updated to read the named external fields.

Codex review on a staging copy converged: Lyxot#67 (comment). The staging copy is Lyxot#67, which is this PR at e78f0d4 merged onto main 5e04590, with an identical diff.

The first two passes each raised a P2. Both are true edge cases, answered and resolved in-thread without code changes to keep this PR small:

  • A tool card whose offset falls inside a literal tag's characters is moved to the end of the tag. That needs the model to stop mid-<think>, call a tool, and resume the tag in its next turn. Even then, the card only shifts by a few characters.
  • If you stop a Thinking-off reply, switch Thinking on and press Continue, the quoted prefix is reparsed as reasoning. Handling that would need a parse mode per segment across the continuation boundary.

CI on the staging PR: 40 passed, 5 failed. None of the failures involve this change, and each fails the same way on main at 5e04590 or is a runner problem:

  • Chat UI Tests (chat), Chat UI Tests (Windows, extra lane) and the macOS Chat UI, API, Update and GGUF inference job: the update-banner layout check fails at 390x500 and 320x480 with "the card does not clip its own copy away". This is identical on main's Unsloth UI CI and Windows Unsloth UI CI.
  • Repo tests (CPU, studio): the same 12 layout-contract failures as main's Backend CI (test_desktop_reliability_frontend_contract.py, test_update_release_notes.py).
  • Composer (macos-latest, safari): a runner problem, because Safari WebDriver timed out creating a session.

This PR's own frontend unit tests pass, along with Frontend build + bundle sanity, which fails on this PR's old merge base only because of the sidebar-row-drag typecheck that #11503 fixed.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. The client now follows the same thinking-off decision as the server and recovery. Codex converged on a staging copy, and the remaining CI failures also fail on main or are flaky.

@Lyxot
Lyxot merged commit 9055780 into unslothai:main Sep 22, 2026
41 of 46 checks passed
CelesteHeartsong pushed a commit to CelesteHeartsong/unsloth that referenced this pull request Sep 22, 2026
…i#10365 conflicts)

unslothai#10365 landed on main after this branch last merged, so the durable-turns code it
introduced collided with the copy carried here. Resolved per file:

- backend chat_generation_runs.py, tool_approvals.py, test_tool_approvals.py and
  tests/studio/test_multi_chat_prompt_queue_contract.py: take main's reviewed
  version (attended/unattended park, lease renewal, robust env parse, decision
  reasons). No replay-specific content was lost.
- chat-adapter.ts: keep the shapeToolResult shaper; drop the now-duplicate local
  isMcpImageToolResult (imported from utils/tool-result-shape); keep
  isBareMcpImageWrapper (still called in the live path).
- generation-tool-recovery.test.ts: union the mock store stubs
  (set/clearToolConfirmation + append/clearToolLiveOutput).
- runtime-provider.tsx: keep createRecoveryReplay (this PR's replay impl).

Follow-ups before this lands on main: tsc -b + npm test; backend
test_tool_approvals + test_chat_generation_runs; port unslothai#11481
(requestParsesThinkTags/parseThink) onto the replay path.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…nslothai#11481)

* Studio: keep literal <think> text in the chat reply when Thinking is off

* Studio: read the think-parse choice from the request when recovery starts before the first save

* Studio: decide think parsing before the continuation's first yield

* Studio: decide think parsing from the reasoning fields the request sends

The live stream used its own thinking-off rule while recovery read the stored request, so an effort of none (Inkling-style local templates, OpenAI-style external ladders) still split literal <think> text live even though the server leaves it as reply text. Build the reasoning fields once, send them, and decide parsing from them with requestParsesThinkTags.

---------

Co-authored-by: Lyxot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants