mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:21:23 +00:00
feat: support per-model thinkingDefault override in models config
The global `agents.defaults.thinkingDefault` forces a single thinking
level for all models. Users running multiple models with different
reasoning capabilities (e.g. Claude with extended thinking, GPT-4o
without, Gemini Flash with lightweight reasoning) cannot optimise the
thinking level per model.
Add an optional `thinkingDefault` field to `AgentModelEntryConfig` so
each entry under `agents.defaults.models` can declare its own default.
Resolution priority: per-model → global → catalog auto-detect.
Example config:
"models": {
"anthropic/claude-sonnet-4-20250514": { "thinkingDefault": "high" },
"openai/gpt-4o": { "thinkingDefault": "off" }
}
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
Peter Steinberger
parent
e368c36503
commit
671f913123
@@ -425,10 +425,29 @@ export function resolveThinkingDefault(params: {
|
||||
model: string;
|
||||
catalog?: ModelCatalogEntry[];
|
||||
}): ThinkLevel {
|
||||
// 1. Per-model thinkingDefault (highest priority)
|
||||
// Normalize config keys via parseModelRef (consistent with buildModelAliasIndex,
|
||||
// buildAllowedModelSet, etc.) so aliases like "anthropic/opus-4.6" resolve correctly.
|
||||
const configModels = params.cfg.agents?.defaults?.models ?? {};
|
||||
for (const [rawKey, entry] of Object.entries(configModels)) {
|
||||
const parsed = parseModelRef(rawKey, params.provider);
|
||||
if (
|
||||
parsed &&
|
||||
parsed.provider === params.provider &&
|
||||
parsed.model === params.model &&
|
||||
entry?.thinkingDefault
|
||||
) {
|
||||
return entry.thinkingDefault as ThinkLevel;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Global thinkingDefault
|
||||
const configured = params.cfg.agents?.defaults?.thinkingDefault;
|
||||
if (configured) {
|
||||
return configured;
|
||||
}
|
||||
|
||||
// 3. Auto-detect from model catalog (reasoning-capable → "low")
|
||||
const candidate = params.catalog?.find(
|
||||
(entry) => entry.provider === params.provider && entry.id === params.model,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user