Repository navigation
ThinkBudget alone owns thinking: a response format no longer turns it off - #5808
Merged
Merged
Conversation
… off
Defect (Cormac, 2026-11-06, probing fork llama-server 0d7dda6ae): request_body::finish_body set
chat_template_kwargs.enable_thinking=false for ANY response_format, Text included, so a
format-bound request never thought whatever ThinkBudget it carried. The fork composes a format
with thinking: the template's reasoning rule wraps the schema (common/chat.cpp:1235-1244) and the
budget sampler runs before the grammar (common/sampling.cpp:631): budget 40 -> forced </think>,
then schema-valid JSON, finish=stop.
One owner: request_body::apply_think(think, body) (replaces apply_reasoning_budget and
apply_enable_thinking_false). Some(n>0): thinks, reasoning_budget_tokens n, template left on.
Some(0): the caller's explicit no-think, enable_thinking=false + budget 0. None: model default.
Side rules removed, each now reading the one fact:
- response_format -> enable_thinking=false (the defect): deleted.
- purpose == VISION_DESCRIPTION_PURPOSE -> enable_thinking=false: deleted; vision_describe now
states its intent as ai/generate's think term ("think": 0).
- gateway ThinkingMode::Suppress (enable_thinking=false + the /no_think text switch appended to
her last user message): dead, no provider declared suppress_thinking. Deleted ThinkingMode,
OpenAICompatibleConfig.thinking, ProviderCapabilities.suppress_thinking, apply_no_think_switch
and their tests.
- the readiness smoke body's hand-written enable_thinking/reasoning_budget_tokens pair: now
apply_think(Some(ThinkBudget(0))).
Behaviour change to note: callers carrying a response_format and no think term
(should_respond, rag_inspect: JsonObject; generate_response, validate_response: Text) now get the
model's default (think) instead of a forced no-think. Budget 0 still relies on the fork for
templates without an enable_thinking branch (Cormac's card 8b479782).
Tests (request_body's one test mod): the_think_budget_is_the_callers_measured_one_and_nothing_else
(extended: zero closes the template, None leaves it); new
a_response_format_never_turns_her_thinking_off_only_her_think_term_does (JsonObject and Text with
ThinkBudget(40) keep thinking at 40; ThinkBudget(0) turns it off; a purpose is not a think term).
vision_describe test asserts the description's zero think term parses as ai/generate's.
Validated (worktree, CARGO_TARGET_DIR=cargo-target-thinkown, nice 19, serving untouched):
cargo check -p continuum-engine --features continuum-engine/metal; cargo test -p continuum-engine
--lib (1498 passed, 16 ignored); cargo check + test -p continuum-cognition (vision_describe,
working_memory, act_output_room: 80 passed); source-hygiene ratchets vs 640a07b (87 passed, no
count rose); oversized-edits exit 0. No ts-rs wire type changed. 89 added, 241 removed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…red and the terms-less paths take an engine-only witness Review of #5808 (coordinator, Cormac). The think term is REQUIRED for every generation the core makes, enforced by the compiler: - ai/think.rs (new; ThinkBudget and DispatchTerms moved out of types.rs, re-exported there): `Think { Budget(ThinkBudget), ModelDefault }`. `DispatchTerms::think` is a `Think`: no Option, no Default (DispatchTerms' Default derive is gone), constructor `DispatchTerms::thinking`. - adapter::Dispatched: a witness with a private field, built only by the engine's dispatch (`Dispatched::under(&terms)`; `fixture()` behind test-fixtures). `generate_text`, `generate_stream` and `generate_stream_checked` take it, so a caller outside the engine cannot reach a terms-less path: it generates through `DispatchTermsPolicy::generate_admitted`, or the new provided drain `generate_under(request, terms)`, and states its think. A wrapping adapter forwards the witness it was handed; the witness carries the terms (OpenAI's terms-less stream reads `dispatched.terms()`, the grid lane forwards its budget). - Compile-fail doctests on DispatchTerms pin both: terms without a think, and building the witness outside the engine, do not compile. Callers, each explicit with its current behaviour: - ThinkBudget(0), today's no-think now stated by the one owner: cognition/should_respond (JSON), cognition/generate_response (Text), cognition/validate_response (Text), persona/rag_inspect (JSON). - Think::ModelDefault (no think term, as they always ran; measured per-purpose budgets with an upward probe are a follow-up card, owner Fable): rate_proposals, generate_recipe (through the registry helper, which now takes terms), request_replay, academy dream distiller, genome teach, models/try (both probes), engine llm_module_service, handle_store, the in-process warm-up. - External passthrough keeps its own: the gateway (ModelDefault, the client's body decides) and ai/generate (`Think::from_wire(params.think)`; one generate_admitted path replaces its four-way match). - Acts: `Think::Budget(act_reasoning_budget(..))`, unchanged on the wire. Template check (Cormac verified; receipt here too): the M5 engine's /props (fork b11009-0d7dda6ae, Qwen3.6-35B-A3B-Q4_K_M, chat_template sha256 e84f32a2...) reads `enable_thinking` only under `add_generation_prompt` (`<think>\n\n</think>\n\n` vs `<think>\n`); prior assistant turns render by `preserve_thinking` / `last_query_index`. Budget 0 => enable_thinking=false keeps her prefix. Touched files leave clean (ratchets judge a touched file whole): - generate_response: `admission` is REQUIRED (GenerateResponseAdmissionPolicy, no Option); the self-sized DEFAULT_GENERATE_MAX_CONCURRENCY / MAX_COST_UNITS / COST_UNITS / LEASE_TTL_PAD constants and `with_timeout` are deleted (ts-rs GenerateResponseRequest.ts regenerated). - rag_inspect: the decide-and-respond parse is a typed serde struct, not two "missing ..." complaints. - heuristic_adapter (test fixture): echoes the whole last message (ECHO_CHARS deleted); the fingerprint is the digest's leading u32, not `.take(4)`. - airc_remote_inference_end_to_end: the missing-module assertion pins the hard error task #219 landed (it failed on base: the TS-bridge fallthrough it pinned is gone). Validated (worktree, CARGO_TARGET_DIR=cargo-target-thinkown, nice 19, serving untouched): - plain check: engine (metal), cognition, mind, academy, models, sentinel, gateway, genome, core, base: no errors, no new warnings. - tests: engine lib 1498 passed (16 ignored) + 2 compile-fail doctests; cognition lib 940; mind 1108; academy 192; genome 345; gateway 19; models 34; core lib 1189; core airc_remote_inference_end_to_end 3 + persona_command_inbound_pump 1 (test-fixtures); core --tests check with and without test-fixtures. - source-hygiene ratchets vs 640a07b: 87 passed, no count rose; oversized-edits exit 0. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…doctests name their error codes Cormac's review of #5808 at 3f808a2: - Retracted claim removed: ThinkBudget's doc said the pinned fork's sampler forces the end tag at a zero budget. False on 0d7dda6ae; true only from the fork fix on (llama.cpp#95, card c5fb32b7). Restated in think.rs: zero is no-think through both levers, the template's enable_thinking=false on every pin (Cormac's receipt: deployed engine 0d7dda6ae, Qwen3.5-0.8B on the IntelMac ~01:10Z 2026-11-07: empty reasoning, 96 tokens of schema JSON, a 56-token answer, finish=stop), and the sampler's reasoning_budget_tokens 0 from the fork fix on. The same claim restated in request_body::apply_think's doc and act_room::act_reasoning_budget's doc (grep for "forces the end tag" / REASONING_BUDGET_FORCING: no other site). - Doctests pinned: compile_fail,E0063 (terms without `think`) and compile_fail,E0423 (building Dispatched's private tuple field outside the engine). E0423, not E0603: rustc 1.96 reports "cannot initialize a tuple struct which contains private fields" (checked by compiling both snippets as a throwaway example: E0063 and E0423). Note: stable rustdoc does not enforce the code (a wrong code still passed); the codes are enforced where rustdoc runs on nightly. Doctests: 2 passed (cargo test -p continuum-engine --doc think). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…omments; CI's drift detector) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply
enabled auto-merge (squash)
November 7, 2026 01:23
joelteply
disabled auto-merge
November 7, 2026 01:24
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.
How this serves the minds: a resident whose request carries a structured format can reason before answering, within the budget her faculty measured. Her think term is the only thing that decides whether she thinks, and every generation the core makes has to state one. Order of work: line 2/3 (serving; the engine's request contract), "one owner per fact".
The defect
Found by Cormac on 2026-11-06, probing fork llama-server 0d7dda6ae.
request_body::finish_body(canary 640a07b,request_body.rs:127-138) setenable_thinking = falsefor anyresponse_format, Text included. A request with a format therefore never thought, whatever budget it carried. The fork handles a format and thinking together: the reasoning rule wraps the schema (common/chat.cpp:1235-1244) and the budget sampler runs before the grammar (common/sampling.cpp:631).One owner
request_body::apply_think(Think, body)is the only place that decides thinking:Think::Budget(n > 0): she thinks, withreasoning_budget_tokens: n.Think::Budget(0): the caller's explicit no-think. The body getsenable_thinking = falseand a zero budget.Think::ModelDefault: no think term on the body.Side rules deleted:
response_formatturning thinking off (the defect).purpose == VISION_DESCRIPTION_PURPOSEturning thinking off.vision_describenow sends"think": 0itself.ThinkingMode::Suppressand its/no_thinktext switch: no provider declared it. RemovedThinkingMode,suppress_thinkingandapply_no_think_switch.apply_think.Required, enforced by the compiler
DispatchTerms::thinkis aThink(ai/think.rs). It is not an Option and has no Default.generate_text,generate_stream,generate_stream_checked) take anadapter::Dispatchedwitness. Its field is private and only the engine's dispatch builds it; a test-onlyfixture()sits behindtest-fixtures.generate_admitted, or the new draingenerate_under(request, terms), and must state its think.thinkstays onDispatchTerms(Cormac). Restricting the terms-less paths with a witness is the one way to make them unreachable across crates while adapters in other crates (PlacementSwitch, test adapters) can still implement and forward them.compile_faildoctests onDispatchTermscheck both halves: terms without a think, and building the witness outside the engine.Callers, each explicit with its current behaviour
Budget(ThinkBudget(0))(today's no-think, now stated)ModelDefault(as they always ran)ModelDefault); ai/generate (Think::from_wire(params.think), one path)Budget(act_reasoning_budget(..)), unchanged on the wireFollow-up card, owner Fable: measured per-purpose think budgets with a scheduled upward probe for these utility calls. Until then, the unmeasured prior is the mind's measured act think need.
Template check
Cormac verified this, and here is my own receipt. A read-only GET of
/propson the M5 engine (port 58057, fork b11009-0d7dda6ae, Qwen3.6-35B-A3B-Q4_K_M, chat_template sha256 e84f32a2…) showsenable_thinkingread only underadd_generation_prompt:<think>\n\n</think>\n\ninstead of<think>\n. Prior assistant turns render bypreserve_thinkingandlast_query_index. Budget 0 =>enable_thinking=falsetherefore keeps her prefix.Touched files leave clean
admissionis now required. The self-sizedDEFAULT_GENERATE_MAX_*constants, cost units, TTL pad andwith_timeoutare deleted, and ts-rsGenerateResponseRequest.tsis regenerated.Measured
Run in the worktree at 3f808a2 (2026-11-07) with
CARGO_TARGET_DIR=cargo-target-thinkownandnice -n 19. Crate-scoped; serving was not touched.airc_remote_inference_end_to_end3 andpersona_command_inbound_pump1 (withtest-fixtures)The live check comes after deploy: the format-bound callers' act time on the M5.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo