Skip to content

server: an explicit thinking off that a template can't honour is refused - #2170

Merged
ashhart merged 2 commits into
mainfrom
lead/thinking-off-refusal
Nov 8, 2026
Merged

ashhart merged 2 commits into
mainfrom
lead/thinking-off-refusal

Conversation

@ashhart

@ashhart ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Part of #2139.

On a template that has </think> but no switch, thinking off was accepted and then ignored unless the prompt happened to end in a dangling <think>, so the client got a 200 and the model still thought. An explicit thinking off that can't be honoured is now refused before anything is submitted.

What keeps working: requests that don't ask for it, server defaults, raw completions, templates with a real switch, and prompts that already close thinking keep their token ids, with tests for each.

Who could notice: a client that explicitly turns thinking off on such a template now gets a 400 instead of a reply with thinking in it.

A host test through the real text and OpenAI paths fails on main and passes here, and the frozen HTTP goldens show no unexpected difference. No device run.

ashhart added a commit that referenced this pull request Nov 5, 2026
Carry client origin from OpenAI parsing into prompt preparation. Internal compaction notes and Living Weights asks retain the existing prompt policy, while client chat, completion and translated requests keep the explicit-off check.

The host regressions fail for compaction, ask and askIn before the change and pass afterwards alongside the existing client refusal and prompt-ID checks. Refs #2139, #2170.
ashhart added a commit that referenced this pull request Nov 5, 2026
Read the selected model capability once and omit the off field only when it is explicitly unsupported. Unknown servers retain the existing request and are labelled unverified.

Server-default samples carry a local-only settings marker, remain custom protocol cells and are refused by publication validation. Host tests cover request bytes, bounded model discovery and the local save/publication boundary. Refs #2139, #2170.
ashhart added a commit that referenced this pull request Nov 5, 2026
Unknown discovery keeps the legacy off request and labels it off requested (unverified). Only an explicit unsupported switch selects the model default.

Both clients can compare a prior receipt and flag rows with different thinking labels, including per-request modes in mixed runs. Host-only request and CLI tests cover both paths and matching-label controls. Refs #2139, #2170.
ashhart added a commit that referenced this pull request Nov 5, 2026
Expose thinking applicability from the model's close token, separately from
whether its renderer has an off switch. Native and Python clients omit the
off field and label such models not applicable. Preserve the established
gpu-chat-no-think prompt name and compare receipts using their mode labels.

Pin discovery and request behavior for no-thinking models, refresh only the
new model-listing field and HTTP length, and account for the native client's
single discovery GET in its end-to-end tests.

Refs #2139, #2170.
@ashhart

ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

GB10 run, main against this head, Qwen3.8-27B: verdict GREEN. No token differences across runs in the 20 prompt rows I checked. 32K prompts read -0.1 to +0.2%, decode after them 0 to +0.3%, and the 1- and 4-stream chat and code sweeps -0.3 to +0.2%. A level result is what this change should give, since it only refuses a request earlier. The branch now conflicts with main, so it needs a rebase before it can land, and it still owes the thinking-off reply on GLM and LFM2.

@ashhart
ashhart force-pushed the lead/thinking-off-refusal branch 2 times, most recently from e6bb8ee to 9da1f70 Compare November 6, 2026 05:50
@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto today's main (9da1f70c8), with the thinking-off results for GLM and LFM2 that we owed:

checkpoint template its generation prefix explicit thinking off
GLM-5.3-Flash (nvidia/GLM-5.3-Flash-NVFP4) <|assistant|><think> honoured: native closes the block, prompt ends <think></think>, HTTP 200
LFM2.5-24B-A2B (LiquidAI/LFM2.5-24B-A2B-MLX-4bit) <|im_start|>assistant\n<think> honoured: the same native closure, HTTP 200

Neither template reads a named off switch, and both are served as on main. Only a template with neither a switch nor a closable generation prefix is refused, with thinking off is not supported by this chat template: it has no thinking switch or closable generation prefix.

