Orchestrator-Subagent Pattern
Implement the orchestrator-subagent pattern where a planner agent breaks tasks into subtasks, delegates to specialist agents, and synthesizes their results into a final output.
The Orchestrator-Subagent Mental Model
The orchestrator-subagent pattern is the most widely used multi-agent architecture. An orchestrator agent receives a high-level goal, decomposes it into subtasks, delegates each subtask to a specialized subagent, collects the results, and synthesizes a final output. Think of the orchestrator as a project manager and the subagents as domain experts on the team.
Responsibilities of the Orchestrator
The orchestrator has three core responsibilities: decomposition (breaking the goal into concrete, actionable subtasks), delegation (assigning each subtask to the right specialist), and synthesis (combining the subagent outputs into a coherent result). The orchestrator itself does minimal domain-specific work — its value is in coordination.
from openai import OpenAI
client = OpenAI()
def orchestrator(goal: str) -> dict:
# Step 1: Decompose
plan = client.chat.completions.create(
model='gpt-4o',
messages=[
{'role': 'system', 'content': 'You are a task planner. Decompose the goal into subtasks. Return JSON with keys: researcher_task, writer_task, coder_task.'},
{'role': 'user', 'content': goal}
],
response_format={'type': 'json_object'}
)
return plan.choices[0].message.contentAll lessons in this course
- Why Single Agents Hit a Wall
- Orchestrator-Subagent Pattern
- Building Multi-Agent Pipelines with LangGraph
- Shared Memory and Inter-Agent Communication