From 6c26461cd4bd78eeb90b8deafa331d880ecc0207 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 14 May 2026 12:46:27 +0000 Subject: [PATCH] fix: prevent date-stamped model names from false no-prefill detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The regex now limits the minor version capture to 1-2 digits so names like claude-opus-4-20250514 are not misclassified as 4.20250514. Added tests for date-stamped and Bedrock-style model IDs. Co-Authored-By: João --- lib/crewai/src/crewai/llm.py | 2 +- .../src/crewai/llms/providers/anthropic/completion.py | 2 +- .../tests/agents/test_claude_opus_4_7_support.py | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/crewai/src/crewai/llm.py b/lib/crewai/src/crewai/llm.py index c18c08025..18a96c136 100644 --- a/lib/crewai/src/crewai/llm.py +++ b/lib/crewai/src/crewai/llm.py @@ -2295,7 +2295,7 @@ class LLM(BaseLLM): # Fallback heuristic for model names not in the litellm registry model_lower = (self.model or "").lower() if "claude" in model_lower: - match = re.search(r"claude.*?(\d+)[.-](\d+)", model_lower) + match = re.search(r"claude.*?(\d+)[.-](\d{1,2})(?!\d)", model_lower) if match: major, minor = int(match.group(1)), int(match.group(2)) if (major == 4 and minor >= 6) or major >= 5: diff --git a/lib/crewai/src/crewai/llms/providers/anthropic/completion.py b/lib/crewai/src/crewai/llms/providers/anthropic/completion.py index 986e90a4c..cbd95df69 100644 --- a/lib/crewai/src/crewai/llms/providers/anthropic/completion.py +++ b/lib/crewai/src/crewai/llms/providers/anthropic/completion.py @@ -1838,7 +1838,7 @@ class AnthropicCompletion(BaseLLM): assistant prefill. """ model_lower = self.model.lower() - match = re.search(r"claude.*?(\d+)[.-](\d+)", model_lower) + match = re.search(r"claude.*?(\d+)[.-](\d{1,2})(?!\d)", model_lower) if match: major, minor = int(match.group(1)), int(match.group(2)) if (major == 4 and minor >= 6) or major >= 5: diff --git a/lib/crewai/tests/agents/test_claude_opus_4_7_support.py b/lib/crewai/tests/agents/test_claude_opus_4_7_support.py index c2d67f23a..6068d49db 100644 --- a/lib/crewai/tests/agents/test_claude_opus_4_7_support.py +++ b/lib/crewai/tests/agents/test_claude_opus_4_7_support.py @@ -73,6 +73,17 @@ class TestAnthropicPrefillDetection: llm = self._make_anthropic_llm("claude-5-0-opus") assert llm.supports_assistant_prefill() is False + def test_date_stamped_claude_4_not_falsely_flagged(self): + """claude-opus-4-20250514 should NOT be treated as 4.20250514.""" + llm = self._make_anthropic_llm("claude-opus-4-20250514") + assert llm.supports_assistant_prefill() is True + + def test_bedrock_date_stamped_model(self): + """Bedrock-style IDs like claude-opus-4-20250514-v1:0 must not + be misclassified.""" + llm = self._make_anthropic_llm("claude-opus-4-20250514-v1:0") + assert llm.supports_assistant_prefill() is True + # --------------------------------------------------------------------------- # AnthropicCompletion temperature dropping