1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →
What are sub-agents, and why do coding and research agents use them?
30-second answerSay your answer out loud first, then reveal.
Example (coding agent). "Find where authentication is handled in this repo." The main agent spawns an explorer sub-agent that greps and reads 40 files (using maybe 80K tokens) and returns: "Auth is in
src/auth/middleware.ts (JWT verify, line 42) and src/routes/login.ts." The main agent's context only grows by about 200 tokens.Benefits
- Context isolation: heavy reading doesn't pollute the main context (Q17).
- Parallelism: several explorers or researchers run at once.
- Specialisation: a "reviewer" sub-agent with a critical persona; a "test-writer" with only file-write access.
- Safety: a sub-agent with read-only tools for untrusted content.
Design tips
- Write a clear task brief: objective, scope, output format, what not to do. Vague delegation causes duplicated or incomplete work.
- Return structured, condensed results with references (file paths, URLs) so the parent can verify.
- Limit depth. Sub-agents spawning sub-agents gets expensive and hard to debug.
When NOT to use them: tightly coupled work where the sub-agent needs the full conversation context, or tasks small enough that the spawn overhead dominates.
Related
This is what real progress feels like.