0PricingLogin
AI Engineering Academy · Lesson

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.content

All lessons in this course

  1. Why Single Agents Hit a Wall
  2. Orchestrator-Subagent Pattern
  3. Building Multi-Agent Pipelines with LangGraph
  4. Shared Memory and Inter-Agent Communication
← Back to AI Engineering Academy