Send adaptive low-effort thinking for Opus 5.5 when reasoning is off

Opus 5.5 returns 400 on thinking {type:"disabled"}, and its ID matched the
"claude-opus-5" marker, so it inherited Opus 5's explicit disabled config.
This commit is contained in:
sausheong committed 2026-09-23 19:18:37 +08:00
1 parent 9a013f6f4b
commit a1f34cce4c
2 files changed
+38

No files matched your search

+17
View File
@@ -160,6 +160,16 @@ func (p *AnthropicProvider) buildMessageParams(req llm.ChatRequest) anthropic.Me
slog.Info("anthropic adaptive thinking",
"model", model,
"effort", string(anthropicEffort(req.Reasoning)))
} else if anthropicRejectsDisabledThinking(model) {
// Opus 5.5 can't turn thinking off: {type:"disabled"} is a 400
// ("use thinking.type.adaptive and output_config.effort").
// Adaptive at low effort is the closest accepted "off".
params.Thinking = anthropic.ThinkingConfigParamUnion{
OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
}
params.OutputConfig = anthropic.OutputConfigParam{
Effort: anthropic.OutputConfigEffortLow,
}
} else if anthropicThinksByDefault(model) {
// Opus 5 and Sonnet 5 think by default when the thinking
// param is omitted entirely (unlike Opus 4.7/4.8, Fable 5,
@@ -557,6 +567,13 @@ func anthropicThinksByDefault(model string) bool {
return false
}
// anthropicRejectsDisabledThinking reports whether the model returns a 400
// for thinking {type:"disabled"}. Checked before anthropicThinksByDefault,
// whose "claude-opus-5" marker also matches Opus 5.5 IDs.
func anthropicRejectsDisabledThinking(model string) bool {
return strings.Contains(model, "claude-opus-5-5")
}
// anthropicEffort maps the unified ReasoningMode onto output_config.effort
// for adaptive-thinking-only models.
func anthropicEffort(mode llm.ReasoningMode) anthropic.OutputConfigEffort {