Manager/Subagent Orchestration & Context Isolation
CoreDesign multi-agent systems and orchestration for genuinely separable work · Difficulty 3/5
Explanation
When a task is genuinely separable and heavy, a manager/orchestrator coordinates specialized subagents, each running in its own context window and returning only a condensed result.
Why This Helps
- Context isolation -- a research Subagent can read thousands of tokens and hand back a short summary, keeping the manager's context clean.
- Specialization -- each Subagent gets a focused prompt, tool set, and (optionally) model tier -- route cheap steps to Haiku, hard steps to Sonnet/Opus.
- Parallelism -- independent subtasks run concurrently.
Context Isolation Is the Defining Benefit
Of the three benefits above, context isolation is the one that has no substitute at the single-agent level: a single augmented LLM has one context window, and if a subtask requires reading and reasoning over a large amount of material, that material bloats the main context whether or not the answer needed from it is short. Delegating that subtask to a Subagent lets the manager receive only the condensed result, not the raw material.
Designing the Hierarchy
- Identify subtasks that are genuinely independent or that require reading far more material than the final answer needs.
- Give each Subagent a narrow system prompt and only the tools its subtask requires.
- Assign a model tier per Subagent based on task difficulty -- not every Subagent needs the most capable (and most expensive) model.
- Run independent subagents concurrently when their subtasks do not depend on each other's output.
This is the multi-agent analog of the workflow composition patterns: specialization mirrors routing, parallel Subagent execution mirrors parallelization, and a manager deciding subtasks at runtime mirrors orchestrator-workers -- multi-agent systems are the agentic-loop version of the same underlying ideas.
Key Takeaways
- Manager/orchestrator coordinates specialized subagents, each with its own context window
- Context isolation is the defining benefit: a subagent can read a lot and return only a condensed result
- Specialization lets each subagent get a focused prompt, tool set, and model tier (e.g., Haiku for cheap steps, Sonnet/Opus for hard ones)
- Independent subtasks running concurrently deliver the parallelism benefit
- Multi-agent hierarchies mirror workflow composition patterns (routing, parallelization, orchestrator-workers) at the agentic-loop level
Glossary Terms
The practice of directing requests to different Claude model tiers based on assessed complexity and requirements. A common pattern uses a fast, cheap model (Haiku) to classify task complexity, then routes to Sonnet or Opus accordingly.
The core pattern for AI agents: call Claude, check `stop_reason`, if `"tool_use"` execute the requested tools and append results, then call Claude again. Repeat until `stop_reason` is `"end_turn"`. The number of loop iterations is determined dynamically by task complexity.
A multi-agent architecture where a central coordinator manages specialized subagents using hub-and-spoke communication. The coordinator handles task decomposition, routing, and result aggregation. Subagents never communicate directly with each other, keeping the system auditable.
Anthropic's Python SDK for building agentic applications with Claude. Provides primitives for agentic loop management, subagent orchestration, tool integration, and lifecycle hooks. Imported as `claude_agent_sdk`. Removes the boilerplate of raw-API agentic loops so architects can focus on design rather than plumbing.
A Claude instance spawned by an orchestrator to handle one bounded subtask in complete context isolation. Each subagent starts with a fresh context window — the orchestrator's history is never inherited — and is invoked via the [Task tool](/glossary/task-tool). The subagent runs its own full [Agentic Loop](/glossary/agentic-loop), then returns a single structured result to the orchestrator.
The built-in Agent SDK tool used to invoke a subagent. Takes a task description, available tools, and optional context. The subagent runs its own agentic loop in an isolated context and returns its final result. The primary mechanism for multi-agent delegation.
The Agent SDK configuration object that blueprints a reusable agent: which model it runs on, what system prompt shapes its behavior, which tools it may call, and what lifecycle hooks fire during its execution. `AgentDefinition` is defined once and can be instantiated many times — each run gets an independent agent instance from the same static configuration. For what a subagent *is*, see [Subagent](/glossary/subagent).
Related Concepts
Workflow Composition Patterns & the Orchestrator-Workers Trap
Five workflow composition patterns: prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer
Multi-Agent Cost Tradeoffs & the "Not Automatically Better" Trap
Multi-agent hierarchies multiply token usage and add real coordination overhead