Skip to content

Fix: Make Bedrock model IDs region-aware to support non-US regions#6

Merged
getOffIt merged 1 commit intomainfrom
fix/bedrock-model-id-region-aware
Dec 28, 2025
Merged

Fix: Make Bedrock model IDs region-aware to support non-US regions#6
getOffIt merged 1 commit intomainfrom
fix/bedrock-model-id-region-aware

Conversation

@getOffIt
Copy link
Copy Markdown
Owner

@getOffIt getOffIt commented Dec 28, 2025

Problem

When using Amazon Bedrock in non-US regions (e.g., eu-west-2), the system was failing with a ValidationException because model identifiers included a us. prefix that is only valid for US regions.

Error Example

ERROR: An error occurred (ValidationException) when calling the ConverseStream operation: 
The provided model identifier is invalid.
└ Bedrock region: eu-west-2
└ Model id: us.anthropic.claude-3-7-sonnet-20250219-v1:0

This caused:

  • 5 retry attempts to fail for the Tracker agent
  • System to fall back to alternative models/agents
  • Added ~30-60 seconds of retry attempts
  • Blocked proper multi-region support

Fixes #1

Solution

This PR implements region-aware model ID handling that automatically adjusts model identifiers based on the AWS region:

  1. Modified bedrock_info.get_model_id() to accept an optional region parameter
  2. Automatic prefix handling: For non-US regions, the us. prefix is automatically stripped from model IDs
  3. Backward compatible: If region is not provided, it reads from environment variables (AWS_REGION or AWS_DEFAULT_REGION)
  4. Updated all call sites to pass the region parameter:
    • llm_st.py: Updated all LLM type configurations
    • strands_sdk_utils.py: Updated model creation calls

How It Works

  • For non-US regions (e.g., eu-west-2, ap-southeast-1):

    • Model ID: us.anthropic.claude-3-7-sonnet-20250219-v1:0anthropic.claude-3-7-sonnet-20250219-v1:0
  • For US regions (e.g., us-east-1, us-west-2):

    • Model ID: us.anthropic.claude-3-7-sonnet-20250219-v1:0 (unchanged)

Changes Made

Files Modified

  • tech-recon/src/utils/bedrock.py: Added region-aware logic to get_model_id() method
  • tech-recon/src/agents/llm_st.py: Updated all get_model_id() calls to pass region
  • tech-recon/src/utils/strands_sdk_utils.py: Added region parameter to model ID calls

Code Changes

# Before
model_id = bedrock_info.get_model_id(model_name="Claude-V3-7-Sonnet-CRI")

# After  
region = os.environ.get("AWS_DEFAULT_REGION", None)
model_id = bedrock_info.get_model_id(model_name="Claude-V3-7-Sonnet-CRI", region=region)

Testing

  • ✅ No linting errors
  • ✅ Backward compatible (works without region parameter)
  • ✅ Automatically handles region from environment variables
  • ✅ Fixes the ValidationException for non-US regions

Impact

Reference

See ERROR_SUMMARY.md for full error details and context.

- Add region parameter to get_model_id() method in bedrock_info class
- Automatically strip 'us.' prefix for non-US regions (e.g., eu-west-2)
- Update all get_model_id() calls to pass region parameter
- Fixes ValidationException when using Bedrock in non-US regions

Resolves #1
@getOffIt getOffIt merged commit f872090 into main Dec 28, 2025
@getOffIt getOffIt deleted the fix/bedrock-model-id-region-aware branch December 28, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CRITICAL] Invalid Bedrock Model Identifier for non-US regions

2 participants