The host tests pin both checkpoints' own templates (unmodified, recorded in THIRD_PARTY_NOTICES.md with revisions and licences): the complete rendered bytes, the closure token ids, all six off spellings under both server defaults, and both discovery aliases. Server host steps: 11 of 11, 1,165 tests passed and 5 skipped; a plain zig build passes 255 of 255. The 27B GB10 A/B from 5 Nov was level, as a change that only refuses earlier should be. Out of draft and into the landing queue.

@ashhart

ashhart commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto main (7d078c13af). Two conflicts, both in docs/api.md, and both resolved by keeping each side:

The thinking and discovery host steps pass on the rebased head: 23 of 23 steps, 190 tests.

@ashhart

ashhart commented Nov 7, 2026

Copy link
Copy Markdown
Owner Author

Held until after the 1.2.4 cut. #2157 landed tonight and gives each /v1/models entry its capabilities from the same source. This branch adds its own capabilities object there (thinking_switch, thinking_applicable), and its prompt-rendering split meets main's new DeepSeek native path in prompt.zig. The two need one shape for the listing, and the 17 golden responses regenerate from that, so this gets a proper rebase rather than a rushed one before the freeze.

ashhart added a commit that referenced this pull request Nov 8, 2026
…sed, on main's capability source (#2170)

#2170 (its commits c66c50e, d9a6676, e6daa05 and 7d078c1) brought onto
main 221aca5 with the two held conflicts resolved:

- #2157's one capability source: thinking_switch and thinking_applicable are Info flags and the last two
  Capability entries, so /v1/models keeps one capabilities object with its fields and order and appends the
  two; the server sets them once at start-up (the off probe renders through the same refusal as a request)
  and an idle reload keeps them; the request refusal reads applicability through Info.capability.
- main's DeepSeek native path in prompt.zig is kept as is: its encoder has a real switch (the synthetic
  source names enable_thinking and thinking_mode) and writes <|Assistant|></think> itself, so it is never refused.

Tests beyond #2170's: raw completions, a switched template whose off render ends without </think>, DeepSeek
off through the OpenAI route, the listing shape and the reload. The 17 /v1/models goldens gain only the two
fields and their Content-Length.

Part of #2139.
@ashhart

ashhart commented Nov 8, 2026

Copy link
Copy Markdown
Owner Author

Reworked onto today's main as two commits (a468db9ff9, eed5bdd3f5), resolving what held it:

  • One listing shape. The two thinking facts are now entries in main's capability source from /v1/models: each model lists what it supports, from the same facts the refusals read #2157 (engine_capabilities.zig), so /v1/models has one capabilities object, with its existing fields and order. The HTTP goldens change only by those two fields.
  • DeepSeek's native path is untouched. Its template's thinking is the encoder's own switch, so it's published and never refused there. A test pins that.
  • Only the client's own off is refused. A review before pushing found that the original server: an explicit thinking off that a template can't honour is refused #2170 would refuse Anthropic /v1/messages requests that leave out thinking: the translator fills in a disabled default, and that counted as an explicit off. Now Input.explicit_off is set only from a thinking off the client actually sent, on chat, completions, messages and count_tokens alike. A server default, a template default or --no-thinking never counts. The rendered token ids are unchanged everywhere main served.
  • Tests:
    • /v1/messages with no thinking on a switchless </think> template gives a 200 with main's ids (it fails on the first commit, passes on the second);
    • "thinking":{"type":"disabled"} there gives a 400;
    • count_tokens agrees with both;
    • every "keeps working" case from the description keeps its ids.

Server suites, test-golden, the bench tool tests, fmt and lean (0 new) pass.

