Sequential agent execution is simple to reason about, but it leaves performance on the table whenever tasks are independent of each other. If you need a sentiment analysis, a feature extraction, and a pros-and-cons summary from the same product review, there is no reason to wait for one to finish before starting the next. Running those agents in parallel — fanning out, then fanning in — can cut total latency dramatically and reduce the blast radius of a single failure. This guide shows you how to implement that pattern with the OpenAI Agents SDK and Python’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/openai/openai-cookbook/llms.txt
Use this file to discover all available pages before exploring further.
asyncio.
When parallel agents help
Parallel execution is the right tool when your workflow contains tasks that:- Do not depend on each other’s output. Each agent gets the same input and produces an independent result.
- Are slow enough to matter. If each step takes 1–3 seconds, sequential execution adds up fast. Parallel execution brings the total latency closer to the slowest single step.
- Can fail independently. If one analysis fails, the others can still complete. You decide how to handle partial results.
Basic parallel execution with asyncio
The Agents SDK’sRunner.run method is an async coroutine. Use asyncio.gather to await multiple runs at the same time:
asyncio.gather schedules both coroutines onto the event loop and returns when all of them complete. The result is a list in the same order as the input coroutines, so results[0] corresponds to agent_a and results[1] to agent_b.
A real-world example: parallel review analysis
The following example analyzes a product review from four angles simultaneously — features, pros/cons, sentiment, and recommendation — then feeds all four outputs to a meta-agent that writes a final summary.Step 1: Define specialist agents
Step 2: Run all agents in parallel
Step 3: Synthesize with a meta-agent
Pass all four outputs to a final agent that writes the user-facing summary:Agents as tools: SDK-native parallelism
The Agents SDK also supports a built-in parallel execution model where specialist agents are exposed as tools on a parent agent. The parent agent calls whichever tools it deems useful — potentially multiple at once — and the SDK handles concurrency automatically:The
asyncio.gather approach gives you direct control over which agents run and when. The agent-as-tool approach lets the orchestrator decide dynamically at runtime — useful when the set of analyses depends on the input content.Handling partial failures
asyncio.gather raises the first exception it encounters and cancels the rest by default. If you want to collect results even when some agents fail, use return_exceptions=True:
Measuring the latency benefit
One way to confirm parallelism is working is to compare wall-clock time against the sum of individual run times. If the parallel run takes roughly as long as your slowest single agent (rather than the total of all agents), you are getting the benefit:Coordination patterns at a glance
Fan-out / fan-in
Run N specialist agents in parallel, then pass all outputs to one synthesis agent. Best for fixed analysis pipelines.
Agents as tools
Expose specialists as callable tools on an orchestrator. The orchestrator selects which to call at runtime.
Partial failure tolerance
Use
return_exceptions=True to collect whatever completed and handle failures gracefully in the synthesis step.Sequential fallback
When task B needs task A’s output, keep them sequential. Only parallelize genuinely independent branches.
Further reading
- Parallel agents notebook — the full runnable example with latency visualization
- OpenAI Agents SDK: agents as tools
- Orchestrating agents — sequential handoff patterns for dependent tasks