Commit 819054b
Python: Fix Bedrock parallel tool-call results rejected by Converse
When a model requests multiple tools in a single turn, the function-calling
loop appends one ChatMessageContent per tool call and one per tool result.
The Bedrock connector mapped each of these 1:1 to a Converse message, so N
parallel tool results became N separate user messages each with a single
toolResult block. Converse rejects this with:
Expected toolResult blocks at messages.X.content for the following
Ids: ... but found: ...
Merge consecutive messages that map to the same Bedrock role in
_prepare_chat_history_for_request, so all toolUse blocks for an assistant
turn land in one assistant message and all toolResult blocks land in one
user message. This mirrors the existing behavior of the sibling Anthropic
connector, which already groups parallel tool messages.
Python analogue of #13647 (reported for .NET).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 61331d8 commit 819054b
2 files changed
Lines changed: 66 additions & 1 deletion
File tree
- python
- semantic_kernel/connectors/ai/bedrock/services
- tests/unit/connectors/ai/bedrock/services
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
179 | 187 | | |
180 | 188 | | |
181 | 189 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
153 | 210 | | |
154 | 211 | | |
155 | 212 | | |
| |||
0 commit comments