Skip to content

fix(bedrock): detect region from AWS_DEFAULT_REGION and aws_profile arg#1553

Open
JiwaniZakir wants to merge 1 commit into
anthropics:mainfrom
JiwaniZakir:fix/issue-892
Open

fix(bedrock): detect region from AWS_DEFAULT_REGION and aws_profile arg#1553
JiwaniZakir wants to merge 1 commit into
anthropics:mainfrom
JiwaniZakir:fix/issue-892

Conversation

@JiwaniZakir
Copy link
Copy Markdown

The _infer_region function in src/anthropic/lib/bedrock/_client.py only checked AWS_REGION and ignored the standard AWS_DEFAULT_REGION environment variable, and did not pass the aws_profile argument to the boto3 session, so a non-default profile's region was never picked up. This PR adds AWS_DEFAULT_REGION as a fallback after AWS_REGION, updates _infer_region to accept and forward aws_profile to boto3.Session, and threads that argument through both AnthropicBedrock and AsyncAnthropicBedrock. Run pytest tests/lib/test_bedrock.py to verify the new test_region_infer_from_aws_default_region_env and test_region_infer_from_aws_profile_arg tests pass alongside the existing suite.

Fixes #892

_infer_region now checks AWS_DEFAULT_REGION in addition to AWS_REGION,
and accepts the aws_profile argument so the correct boto3 session is
used when a non-default profile is passed to AnthropicBedrock.
@JiwaniZakir JiwaniZakir requested a review from a team as a code owner May 16, 2026 13: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.

Bedrock client failing to detect AWS region correctly can cause cross-region inference to fail

1 participant