From d4c1815401faaab927cb6de64c51f18f274f1eca Mon Sep 17 00:00:00 2001 From: Chenglun Hu Date: Wed, 10 Jun 2026 17:28:54 +0800 Subject: [PATCH] fix(anthropic): drop hardcoded _is_claude_4_8_model helper per project convention greptile flagged the new hardcoded name helper as a discouraged pattern. the suffix-strip fix in _model_map_lookup_candidates already covers the primary path: with the bare claude-opus-4-8 entry resolved, the supports_adaptive_thinking flag is found and the name fallback isn't reached. dropping the helper and its targeted test; the suffix-strip regression coverage stays. --- litellm/llms/anthropic/common_utils.py | 22 +++---------------- .../anthropic/test_anthropic_common_utils.py | 14 ------------ 2 files changed, 3 insertions(+), 33 deletions(-) diff --git a/litellm/llms/anthropic/common_utils.py b/litellm/llms/anthropic/common_utils.py index 46b36c3b846..e7ffe324cc0 100644 --- a/litellm/llms/anthropic/common_utils.py +++ b/litellm/llms/anthropic/common_utils.py @@ -272,20 +272,6 @@ class AnthropicModelInfo(BaseLLMModelInfo): ) ) - @staticmethod - def _is_claude_4_8_model(model: str) -> bool: - """Check if the model is a Claude 4.8 model (Opus 4.8).""" - model_lower = model.lower() - return any( - v in model_lower - for v in ( - "opus-4-8", - "opus_4_8", - "opus-4.8", - "opus_4.8", - ) - ) - @staticmethod def _supports_sampling_params(model: str) -> bool: """Claude 4.7+ (Opus 4.7/4.8, Fable 5) removed sampling params: the API @@ -425,11 +411,9 @@ class AnthropicModelInfo(BaseLLMModelInfo): model, "supports_adaptive_thinking" ): return True - return ( - AnthropicModelInfo._is_claude_4_6_model(model) - or AnthropicModelInfo._is_claude_4_7_model(model) - or AnthropicModelInfo._is_claude_4_8_model(model) - ) + return AnthropicModelInfo._is_claude_4_6_model( + model + ) or AnthropicModelInfo._is_claude_4_7_model(model) def is_effort_used( self, optional_params: Optional[dict], model: Optional[str] = None diff --git a/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py b/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py index 32b4791e062..382b42fc751 100644 --- a/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py +++ b/tests/test_litellm/llms/anthropic/test_anthropic_common_utils.py @@ -1506,17 +1506,3 @@ class TestVertexVersionSuffixModelResolution: ) is True ) - - def test_is_claude_4_8_model_recognizes_suffix_and_provider_prefix(self): - from litellm.llms.anthropic.common_utils import AnthropicModelInfo - - assert AnthropicModelInfo._is_claude_4_8_model("claude-opus-4-8") is True - assert ( - AnthropicModelInfo._is_claude_4_8_model("claude-opus-4-8@default") is True - ) - assert ( - AnthropicModelInfo._is_claude_4_8_model("vertex_ai/claude-opus-4-8@default") - is True - ) - assert AnthropicModelInfo._is_claude_4_8_model("claude-opus-4-7") is False - assert AnthropicModelInfo._is_claude_4_8_model("claude-opus-4-5") is False