fix: recognize Bedrock application inference profile ARNs for caching (#1705)#1895
Open
mango766 wants to merge 1 commit intostrands-agents:mainfrom
Open
fix: recognize Bedrock application inference profile ARNs for caching (#1705)#1895mango766 wants to merge 1 commit intostrands-agents:mainfrom
mango766 wants to merge 1 commit intostrands-agents:mainfrom
Conversation
`_cache_strategy` only checked for "claude" or "anthropic" in the model_id string. Application inference profile ARNs (e.g., arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/...) don't contain these substrings, so caching was silently disabled even when the user explicitly set cache_config. Now also returns "anthropic" strategy for Bedrock ARN-style model IDs, since only Anthropic models currently support prompt caching on Bedrock. Fixes strands-agents#1705
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
_cache_strategyto recognize Bedrock application inference profile ARNs, which don't contain "claude" or "anthropic" in the model ID string.Root cause
Application inference profile ARNs look like:
_cache_strategyonly checked"claude" in model_id or "anthropic" in model_id, which fails for these ARNs. This caused a warning on every API call and silently disabled caching even when the user explicitly setcache_config=CacheConfig(strategy="auto").Fix
Also return
"anthropic"strategy when the model_id is a Bedrock ARN (arn:...bedrock...), since only Anthropic models currently support prompt caching on Bedrock.Fixes #1705