Commits
Click on a commit to change the comparison rangefix(anthropic): clean up cache_control in middleware to prevent fallback errors
Fixes issue where AnthropicPromptCachingMiddleware's cache_control parameter
persisted in model_settings when ModelFallbackMiddleware switched to non-Anthropic
models (OpenAI, Google), causing TypeError.
The fix uses try/finally blocks to ensure cache_control is always removed from
model_settings after handler execution, regardless of success or failure. This
prevents the Anthropic-specific parameter from being passed to fallback models.
Changes:
- Added cleanup logic in wrap_model_call() and awrap_model_call()
- Updated existing tests to verify cleanup behavior
- Added comprehensive tests for both success and error cases
Fixes #3370922 hours ago
by yashwantbezawada