From ed523c6e89543bf5666d932a369a2565b9519137 Mon Sep 17 00:00:00 2001 From: easonysliu Date: Fri, 13 Mar 2026 11:13:52 +0800 Subject: [PATCH] fix: recognize Bedrock application inference profile ARNs for caching `_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 #1705 --- src/strands/models/bedrock.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/strands/models/bedrock.py b/src/strands/models/bedrock.py index bab4031ed..f25c1e90b 100644 --- a/src/strands/models/bedrock.py +++ b/src/strands/models/bedrock.py @@ -186,6 +186,11 @@ def _cache_strategy(self) -> str | None: model_id = self.config.get("model_id", "").lower() if "claude" in model_id or "anthropic" in model_id: return "anthropic" + # Application inference profile ARNs don't contain model names. + # When the user explicitly enables caching via cache_config, assume Anthropic + # strategy for Bedrock ARNs since only Anthropic models currently support it. + if model_id.startswith("arn:") and "bedrock" in model_id: + return "anthropic" return None @override