Standard library only · runs in your browser
Modern models ask for several tools in one turn (check Paris and Tokyo at once), and every result must carry the exact ID of the call it answers. Get the IDs wrong and the API rejects the request.
Implement execute_tool_calls(calls, max_parallel=4). Each call is {"id": str (optional), "tool": str, "arguments": dict (optional)}.
Return one {"role": "tool", "tool_call_id": id, "content": str} per call, in the same order as the calls:
id becomes f"call_{i}", with i counting from 1 by position.error: duplicate tool_call_id 'ID', and that call isn't run.max_parallel get error: too many parallel tool calls (limit N) and aren't run.dispatch({"tool": ..., "arguments": ...}). A missing arguments key means {}.One failing call never stops the others.
execute_tool_calls(calls: list[dict], max_parallel: int = 4) -> list[dict]