Parallel Tool Calls and Streaming with Tools

Three independent weather lookups serialized is three round trips. Run them in parallel and total time collapses to the slowest single call. Every frontier provider now emits multiple tool calls in a single turn. The payoff is real; the plumbing is subtle. This lesson walks both halves: the parallel fan-out and the streamed-argument reassembly, with emphasis on the id-correlation trap.

Build 1.3 hr Python (stdlib, thread pool + streaming harness)

Prerequisites: Phase 13 · 02 (function calling deep dive)

#Learning Objectives

  • Explain why parallel_tool_calls: true exists and when to disable it.
  • Correlate streamed argument chunks to the right tool-call id during parallel fan-out.
  • Reassemble partial arguments strings into complete JSON without parsing early.
  • Run a three-city weather benchmark that demonstrates sequential vs parallel latency.
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.