Default reasoning to on when model has reasoning: true (fix #22456) (#22513)

* Default reasoning to on when model has reasoning: true (fix #22456)

What: When a model is configured with reasoning: true in openclaw.json (e.g. OpenRouter x-ai/grok-4.1-fast), the session now defaults reasoningLevel to on if the user has not set it via /reasoning or session store.

Why: Users expected setting reasoning: true on the model to enable reasoning; previously only session/directive reasoningLevel was used and it always defaulted to off, so Think stayed off despite the model config.

* Chore: sync formatted files from main for CI

* Changelog: note zwffff/main OpenRouter fix

* Changelog: fix OpenRouter entry text

* Update msteams.md

* Update msteams.md

* Update msteams.md

---------

Co-authored-by: 曾文锋0668000834 <zeng.wenfeng@xydigit.com>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
zwffff
2026-02-23 01:19:36 +08:00
committed by GitHub
parent 9ae08ce205
commit c543994e90
5 changed files with 74 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import {
modelKey,
normalizeProviderId,
resolveModelRefFromString,
resolveReasoningDefault,
resolveThinkingDefault,
} from "../../agents/model-selection.js";
import type { OpenClawConfig } from "../../config/config.js";
@@ -32,6 +33,8 @@ type ModelSelectionState = {
allowedModelCatalog: ModelCatalog;
resetModelOverride: boolean;
resolveDefaultThinkingLevel: () => Promise<ThinkLevel>;
/** Default reasoning level from model capability: "on" if model has reasoning, else "off". */
resolveDefaultReasoningLevel: () => Promise<"on" | "off">;
needsModelCatalog: boolean;
};
@@ -397,6 +400,19 @@ export async function createModelSelectionState(params: {
return defaultThinkingLevel;
};
const resolveDefaultReasoningLevel = async (): Promise<"on" | "off"> => {
let catalogForReasoning = modelCatalog ?? allowedModelCatalog;
if (!catalogForReasoning || catalogForReasoning.length === 0) {
modelCatalog = await loadModelCatalog({ config: cfg });
catalogForReasoning = modelCatalog;
}
return resolveReasoningDefault({
provider,
model,
catalog: catalogForReasoning,
});
};
return {
provider,
model,
@@ -404,6 +420,7 @@ export async function createModelSelectionState(params: {
allowedModelCatalog,
resetModelOverride,
resolveDefaultThinkingLevel,
resolveDefaultReasoningLevel,
needsModelCatalog,
};
}