Repository navigation
Description
Observed Behavior
BedrockChatClient silently drops valid tool results when an assistant turn contains multiple parallel tool calls and the corresponding results are represented as separate tool messages.
The issue occurs in _prepare_bedrock_messages() in:
python/packages/bedrock/agent_framework_bedrock/_chat_client.py
When an assistant turn contains two parallel tool calls (c1 and c2) and their results arrive as two separate tool messages, the first result is preserved but the second result is silently dropped.
In my reproduction, the generated Bedrock request contains:
toolUseIDs:['c1', 'c2']toolResultIDs:['c1']
The toolResult for c2 is missing.
This happens because the pending tool-use IDs are cleared after processing the first tool message. The next tool message therefore has no pending ID to match against and its valid result is discarded.
This can leave the generated Bedrock Converse request with a toolUse for c2 without its corresponding toolResult.
Expected Behavior
All valid tool results for the parallel tool calls should be preserved.
When the conversation contains:
assistant:
toolUse: c1
toolUse: c2
tool:
toolResult: c1
tool:
toolResult: c2
the Bedrock adapter should generate a single following user message containing both results:
user:
toolResult: c1
toolResult: c2
The adapter should continue tracking unanswered tool-use IDs across consecutive tool messages and merge their results into the Bedrock user message.
Existing behavior for duplicate and unknown tool IDs should remain unchanged; those results should continue to be dropped.
Steps to Reproduce
- Create an assistant turn containing two parallel tool calls with IDs
c1andc2. - Represent the tool results as two separate
toolmessages:- first message contains the result for
c1 - second message contains the result for
c2
- first message contains the result for
- Pass the conversation through
BedrockChatClient/_prepare_bedrock_messages(). - Inspect the generated Bedrock Converse messages.
- Observe that the generated request contains
toolUseIDs['c1', 'c2']but onlytoolResultID['c1']. - The result for
c2has been silently discarded.
Minimal Reproduction
The issue can be reproduced with the Agent Framework repository and does not require a live Bedrock connection.
The minimal conversation is:
assistant:
toolUse: c1
toolUse: c2
tool:
toolResult: c1
tool:
toolResult: c2
Passing this conversation through the Bedrock message conversion produces:
toolUse IDs: ['c1', 'c2']
toolResult IDs: ['c1']
The toolResult for c2 is silently dropped.
I also reproduced this through the AG-UI conversion path, where AG-UI represents each tool result as a separate tool message.
The relevant implementation is:
python/packages/bedrock/agent_framework_bedrock/_chat_client.py
Specifically _prepare_bedrock_messages().
I have a local patch that fixes the behavior and two regression tests covering the parallel-result case and duplicate/unknown tool IDs.
Error Messages and Stack Traces
No Python exception is raised by the local message conversion itself.
The problem is that the generated Bedrock request is incomplete: it contains a `toolUse` for `c2` without a corresponding `toolResult`.
In the local reproduction:
toolUse IDs: ['c1', 'c2']
toolResult IDs: ['c1']
I did not have access to a live Amazon Bedrock endpoint for this reproduction, so I have not included a claimed live Bedrock stack trace.
The expected failure is based on the Bedrock Converse tool-use contract requiring the corresponding `toolResult` for each `toolUse`.
Package Versions
Microsoft Agent Framework Core Version: 1.23.0
Python Version
Python 3.13.15
Operating System
Windows
Regression
Yes
Additional Context
The issue is particularly relevant to AG-UI because AG-UI can represent parallel tool results as separate tool messages.
I reproduced the complete local conversion path:
AG-UI messages
-> agui_messages_to_agent_framework()
-> Bedrock message conversion
For a parallel tool call with IDs c1 and c2, the converted Bedrock request contained:
toolUse IDs: ['c1', 'c2']
toolResult IDs: ['c1']
The second valid tool result was silently dropped.
The root cause appears to be that _prepare_bedrock_messages() clears the pending tool-use IDs after processing a tool message. Therefore, when the next tool message contains the result for another outstanding parallel call, there is no pending ID left to match it.
The proposed fix keeps unanswered tool-use IDs across consecutive tool messages and combines their results into the single Bedrock user message required for the tool-result turn.
I added two regression tests:
- Separate tool messages for parallel tool calls are merged correctly.
- Duplicate and unknown tool IDs continue to be dropped.
With the proposed fix, the full Bedrock test suite passes: 61 tests.
I have not yet run the project's full lint or type-check suite.
I searched existing Agent Framework issues for Bedrock toolResult, toolUse, parallel tool calls, toolUseId, and dropped tool results and did not find an existing issue covering this specific failure.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
Namraa310806 commentedon Oct 28, 2026
working on it.
github-actions commentedon Oct 28, 2026
🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
The defect is in
python/packages/bedrock/agent_framework_bedrock/_chat_client.py::BedrockChatClient._prepare_bedrock_messages, especially line 557, where pending tool-use IDs are cleared after every tool message. It triggers when parallel calls receive results in consecutive tool messages. Minimal repro: pass one assistant message containing callsc1andc2, followed by separate tool-result messages for each, and assert both results appear in the converted Bedrock user message.python/packages/bedrock/tests/test_bedrock_client.py::test_prepare_bedrock_messages_merges_parallel_results_from_separate_tool_messages1.23.01.0.0b261022kimnamu commentedon Oct 29, 2026
Thanks for the careful write-up and for opening #9796 right away.
You mentioned you had no live Bedrock endpoint, so I sent the history from your repro, with a user turn in front, through
BedrockChatClient.get_responsein us-east-1. On main (fc3c3c0) the caller does get an error, because Converse rejects the request. With the_chat_client.pyfrom #9796 (beb7d29) the same history goes through. Keeping both results but leaving them in twousermessages fails the same way, so the merge step in #9796 matters as much as dropping the.clear()at_chat_client.py:557.toolResultforc2droppedusermessagesusermessagefinish_reason=stopfinish_reason=stopScript, raw output, unit tests
Swap
python/packages/bedrock/agent_framework_bedrock/_chat_client.pybetween runs; needs Bedrock access in us-east-1.Middle row: main with this local change, only to isolate the merge:
Happy to leave it with you. Claude (via Claude Code) assisted with the checks and this write-up; the outputs above are from local runs.