Fix: Make Bedrock model IDs region-aware to support non-US regions#6
Merged
Fix: Make Bedrock model IDs region-aware to support non-US regions#6
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using Amazon Bedrock in non-US regions (e.g.,
eu-west-2), the system was failing with aValidationExceptionbecause model identifiers included aus.prefix that is only valid for US regions.Error Example
This caused:
Fixes #1
Solution
This PR implements region-aware model ID handling that automatically adjusts model identifiers based on the AWS region:
bedrock_info.get_model_id()to accept an optionalregionparameterus.prefix is automatically stripped from model IDsAWS_REGIONorAWS_DEFAULT_REGION)llm_st.py: Updated all LLM type configurationsstrands_sdk_utils.py: Updated model creation callsHow It Works
For non-US regions (e.g.,
eu-west-2,ap-southeast-1):us.anthropic.claude-3-7-sonnet-20250219-v1:0→anthropic.claude-3-7-sonnet-20250219-v1:0For US regions (e.g.,
us-east-1,us-west-2):us.anthropic.claude-3-7-sonnet-20250219-v1:0(unchanged)Changes Made
Files Modified
tech-recon/src/utils/bedrock.py: Added region-aware logic toget_model_id()methodtech-recon/src/agents/llm_st.py: Updated allget_model_id()calls to pass regiontech-recon/src/utils/strands_sdk_utils.py: Added region parameter to model ID callsCode Changes
Testing
Impact
Reference
See
ERROR_SUMMARY.mdfor full error details and context.