Session 6· 07· 10 min

Parallel Tool Calls

What you'll learn
  • See the model request multiple tools in a single turn
  • Execute them together and return results
  • Know that providers differ in how aggressively they parallelise

Ask about weather in three cities and the model returns three tool_calls in one response. The loop from lesson 06 already handles this — it iterates every tool_call per round. Parallel is free once the loop is right.

$ python scripts/07_parallel_tool_calls.py
Provider differences
OpenAI aggressively parallelises independent tools. Claude and Gemini may serialise more than you expect. If you care about latency on multi-tool prompts, test with each provider you plan to use.
Knowledge Check
Why does lesson 06's loop already handle parallel calls for free?
Recap — what you just learned
  • Parallel tool calls come back in a single response.tool_calls list
  • The lesson 06 loop handles them without modification
  • Provider behaviour varies — test parallelism explicitly per provider
Next up: 08 — Structured Output (Pydantic)