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_REGION is not set.
- Create a boto3 session for
eu-west-1.
- Pass it to
BedrockChatClient without region.
- 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-1
No 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.
Observed Behavior
When
BedrockChatClientis created withboto3_sessionand noregion(andBEDROCK_REGIONis not set), it always builds the Bedrock runtime client inus-east-1. The region of the session is ignored, whether it was set directly, through an AWS profile, or throughAWS_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.regionandservice_url()(used for the telemetryserver.address) also reportus-east-1.BedrockEmbeddingClientin 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 (
regionargument orBEDROCK_REGION),BedrockChatClientshould use the region of the providedboto3_session, likeBedrockEmbeddingClientdoes. An explicitly configured region should still take precedence.Steps to Reproduce
BEDROCK_REGIONis not set.eu-west-1.BedrockChatClientwithoutregion.Minimal Reproduction
No 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_REGIONis passed tosession.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 toboto3_session.region_namebeforeus-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.