Skip to content

fix: recognize Bedrock application inference profile ARNs for caching (#1705)#1895

Open
mango766 wants to merge 1 commit intostrands-agents:mainfrom
mango766:fix/cache-strategy-bedrock-arn
Open

fix: recognize Bedrock application inference profile ARNs for caching (#1705)#1895
mango766 wants to merge 1 commit intostrands-agents:mainfrom
mango766:fix/cache-strategy-bedrock-arn

Conversation

@mango766
Copy link

Summary

Fix _cache_strategy to 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:

arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123

_cache_strategy only 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 set cache_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

`_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] _supports_caching doesn't recognize Bedrock application inference profile ARNs

1 participant