Repository navigation
Description
Summary
Thinking-level support is encoded in code rather than data, and the encoding is duplicated across three layers that can disagree. Adding a model family means editing packages/ai predicates, provider if/else trees, tests and docs, then rebuilding dreb — and a custom models.json endpoint has no way to declare it at all.
Observed in practice: a local Anthropic-compatible gateway (api: "anthropic-messages", model deepseek-v4.1-flash) accepts output_config: { effort: "max" } and returns thinking blocks — verified with a direct request — but dreb cannot offer max for it. supportsMax() returns false (id not in the hardcoded families), so the session clamps max → xhigh → high, and an explicit max is a hard error in validateThinkingLevelForModel(). There is no models.json override for this: ModelDefinitionSchema/ModelOverrideSchema expose only reasoning: boolean, and compat is typed for openai-completions only — so an anthropic-messages gateway has zero knobs.
Root causes
-
Capabilities are boolean predicates over model-id regexes, in
packages/ai/src/models.ts:supportsMax()(:221),supportsXhigh()(:246),supportsAdaptiveThinking()(:269),supportsThinkingOff()(:284),getClaudeThinkingOffMode()(:300),isQwen38OrLater()(:206), plusclaudeFamilyVersion()/nativeClaude().- One commit per family is the observable consequence:
b29f468(GPT-5.6 max),4d74107(Claude 5.5 xhigh/max),b83112b(Qwen),02eab03(Kimi).
-
Tiers are not representable outside code.
ThinkingBudgets(packages/ai/src/types.ts:48) has onlyminimal|low|medium|high. Soxhigh/maxcannot exist on a budget-based transport, andclampReasoning()(packages/ai/src/providers/simple-options.ts:19) hardcodesxhigh|max → high. The capability gate and the wire layer cannot agree on the top two tiers — a correctsupportsMax()alone still produceshighbehaviour on budget transports. -
No override surface.
ModelDefinitionSchema(packages/coding-agent/src/core/model-registry.ts:87),ModelOverrideSchema(:111) andapplyModelOverride()(:294) know nothing about thinking;compat.thinkingFormat(packages/ai/src/providers/openai-completions.ts:415-460) is a closed enum of per-vendor branches rather than data. -
Provider payload code branches on model id rather than on a capability:
packages/ai/src/providers/anthropic.ts:698-775(adaptive vs budget vs off-mode),amazon-bedrock.ts:711,openai-completions.ts:415-460.
Proposed work
Introduce one declarative capability descriptor on the model record and derive everything from it. Heuristics stay as a fallback for unknown ids, so behaviour for existing models is unchanged.
// packages/ai/src/types.ts
export type ThinkingEncodingKind = "effort" | "budget" | "toggle" | "adaptive";
export interface ThinkingEncoding {
kind: ThinkingEncodingKind;
// reserved for the provider work (stage 2):
field?: string;
map?: Partial<Record<ThinkingLevel, string>>;
budgets?: Partial<Record<ThinkingLevel, number>>;
}
export interface ThinkingCapability {
/** Supported tiers, ascending; empty for non-reasoning models. "off" is expressed by `off`. */
levels: ThinkingLevel[];
/** How a request disables thinking. `"omit"` means it cannot be disabled. */
off: "disabled" | "between_tools" | "omit";
encoding: ThinkingEncoding;
}
export interface Model<TApi extends Api> {
// ...
thinking?: ThinkingCapability;
}Resolution order in getThinkingCapability(model): model.thinking (from models.json) → curated catalog data → id-heuristic inference (today's rules, moved verbatim) → conservative default (reasoning ? [minimal..high] : []). supportsMax/supportsXhigh/supportsThinkingOff/supportsAdaptiveThinking/getAvailableThinkingLevels/clampThinkingLevel become thin derivations with unchanged signatures, so coding-agent call sites don't move.
Stage 1 (this issue's first PR): descriptor + config surface, zero provider changes.
- New types and
Model.thinking. getThinkingCapability()+ inference that reproduces current behaviour exactly (proved by a golden snapshot over every registered model).- Route the existing helpers through the capability.
thinkingaccepted inmodels.jsonat both model-definition and per-model-override level, deep-merged inapplyModelOverride(), validated invalidateConfig().- Docs:
packages/coding-agent/docs/models.mdfield table + example,packages/ai/README.mdhelpers note.
A user can then fix the deepseek-v4.1-flash case above, and any future gateway model, without a rebuild:
{ "providers": { "tux-anthropic": { "modelOverrides": { "deepseek-v4.1-flash": {
"thinking": {
"levels": ["minimal", "low", "medium", "high", "xhigh", "max"],
"off": "disabled",
"encoding": { "kind": "effort" }
} } } } } }Note: until stage 2 lands, a declared tier is accepted and offered but the provider still uses its existing branch, so max on a non-adaptive transport is not yet sent on the wire. Stage 1 is deliberately behaviour-neutral for stock models.
Stage 2: providers switch on encoding.kind instead of model id; ThinkingBudgets extended to all six tiers; clampReasoning() stops folding xhigh/max into high; anthropic.ts/bedrock read encoding for the adaptive/effort case.
Stage 3: scripts/generate-models.ts emits thinking (models.dev/OpenRouter data merged with a curated data-only catalog), shrinking the heuristics to an unknown-id fallback.
Acceptance criteria
-
getThinkingCapability(model)returns identical effective behaviour to today for every model in the generated registry (golden snapshot test added). -
supportsMax,supportsXhigh,supportsAdaptiveThinking,supportsThinkingOff,getClaudeThinkingOffMode,getAvailableThinkingLevelskeep their exported signatures and values; existing tests pass unchanged. -
models.jsonacceptsthinkingin bothmodels[]andmodelOverrides, with validation errors that name the offending provider/model. - Invalid capability data (unknown tier, unknown
off/kind, duplicate or unsorted levels) is rejected or normalised deterministically, covered by tests. - Docs updated (
docs/models.md,packages/ai/README.md).
Out of scope
- Provider payload rewrites (stage 2) and codegen/catalog work (stage 3) — separate PRs.
- Runtime capability probing against a live endpoint.
- Changing the session-facing
ThinkingLevelscale or the selector UX.
Prior art
#545 / #546 (Claude 5.5 effort levels), #338 (GPT-5.6 max), #117 (effort mapping), #250 (Opus 4.7+ display), #466 (Qwen effort forwarding).
Activity
tobiasploetz commentedon Nov 5, 2026
Stage 1 is implemented in a fork PR: tobiasploetz#9 (base
main-tp).Scope delivered matches the "Stage 1" bullet list above — descriptor types,
getThinkingCapability()resolver with the existing heuristics preserved as the inference fallback, all helper signatures unchanged, andthinkingaccepted onmodels.jsoncustom models andmodelOverrides.Evidence that it is behaviour-neutral for stock models: a new golden snapshot pins
off | levels | encoding.kindfor every registered model, and the 211 existing capability assertions insupports-max/supports-xhigh/supports-thinking-off/supports-adaptive-thinkingpass untouched (full suite 6952 passed).Two design decisions worth a maintainer's eye before stage 2:
Model.thinkingis typed as the partialThinkingCapabilityDeclaration, whileThinkingCapabilityis the resolved form. Read sites go throughgetThinkingCapability(); direct field access would see optional values. This keeps SDK construction and single-field overrides ergonomic.encodingcarriesfield/map/budgetsalready, so stage 2 can be provider-only without anothermodels.jsonschema change. Onlykind === "adaptive"andoffaffect requests today — the docs say so explicitly, so a declared tier is selectable but inert on the wire until stage 2.Stages 2 and 3 will be separate PRs against the same base per the repo's small-PR guidance.
m-aebrer commentedon Nov 6, 2026
This seems really promising! Can you give me a plain english ELI5 description of what it's doing though? It's a bit jargony as written.