Skip to content

fix: support Bedrock application inference profile ARNs in cache detection#1788

Open
giulio-leone wants to merge 1 commit intostrands-agents:mainfrom
giulio-leone:fix/bedrock-arn-caching-support
Open

fix: support Bedrock application inference profile ARNs in cache detection#1788
giulio-leone wants to merge 1 commit intostrands-agents:mainfrom
giulio-leone:fix/bedrock-arn-caching-support

Conversation

@giulio-leone
Copy link

Problem

_supports_caching only checks for 'claude' or 'anthropic' in the model_id string. This works for system inference profile IDs (e.g., us.anthropic.claude-haiku-4-5-20251001-v1:0) but fails for application inference profile ARNs which contain opaque profile IDs without model names:

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

As a result, users get a warning on every API call and prompt caching is silently disabled, even when the underlying model is Claude.

Solution

  • Detect application inference profile ARNs and resolve the underlying foundation model via the Bedrock control-plane GetInferenceProfile API
  • Cache the resolution result to avoid repeated API calls
  • Invalidate cache when model_id changes via update_config()
  • Preserve original ARN casing for API calls (ARNs are case-sensitive)
  • Handle API errors gracefully — if resolution fails, caching is disabled with a debug log

Tests

Added 7 new tests covering:

  • ARN resolution to Claude model → caching enabled
  • ARN resolution to non-Claude model → caching disabled
  • API failure (ClientError) → graceful fallback
  • Result caching (no repeated API calls)
  • Cache invalidation on model_id change
  • Original ARN casing preserved for API calls
  • Empty models list response

All 128 existing tests continue to pass.

Fixes #1705

…ction

_supports_caching only checked for 'claude'/'anthropic' in the model_id
string, which fails for application inference profile ARNs since they
contain opaque profile IDs without model names.

Changes:
- Resolve application inference profile ARNs via the Bedrock control-plane
  GetInferenceProfile API to discover the underlying foundation model
- Cache the resolution result to avoid repeated API calls
- Invalidate cache when model_id changes via update_config()
- Preserve original ARN casing for API calls (ARNs are case-sensitive)
- Handle API errors gracefully with broad exception catching

Fixes strands-agents#1705

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@giulio-leone
Copy link
Author

All 5 CI checks pass. Fixes Bedrock inference profile ARN support. Ready for review.

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