Skip to content

[BUG] CacheConfig(strategy="auto") does not detect Claude models when using ARN-based inference profiles #2233

@mrtj

Description

@mrtj

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:

  1. Resolve the ARN at init time via bedrock.get_inference_profile() to discover the underlying foundation model
  2. Try caching optimistically — non-cache-capable models ignore cachePoint blocks in the Converse API, so injecting them is harmless
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions