fix(llm): strip cache_breakpoint marker on the litellm provider path#6188
fix(llm): strip cache_breakpoint marker on the litellm provider path#6188HumphreySun98 wants to merge 1 commit into
Conversation
The prompt-cache breakpoint marker is injected provider-agnostically by the agent executors, but only the native Anthropic adapter consumes it. Native providers route through BaseLLM._format_messages, which already strips the marker. The default litellm-based LLM does not: _format_messages_for_provider returned messages untouched for non-Anthropic providers, so the raw `cache_breakpoint` key reached the wire and was rejected (e.g. Groq: "property 'cache_breakpoint' is unsupported"). Strip the marker in _format_messages_for_provider, copying rather than mutating so the executor's reused message buffer keeps its markers across tool-loop iterations. Fixes crewAIInc#5886 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesStrip cache_breakpoint marker for non-Anthropic providers
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The prompt-cache breakpoint marker is injected provider-agnostically by the agent executors (
mark_cache_breakpoint), but only the native Anthropic adapter consumes it. Native providers route throughBaseLLM._format_messages, which already strips the marker. The default litellm-basedLLMdoes not:_format_messages_for_providerreturned messages untouched for non-Anthropic providers, so the rawcache_breakpointkey reached the wire and was rejected — e.g. Groq:This breaks any crew using Groq or other OpenAI-compatible models on the litellm path.
Fix
Strip the marker in
LLM._format_messages_for_provider, mirroring the base class. It copies rather than mutates, so the executor's reused message buffer keeps its markers across tool-loop iterations (preserving Anthropic prompt caching).Tests
Added
TestLiteLLMStripsMarkerintest_prompt_cache.pycovering the litellm path (the existing tests only exercised native providers). Verified the new tests fail without the fix and pass with it;ruffandmypyclean.Fixes #5886
This PR was authored with Claude Code. Per
CONTRIBUTING.md, AI-generated contributions require thellm-generatedlabel — I don't have triage permission to set it, so could a maintainer please add it? 🤖 Generated with Claude CodeSummary by CodeRabbit
Bug Fixes
Tests