Python: fix(bedrock): merge per-call client kwargs into the Converse request by ManoharPaturi · Pull Request #9345 · microsoft/agent-framework · GitHub
Skip to content

Python: fix(bedrock): merge per-call client kwargs into the Converse request - #9345

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/bedrock-client-kwargs
Oct 15, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 2 commits into
microsoft:mainfrom
ManoharPaturi:fix/bedrock-client-kwargs

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Motivation & Context

BedrockChatClient._prepare_options accepted **kwargs but never used them, so per-call client kwargs passed through client_kwargs were silently dropped from the Converse request. guardrailConfig, requestMetadata and friends just vanished. Issue #9344 has the repro.

Description & Review Guide

  • What are the major changes? run_options.update(kwargs) at the end of _prepare_options, placed before the prompt-ARN cleanup so that branch still strips fields Converse rejects when they arrive through kwargs.
  • What is the impact of these changes? Bedrock-native per-call fields reach the request. Options passed the normal way are unaffected.
  • What do you want reviewers to focus on? The merge placement relative to the prompt-ARN branch, and the new test.

Related Issue

Fixes #9344

AI Assistance

  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

…request

_prepare_options accepted **kwargs but never used them, so anything
passed through client_kwargs (guardrailConfig, requestMetadata, ...)
was silently dropped. Merge them before the prompt-ARN cleanup so that
branch still strips fields Converse rejects, mirroring the other
clients.

Fixes microsoft#9344

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Prompt cleanup checks the model selected before client_kwargs can override modelId.

1 open finding
What changed in this PR

Fixes Bedrock per-call client_kwargs being dropped from Converse requests.

Changes:

  • Merges Bedrock-native kwargs into request options.
  • Adds regression coverage for guardrail and metadata kwargs.
File Description
_chat_client.py Merges per-call kwargs before prompt cleanup.
test_bedrock_client.py Tests forwarding Bedrock-native kwargs.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/bedrock/agent_framework_bedrock/_chat_client.py Outdated
Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Merged via the queue into microsoft:main with commit 0c1beb6 Oct 15, 2026
45 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — dcc604e2 Deployed Oct 13, 2026 by ManoharPaturi via add_label #25179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: BedrockChatClient silently drops per-call client kwargs

3 participants