Skip to content

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

  1. Make sure BEDROCK_REGION is not set.
  2. Create a boto3 session for eu-west-1.
  3. Pass it to BedrockChatClient without region.
  4. 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.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 10, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Oct 10, 2026
  3. github-actions commented on Oct 10, 2026

    @github-actions
    Contributor

    🤖 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 uses us-east-1 when given a region-configured boto3 session without an explicit region or BEDROCK_REGION. This affects the runtime client region, client.region, and service_url(). Minimal repro: provide a fake boto3 session with region_name="eu-west-1", construct the chat client without region, and assert the region passed to session.client().

    • Failing test: python/packages/bedrock/tests/test_bedrock_client.py::test_init_uses_region_from_provided_boto3_session
    • Files examined: python/packages/bedrock/agent_framework_bedrock/_chat_client.py, python/packages/bedrock/agent_framework_bedrock/_embedding_client.py, python/packages/bedrock/tests/test_bedrock_client.py, python/packages/bedrock/pyproject.toml
    • Tests run: test_init_uses_region_from_provided_boto3_session, test_init_uses_boto3_session_when_runtime_client_not_supplied
    • Reported version: 1.0.0b261008
    • Current version: 1.0.0b261008
  4. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions