fix(agents): preserve thinking fallback with model defaults

This commit is contained in:
Peter Steinberger
2026-03-02 03:58:10 +00:00
parent 28d0576fd1
commit 051fba6995
2 changed files with 14 additions and 5 deletions

View File

@@ -492,7 +492,14 @@ describe("model-selection", () => {
cfg,
provider: "anthropic",
model: "claude-opus-4-6",
catalog: [{ provider: "anthropic", id: "claude-opus-4-6", reasoning: true }],
catalog: [
{
provider: "anthropic",
id: "claude-opus-4-6",
name: "Claude Opus 4.6",
reasoning: true,
},
],
}),
).toBe("high");
});

View File

@@ -388,6 +388,10 @@ export async function resolveReplyDirectives(params: {
});
provider = modelState.provider;
model = modelState.model;
const resolvedThinkLevelWithDefault =
resolvedThinkLevel ??
(await modelState.resolveDefaultThinkingLevel()) ??
(agentCfg?.thinkingDefault as ThinkLevel | undefined);
// When neither directive nor session set reasoning, default to model capability
// (e.g. OpenRouter with reasoning: true). Skip auto-enabling when thinking is
@@ -396,9 +400,7 @@ export async function resolveReplyDirectives(params: {
const reasoningExplicitlySet =
directives.reasoningLevel !== undefined ||
(sessionEntry?.reasoningLevel !== undefined && sessionEntry?.reasoningLevel !== null);
const effectiveThinkingForReasoning =
resolvedThinkLevel ?? (await modelState.resolveDefaultThinkingLevel());
const thinkingActive = effectiveThinkingForReasoning !== "off";
const thinkingActive = resolvedThinkLevelWithDefault !== "off";
if (!reasoningExplicitlySet && resolvedReasoningLevel === "off" && !thinkingActive) {
resolvedReasoningLevel = await modelState.resolveDefaultReasoningLevel();
}
@@ -475,7 +477,7 @@ export async function resolveReplyDirectives(params: {
elevatedAllowed,
elevatedFailures,
defaultActivation,
resolvedThinkLevel,
resolvedThinkLevel: resolvedThinkLevelWithDefault,
resolvedVerboseLevel,
resolvedReasoningLevel,
resolvedElevatedLevel,