fix(ai): explicitly disable Anthropic thinking when off closes #2022

This commit is contained in:
Mario Zechner
2026-03-22 19:38:54 +01:00
parent 74073e5227
commit 6129971c04
3 changed files with 146 additions and 13 deletions

View File

@@ -654,20 +654,25 @@ function buildParams(
params.tools = convertTools(context.tools, isOAuthToken);
}
// Configure thinking mode: adaptive (Opus 4.6 and Sonnet 4.6) or budget-based (older models)
if (options?.thinkingEnabled && model.reasoning) {
if (supportsAdaptiveThinking(model.id)) {
// Adaptive thinking: Claude decides when and how much to think
params.thinking = { type: "adaptive" };
if (options.effort) {
params.output_config = { effort: options.effort };
// Configure thinking mode: adaptive (Opus 4.6 and Sonnet 4.6),
// budget-based (older models), or explicitly disabled.
if (model.reasoning) {
if (options?.thinkingEnabled) {
if (supportsAdaptiveThinking(model.id)) {
// Adaptive thinking: Claude decides when and how much to think
params.thinking = { type: "adaptive" };
if (options.effort) {
params.output_config = { effort: options.effort };
}
} else {
// Budget-based thinking for older models
params.thinking = {
type: "enabled",
budget_tokens: options.thinkingBudgetTokens || 1024,
};
}
} else {
// Budget-based thinking for older models
params.thinking = {
type: "enabled",
budget_tokens: options.thinkingBudgetTokens || 1024,
};
} else if (options?.thinkingEnabled === false) {
params.thinking = { type: "disabled" };
}
}