mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-26 17:32:16 +00:00
fix(reasoning): guard model default reasoning when thinking active
- Add hasAgentReasoningDefault to reasoningExplicitlySet check This prevents model default from overriding agent's explicit "off" - Restore !thinkingActive guard for model default fallback Prevents redundant Reasoning: output alongside internal thinking Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -121,4 +121,19 @@ describe("resolveCurrentDirectiveLevels", () => {
|
||||
|
||||
expect(result.currentReasoningLevel).toBe("off");
|
||||
});
|
||||
|
||||
it("respects agent reasoningDefault: off as explicit override", async () => {
|
||||
const resolveDefaultThinkingLevel = vi.fn().mockResolvedValue("off");
|
||||
|
||||
const result = await resolveCurrentDirectiveLevels({
|
||||
sessionEntry: {},
|
||||
agentEntry: {
|
||||
reasoningDefault: "off",
|
||||
},
|
||||
resolveDefaultThinkingLevel,
|
||||
});
|
||||
|
||||
// Agent explicitly setting "off" should be respected, not overridden by model default
|
||||
expect(result.currentReasoningLevel).toBe("off");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -434,11 +434,16 @@ export async function resolveReplyDirectives(params: {
|
||||
(agentCfg?.thinkingDefault as ThinkLevel | undefined);
|
||||
|
||||
// When neither directive nor session nor agent set reasoning, default to model capability
|
||||
// (e.g. OpenRouter with reasoning: true).
|
||||
// (e.g. OpenRouter with reasoning: true). Skip model default when thinking is active
|
||||
// to avoid redundant Reasoning: output alongside internal thinking blocks.
|
||||
const hasAgentReasoningDefault =
|
||||
agentEntry?.reasoningDefault !== undefined && agentEntry?.reasoningDefault !== null;
|
||||
const reasoningExplicitlySet =
|
||||
directives.reasoningLevel !== undefined ||
|
||||
(sessionEntry?.reasoningLevel !== undefined && sessionEntry?.reasoningLevel !== null);
|
||||
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off") {
|
||||
(sessionEntry?.reasoningLevel !== undefined && sessionEntry?.reasoningLevel !== null) ||
|
||||
hasAgentReasoningDefault;
|
||||
const thinkingActive = resolvedThinkLevelWithDefault !== "off";
|
||||
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off" && !thinkingActive) {
|
||||
resolvedReasoningLevel = await modelState.resolveDefaultReasoningLevel();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user