From a1ce7d9dac316c5ffe752b468c7a5cd7507e1eb8 Mon Sep 17 00:00:00 2001 From: PRABHU KIRAN VANDRANKI <72809214+VANDRANKI@users.noreply.github.com> Date: Tue, 5 May 2026 16:16:42 -0400 Subject: [PATCH] fix(anthropic): cap budget->effort at "high" when model lacks "xhigh" support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _translate_legacy_thinking_for_adaptive_model mapped budget_tokens >= 24000 to "xhigh" for all adaptive-thinking models. claude-opus-4-6 and claude-sonnet-4-6 support high/medium/low/max but not xhigh, so those requests failed with "This model does not support effort level 'xhigh'". Only claude-opus-4-7 (and later models) expose xhigh. Use AnthropicConfig._supports_effort_level(model, "xhigh") — the same per-model lookup already used by _validate_effort_for_model — to decide the cap. Fall back to "high" when xhigh is absent from the model map. Fixes #27168 --- .../messages/transformation.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py index 7617ad52ab1..e388c3d3ad7 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/transformation.py @@ -179,9 +179,17 @@ class AnthropicMessagesConfig(BaseAnthropicMessagesConfig): if not isinstance(thinking, dict) or thinking.get("type") != "enabled": return + from litellm.llms.anthropic.chat.transformation import AnthropicConfig + budget = int(thinking.get("budget_tokens") or 0) if budget >= 24000: - effort = "xhigh" + # Only use "xhigh" when the model actually supports it (e.g. claude-opus-4-7). + # claude-opus-4-6 and claude-sonnet-4-6 support high/medium/low/max but not xhigh. + effort = ( + "xhigh" + if AnthropicConfig._supports_effort_level(model, "xhigh") + else "high" + ) elif budget >= 10000: effort = "high" elif budget >= 5000: