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.
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:
Root cause
The function-calling loop (
kernel.pyinvoke_function_call) appends oneChatMessageContentper tool call and one per tool result.BedrockChatCompletion._prepare_chat_history_for_request(connectors/ai/bedrock/services/bedrock_chat_completion.py:173-180) maps eachChatMessageContent1:1 to a Converse message, so N parallel tool results become N separaterole:"user"messages, each with a singletoolResult. Converse requires alltoolResultblocks for an assistant turn in a single user message (and alltoolUseblocks 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.