Lesson 12 / 29
Sub-Agents and Context Isolation
Delegate noisy side-tasks to helpers that report back briefly.
Do the messy work somewhere else
Some tasks generate a lot of reading that the main task does not need to keep: "find every place this function is used", "investigate why the build is slow", "review this diff for security issues". A sub-agent (or helper agent) runs such a task in its own fresh context, using its own tools, and returns only a short report to the main agent. This keeps the main context clean, allows several investigations in parallel, and lets you give a helper a narrower set of permissions (for example read-only for a reviewer). Costs: more model calls, and the report can omit something important, so the main agent should treat it as evidence to check, not a verdict. Use sub-agents for research, review and bulk analysis; keep the single path of edits with one agent so changes stay coherent.
Give reviewers read-only tools
A review sub-agent needs to read and report, not to edit. Narrow its permissions.
Quick check: What is a main benefit of delegating research to a sub-agent?
- It removes the need for tests
- The main context stays clean while the helper returns a short report
- Sub-agents are always right
- It makes tokens free
Answer
The main context stays clean while the helper returns a short report — Isolation keeps noisy exploration out of the main task's context.