fix(agents): gate auto reasoning by effective thinking level (openclaw#24335) thanks @Kay-051

This commit is contained in:
Nimrod Gutman
2026-02-23 14:58:26 +02:00
committed by Nimrod Gutman
parent 42795b87a3
commit 9d37654a90
3 changed files with 41 additions and 6 deletions

View File

@@ -389,14 +389,16 @@ export async function resolveReplyDirectives(params: {
provider = modelState.provider;
model = modelState.model;
// When neither directive nor session set reasoning, default to model capability (e.g. OpenRouter with reasoning: true).
// Skip auto-enabling when thinking is already active — the model's internal
// thinking blocks would otherwise be formatted and delivered as visible
// "Reasoning:" messages, leaking internal content to the user.
// When neither directive nor session set reasoning, default to model capability
// (e.g. OpenRouter with reasoning: true). Skip auto-enabling when thinking is
// active, including model-inferred defaults, or internal thinking blocks can
// be emitted as visible "Reasoning:" messages.
const reasoningExplicitlySet =
directives.reasoningLevel !== undefined ||
(sessionEntry?.reasoningLevel !== undefined && sessionEntry?.reasoningLevel !== null);
const thinkingActive = resolvedThinkLevel !== undefined && resolvedThinkLevel !== "off";
const effectiveThinkingForReasoning =
resolvedThinkLevel ?? (await modelState.resolveDefaultThinkingLevel());
const thinkingActive = effectiveThinkingForReasoning !== "off";
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off" && !thinkingActive) {
resolvedReasoningLevel = await modelState.resolveDefaultReasoningLevel();
}