Description
CacheConfig(strategy="auto") fails to activate prompt caching when the model_id is an ARN-based application inference profile (e.g., arn:aws:bedrock:us-east-1:123456:application-inference-profile/abc123).
Root cause
The _cache_strategy property in BedrockModel checks for "claude" or "anthropic" substrings in the model ID:
# strands/models/bedrock.py, line ~192
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"
return None
ARN-based inference profiles contain neither substring — they look like arn:aws:bedrock:us-east-1:123456:application-inference-profile/2i76zr9zafkf. So auto resolves to None and caching is silently skipped.
Reproduction
from strands.models.bedrock import BedrockModel
from strands.models.model import CacheConfig
model = BedrockModel(
model_id="arn:aws:bedrock:us-east-1:123456:application-inference-profile/abc123",
cache_config=CacheConfig(strategy="auto"),
)
# _cache_strategy returns None → caching silently disabled
# cacheReadInputTokens and cacheWriteInputTokens will always be 0
Expected behavior
auto should detect Claude models behind ARN inference profiles and enable caching. Possible approaches:
- Resolve the ARN at init time via
bedrock.get_inference_profile() to discover the underlying foundation model
- Try caching optimistically — non-cache-capable models ignore
cachePoint blocks in the Converse API, so injecting them is harmless
- Check the response for
cacheWriteInputTokens > 0 on the first call to confirm support
Workaround
Use CacheConfig(strategy="anthropic") instead of "auto" to force-enable caching regardless of model ID detection:
model = BedrockModel(
model_id="arn:aws:bedrock:us-east-1:123456:application-inference-profile/abc123",
cache_config=CacheConfig(strategy="anthropic"),
)
Environment
- strands-agents 1.37.0
- Python 3.12
- AWS Bedrock with application inference profiles for Claude Sonnet 4.6
Description
CacheConfig(strategy="auto")fails to activate prompt caching when themodel_idis an ARN-based application inference profile (e.g.,arn:aws:bedrock:us-east-1:123456:application-inference-profile/abc123).Root cause
The
_cache_strategyproperty inBedrockModelchecks for"claude"or"anthropic"substrings in the model ID:ARN-based inference profiles contain neither substring — they look like
arn:aws:bedrock:us-east-1:123456:application-inference-profile/2i76zr9zafkf. Soautoresolves toNoneand caching is silently skipped.Reproduction
Expected behavior
autoshould detect Claude models behind ARN inference profiles and enable caching. Possible approaches:bedrock.get_inference_profile()to discover the underlying foundation modelcachePointblocks in the Converse API, so injecting them is harmlesscacheWriteInputTokens > 0on the first call to confirm supportWorkaround
Use
CacheConfig(strategy="anthropic")instead of"auto"to force-enable caching regardless of model ID detection:Environment