agent loops — tool_use and the request/tool/respond cycle7 / 9
multi-step tools — when one tool isn't enough
The model returned two tool_use blocks in one assistant turn —
classic parallel tool calls. The reply builder runs both tools but
hardcodes both tool_use_id values to "t1". The next API call
will 400 because tool ids must match the originals (t1 and t2).
Fix the loop so each tool result carries its own original id.
Expected output:
['t1', 't2']
The break is on line 14 — but read the whole snippet first.
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _