Lesson 02.04 · Phase 02 · Tool Use & Function Calling
Parallel tool calls
When one turn asks for several independent lookups, run them at the same time, give each result back under its own id, and never run two side effects in an order the model didn't ask for.
Learning objectives
- Run a turn's tool calls concurrently with threads or asyncio, and return results matched by call id, in the model's order.
- Isolate failures and enforce a deadline for the whole batch.
- Keep side-effecting tools sequential and ordered, while read-only tools run in parallel.
- Detect a model cramming several values into one argument, and fan it out into parallel calls.
"What's the weather in Pune, Oslo and Lima?" needs three lookups. If each takes 300 ms and you run them one after another, the user waits almost a second before the model even starts answering. Run them together and it's 300 ms.
Loading the full lesson…