@ashhart
ashhart force-pushed the lead/thinking-off-refusal branch from 7d078c1 to eed5bdd Compare November 8, 2026 06:12
ashhart added a commit that referenced this pull request Nov 8, 2026
…ges default (#2170)

/v1/messages fills a missing `thinking` in as disabled and writes enable_thinking false and
reasoning_effort none for the template. #2170's refusal read those fields as the client's own off, so a
Messages request that left thinking out got HTTP 400 on a template with a one-token </think> and no switch
or closable prefix, where main served it with 200. #2170's original commits had the same path.

The translator now reports whether the client sent `thinking`; Messages passes that to runNamed, plan sets
chat.Input.explicit_off only for an off among the client's own fields, and the prompt refuses only then.
The kwargs are unchanged, so every rendered prompt keeps its ids. count_tokens follows the same rule: it
refuses the bodies /v1/messages refuses and otherwise counts the prompt it submits. Chat, completions and
Responses bodies are the client's own; --no-thinking and template defaults never reach those fields.

Tests: Messages without thinking (switchless, always-closed and dangling templates, both server defaults)
is served with main's ids and counted the same; its own disabled is refused on both routes and honoured
by a switch; Responses without reasoning is served under either default, and its effort none is refused.

Part of #2139.
…sed, on main's capability source (#2170)

main 221aca5 with the two held conflicts resolved:

- #2157's one capability source: thinking_switch and thinking_applicable are Info flags and the last two
  Capability entries, so /v1/models keeps one capabilities object with its fields and order and appends the
  two; the server sets them once at start-up (the off probe renders through the same refusal as a request)
  and an idle reload keeps them; the request refusal reads applicability through Info.capability.
- main's DeepSeek native path in prompt.zig is kept as is: its encoder has a real switch (the synthetic
  source names enable_thinking and thinking_mode) and writes <|Assistant|></think> itself, so it is never refused.

Tests beyond #2170's: raw completions, a switched template whose off render ends without </think>, DeepSeek
off through the OpenAI route, the listing shape and the reload. The 17 /v1/models goldens gain only the two
fields and their Content-Length.

Part of #2139.
…ges default (#2170)

/v1/messages fills a missing `thinking` in as disabled and writes enable_thinking false and
reasoning_effort none for the template. #2170's refusal read those fields as the client's own off, so a
Messages request that left thinking out got HTTP 400 on a template with a one-token </think> and no switch
or closable prefix, where main served it with 200. #2170's original commits had the same path.

The translator now reports whether the client sent `thinking`; Messages passes that to runNamed, plan sets
chat.Input.explicit_off only for an off among the client's own fields, and the prompt refuses only then.
The kwargs are unchanged, so every rendered prompt keeps its ids. count_tokens follows the same rule: it
refuses the bodies /v1/messages refuses and otherwise counts the prompt it submits. Chat, completions and
Responses bodies are the client's own; --no-thinking and template defaults never reach those fields.

Tests: Messages without thinking (switchless, always-closed and dangling templates, both server defaults)
is served with main's ids and counted the same; its own disabled is refused on both routes and honoured
by a switch; Responses without reasoning is served under either default, and its effort none is refused.

Part of #2139.
@ashhart
ashhart force-pushed the lead/thinking-off-refusal branch from eed5bdd to e4e6849 Compare November 8, 2026 07:29
@ashhart
ashhart merged commit 45f96da into main Nov 8, 2026
ashhart added a commit that referenced this pull request Nov 8, 2026
…sed, on main's capability source (#2170)

main 221aca5 with the two held conflicts resolved:

- #2157's one capability source: thinking_switch and thinking_applicable are Info flags and the last two
  Capability entries, so /v1/models keeps one capabilities object with its fields and order and appends the
  two; the server sets them once at start-up (the off probe renders through the same refusal as a request)
  and an idle reload keeps them; the request refusal reads applicability through Info.capability.
- main's DeepSeek native path in prompt.zig is kept as is: its encoder has a real switch (the synthetic
  source names enable_thinking and thinking_mode) and writes <|Assistant|></think> itself, so it is never refused.

Tests beyond #2170's: raw completions, a switched template whose off render ends without </think>, DeepSeek
off through the OpenAI route, the listing shape and the reload. The 17 /v1/models goldens gain only the two
fields and their Content-Length.

Part of #2139.
ashhart added a commit that referenced this pull request Nov 8, 2026
Every PR merged since v1.2.4 now has exactly one line under Unreleased:
duplicate lines from stacked and train-merged PRs are removed (#2280,
#2384, #2532, #2548, #2170, #2506, #2304, #2241), keeping the fuller
line; #2280's and #2344's lines carry their own numbers; #2176 names the
#1335 it carries; and the finders of #2515's and #2463's problems and
#2526's reporter are thanked by handle. The 1.2.4 section is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant