Repository navigation
Python: [Bug]: BedrockChatClient ignores the region of a provided boto3_session and sends requests to us-east-1 #9248
Description
Observed Behavior
When BedrockChatClient is created with boto3_session and no region (and BEDROCK_REGION is not set), it always builds the Bedrock runtime client in us-east-1. The region of the session is ignored, whether it was set directly, through an AWS profile, or through AWS_DEFAULT_REGION.
So requests go to a different region than the one the session is configured for. The model may not be available there, the account may not have access there, or data leaves the intended region. client.region and service_url() (used for the telemetry server.address) also report us-east-1.
BedrockEmbeddingClient in the same package uses the session's region, so the two clients behave differently with the same session.
Expected Behavior
When no region is configured (region argument or BEDROCK_REGION), BedrockChatClient should use the region of the provided boto3_session, like BedrockEmbeddingClient does. An explicitly configured region should still take precedence.
Steps to Reproduce
- Make sure
BEDROCK_REGIONis not set. - Create a boto3 session for
eu-west-1. - Pass it to
BedrockChatClientwithoutregion. - Check the region of the runtime client that requests are sent through.
Minimal Reproduction
from boto3.session import Session
from agent_framework_bedrock import BedrockChatClient, BedrockEmbeddingClient
session = Session(region_name="eu-west-1")
chat = BedrockChatClient(model="<model id>", boto3_session=session)
embeddings = BedrockEmbeddingClient(model="<embedding model id>", boto3_session=session)
print(chat._bedrock_client.meta.region_name) # us-east-1 (expected eu-west-1)
print(chat.region) # us-east-1 (expected eu-west-1)
print(chat.service_url()) # https://bedrock-runtime.us-east-1.amazonaws.com
print(embeddings._bedrock_client.meta.region_name) # eu-west-1No AWS call is needed to see it; boto3 builds the client offline.
The cause is in agent_framework_bedrock/_chat_client.py: region = settings.get("region") or DEFAULT_REGION is passed to session.client("bedrock-runtime", region_name=region, ...), even when the session comes from the caller.
Error Messages and Stack Traces
No error at construction. Requests then fail or succeed in the wrong region, depending on model availability and account access there.
Package Versions
agent-framework-bedrock: 1.0.0b261008 (main at fd52de7), agent-framework-core: 1.21.0, boto3: 1.43.107
Python Version
Python 3.12
Additional Context
I'd like to fix this. The change is two lines in BedrockChatClient.__init__ (fall back to boto3_session.region_name before us-east-1) plus regression tests.
AI assistance: I used an AI coding assistant for the analysis and to draft this report. I reproduced and verified the behavior myself.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
github-actions commentedon Oct 10, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
Repro:
python/packages/bedrock/agent_framework_bedrock/_chat_client.py::BedrockChatClient.__init__lines 321-340 usesus-east-1when given a region-configured boto3 session without an explicit region orBEDROCK_REGION. This affects the runtime client region,client.region, andservice_url(). Minimal repro: provide a fake boto3 session withregion_name="eu-west-1", construct the chat client withoutregion, and assert the region passed tosession.client().python/packages/bedrock/tests/test_bedrock_client.py::test_init_uses_region_from_provided_boto3_session1.0.0b2610081.0.0b261008