microsoft / microsoft/semantic-kernel

.Net: Python: Bedrock connector rejects parallel tool calls (toolResult blocks not merged into one Converse message)

Open
#14,073 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

.NET python triage
Dominant language
C#
Stars
28.6k
Forks
4.8k
Avg merge
14h 13m
Merged PRs (30d)
18

Description

Describe the bug

Using the Python Bedrock chat completion connector with a model that calls multiple tools in one turn (e.g. Claude Sonnet 4.5), the follow-up Converse request is rejected:

Expected toolResult blocks at messages.X.content for the following Ids: ... but found: ...
Root cause

The function-calling loop (kernel.py invoke_function_call) appends one ChatMessageContent per tool call and one per tool result. BedrockChatCompletion._prepare_chat_history_for_request (connectors/ai/bedrock/services/bedrock_chat_completion.py:173-180) maps each ChatMessageContent 1:1 to a Converse message, so N parallel tool results become N separate role:"user" messages, each with a single toolResult. Converse requires all toolResult blocks for an assistant turn in a single user message (and all toolUse blocks in a single assistant message).

Expected behavior

Chat history with parallel tool calls is usable in follow-up requests without manual merging.

Note

This is the Python counterpart of #13647 (reported for .NET). The sibling Anthropic connector already merges consecutive parallel tool messages (anthropic_chat_completion.py: formatted_messages[-1][content_key] += ...); the Bedrock connector does not. I have a minimal fix + network-free regression test ready and would be happy to open a PR.

Platform

Python, semantic_kernel.connectors.ai.bedrock.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in connectors/ai/bedrock/services/bedrock_chat_completion.py:173-180 and compare its history formatting with anthropic_chat_completion.py, where consecutive parallel tool messages are merged. Review kernel.py invoke_function_call and the available network-free regression test. Done means parallel toolUse blocks and their toolResult blocks are grouped into the single Converse messages required for follow-up requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
ai, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.