diff --git a/lib/crewai/src/crewai/llm.py b/lib/crewai/src/crewai/llm.py index b0b5cd3a19..7c023e5e61 100644 --- a/lib/crewai/src/crewai/llm.py +++ b/lib/crewai/src/crewai/llm.py @@ -535,7 +535,8 @@ def _matches_provider_pattern(cls, model: str, provider: str) -> bool: if provider == "anthropic" or provider == "claude": return any( - model_lower.startswith(prefix) for prefix in ["claude-", "anthropic."] + model_lower.startswith(prefix) + for prefix in ["claude-", "anthropic.", "anthropic--"] ) if provider == "gemini" or provider == "google": @@ -2326,6 +2327,16 @@ def _format_messages_for_provider( "Invalid message format. Each message must be a dict with 'role' and 'content' keys" ) + # Strip cache-breakpoint flags before sending to LiteLLM. + # Native providers already handle this via BaseLLM._format_messages, + # but the LiteLLM fallback path uses this method directly. + from crewai.llms.cache import strip_cache_breakpoint + + messages = [dict(msg) for msg in messages] + for msg in messages: + strip_cache_breakpoint(msg) + + # Handle O1 models specially if "o1" in self.model.lower(): formatted_messages = [] for msg in messages: