A sub-agent is a separate agent instance that a main agent starts to handle part of a task, with its own instructions and fresh context.
Why Delegate
- Context isolation: a sub-agent can read many files or search results, and return only a short conclusion, keeping the main agent's context clean.
- Parallelism: independent sub-tasks run at the same time.
- Specialisation: sub-agents can have tailored instructions and tools — a researcher, a tester, a reviewer.
Good Candidates
- Searching a large codebase for relevant files.
- Researching several independent questions.
- Reviewing work with a fresh perspective.
Costs
- More total tokens and cost.
- Coordination overhead and possible duplicated work.
- Information lost when results are summarised.
Delegating Well
Give each sub-agent a clear, self-contained task: the goal, relevant context, constraints and the exact form of result wanted. Sub-agents don't see the main agent's history unless it's passed on.
Don't Overuse
For small or tightly coupled tasks, a single agent is simpler and often better. Use evaluation to decide whether delegation helps.