agentsadvanced

Multi-Agent Coordination: Orchestrator and Subagent Patterns (2026)

Quick Answer

Multi-agent coordination uses an orchestrator LLM that breaks a task into subtasks and delegates each to a specialized subagent. Subagents run in parallel when tasks are independent, or sequentially when outputs chain. The orchestrator receives results, synthesizes them, and either produces a final answer or delegates further. This pattern scales to complex tasks that exceed a single agent's context window or tool set.

When to Use

  • Tasks requiring specialized expertise across multiple domains (legal review + financial analysis + technical due diligence)
  • Parallelizable tasks where multiple subtasks can run simultaneously to reduce total latency
  • Tasks too long for a single context window — delegate sections to subagents with separate contexts
  • Systems requiring audit trails — each agent's work is logged independently, enabling granular review
  • Building agent systems where different teams own different subagent capabilities

How It Works

  1. 1Orchestrator pattern: the orchestrator receives the full task, generates a plan, and issues subtask assignments to subagents. Subagents are LLM calls with specialized system prompts and tool sets. The orchestrator waits for results and synthesizes.
  2. 2Define clear handoff contracts: what the orchestrator sends to the subagent (task description, context, constraints) and what the subagent must return (structured result, confidence, sources). Use JSON schemas for handoffs.
  3. 3Parallel execution: when subtasks are independent, execute subagent calls concurrently. If the research agent and the financial analysis agent can work simultaneously, run them in parallel with asyncio.gather().
  4. 4Result aggregation: the orchestrator receives all subagent results and synthesizes them. If subagents return conflicting information, the orchestrator must detect and resolve conflicts explicitly.
  5. 5Fault isolation: if a subagent fails, the orchestrator can retry it, replace it with a fallback, or complete the task with a note about missing information — without crashing the whole pipeline.

Examples

Orchestrator dispatching subagents
async def orchestrate_company_research(company: str) -> dict:
    # Orchestrator plans and delegates
    orchestrator_plan = await llm_call(
        system='You are an orchestrator. Given a research task, identify 3-4 parallel subtasks and their required tools.',
        prompt=f'Research {company} for investment analysis. List parallel subtasks.'
    )
    
    # Define subagents (specialized system prompts + tool subsets)
    subagents = [
        SubAgent('financial_analyst', tools=['get_financials', 'get_earnings']),
        SubAgent('news_analyst', tools=['search_news', 'get_sentiment']),
        SubAgent('competitive_analyst', tools=['search_web', 'get_competitors']),
    ]
    
    # Execute all subagents in parallel
    subtask_results = await asyncio.gather(*[
        subagent.run(f'Research {company} for your specialty')
        for subagent in subagents
    ])
    
    # Orchestrator synthesizes
    synthesis = await llm_call(
        system='Synthesize these research findings into an investment thesis.',
        prompt=format_results(subtask_results)
    )
    return synthesis
Output:3 specialized subagents run in parallel, each with a focused tool set and system prompt. Orchestrator synthesizes after all complete. Total latency = max(subagent latencies), not sum.
Subagent result schema
# Enforce structured subagent output for reliable orchestrator synthesis
SUBAGENT_RESULT_SCHEMA = {
    'completed_task': 'string',  # What was accomplished
    'findings': 'list[string]',  # Key findings
    'confidence': 'number 0-1',  # Self-reported confidence
    'sources': 'list[string]',   # URLs or document refs
    'limitations': 'string',     # What the subagent couldn't determine
    'flags': 'list[string]'      # Anything the orchestrator should know
}

# System prompt addition for subagents:
'Always return your findings as JSON matching this schema. Include limitations — the orchestrator needs to know what you couldn't determine.'
Output:Structured subagent output enables the orchestrator to reliably aggregate results. The 'limitations' field is critical — it tells the orchestrator what gaps exist so it can decide whether to request more research.

Common Mistakes

  • Too many subagents for simple tasks — multi-agent adds coordination overhead (extra LLM calls, latency, complexity). For tasks a single agent can do in 5-10 steps, multi-agent is overkill. Use it only when parallelism or specialization provides clear value.
  • No handoff schema — subagents returning free-text results force the orchestrator to parse and interpret, introducing errors. Always define JSON schemas for subagent outputs and validate them before passing to the orchestrator.
  • Subagents with access to the full tool set — subagents should be restricted to the tools they need for their specialty. A news analysis subagent shouldn't have database write access. Principle of least privilege applies to agents.
  • Infinite delegation depth — orchestrators can spawn subagents that spawn sub-subagents, creating uncontrolled recursion. Set a maximum delegation depth (typically 2) and reject delegation requests beyond that depth.

FAQ

When should I use multiple agents vs. one agent with many tools?+

Use multiple agents when: tasks are parallelizable and latency matters, different specialists need different context/tools/prompts, or tasks exceed a single context window. Use one agent with many tools when: tasks are sequential, context sharing is critical, or you need simplicity. Multi-agent adds coordination overhead — only pay that cost when the parallelism or specialization benefit is clear.

How do I prevent subagents from going rogue?+

Defense in depth: (1) Restrict tool access per subagent. (2) Set output format contracts — reject non-conforming outputs. (3) Set token budgets per subagent call. (4) Never give subagents access to credentials beyond their scope. (5) Run subagents in sandboxed environments for code execution. The orchestrator should validate all subagent outputs before acting on them.

What frameworks support multi-agent coordination?+

LangGraph (LangChain) is the most mature framework for multi-agent graphs with state management. CrewAI provides high-level role-based multi-agent abstractions. Anthropic's multi-agent guidance recommends simple tool-based orchestration without frameworks for most use cases. Microsoft AutoGen supports complex agent conversations. Start simple (raw API calls with asyncio) before adopting a framework.

How do I handle context window limits across subagents?+

Each subagent has its own context window. The orchestrator passes only the relevant task and context to each subagent — not the full conversation history. This is a key advantage of multi-agent: distributing context across agents multiplies effective total context by the number of agents.

What's the cost model for multi-agent systems?+

Multi-agent systems are inherently more expensive than single-agent due to: additional LLM calls for each subagent, orchestrator synthesis calls, and potentially duplicate context sent to multiple agents. A 3-subagent system typically costs 3-5x more per task than a single agent. Design with this in mind — use cheap models for specialized subagents and the powerful model only for orchestration.

Related