Skip to content

Python: Fix Bedrock parallel tool result handling. - #9796

Open
Patel Namraa (Namraa310806) wants to merge 1 commit into
microsoft:mainfrom
Namraa310806:fix/bedrock-parallel-tool-results
Open

Patel Namraa (Namraa310806) wants to merge 1 commit into
microsoft:mainfrom
Namraa310806:fix/bedrock-parallel-tool-results

Conversation

@Namraa310806

Copy link
Copy Markdown
Contributor

Motivation & Context

When multiple tool calls are issued in parallel, their results may arrive as separate consecutive tool messages. The Bedrock message preparation logic could silently drop some of these results.

For example, if an assistant issues two parallel tool calls (c1 and c2) and their results arrive in separate messages, processing the first result cleared the pending tool-use IDs. As a result, the second result could no longer be matched and was discarded.

This causes the Bedrock request to contain an incomplete set of tool results even though all results were provided by the framework.

Description & Review Guide

  • What are the major changes?

    • Preserve pending tool-use IDs across consecutive tool messages.
    • Consume only the tool-use ID corresponding to each processed tool result.
    • Merge consecutive tool-result messages into a single Bedrock user message.
    • Continue filtering duplicate and unknown tool-result IDs.
    • Add regression tests covering parallel and edge-case tool-result handling.
  • What is the impact of these changes?

    • Prevents valid parallel tool results from being silently dropped.
    • Preserves existing behavior for single tool calls and tool results already grouped in one message.
    • Keeps duplicate and unknown tool results from being included.
    • The change is limited to Bedrock message conversion and does not change the public tool-calling API.
  • What do you want reviewers to focus on?

    • Correct tracking of pending tool-use IDs across consecutive tool messages.
    • Correct merging of separate tool-result messages.
    • Preservation of duplicate and unknown tool-result filtering.
    • Regression-test coverage for parallel, incomplete, and edge-case tool-result scenarios.

Related Issue

Fixes #9794

AI Assistance

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

AI assistance details:

AI assistance was used to help report and explain the bug clearly, polish the issue and PR descriptions, and assist with implementation and test development. I reviewed and verified the submitted changes and take responsibility for them.

Contribution Checklist

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 28, 2026
@github-actions github-actions Bot changed the title Fix Bedrock parallel tool result handling. Python: Fix Bedrock parallel tool result handling. Oct 28, 2026
@eavanvalkenburg

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: No findings
Scope: full PR (1 commit(s)): beb7d2916d36
Model: gpt-5.6-sol

Overview

The change keeps pending Bedrock tool-use IDs across consecutive tool messages, consumes each accepted result once, and merges those results into one Bedrock user turn. Request-local state, explicit ID matching, duplicate and unknown-result filtering, and focused regression coverage protect the pairing behavior. No publishable Critical, High, or Medium defect was established.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

This branch was previously deployed

1 inactive deployment
github-app-auth — beb7d291 Deployed Oct 28, 2026 by Namraa310806 via team_check #7868
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 parallel tool results when results arrive as separate tool messages

3 participants