Definition
Sub-agent
A sub-agent is a separate AI instance spawned by a main agent to handle a specific subtask. In Claude Code sub-agents run with their own context while the parent continues; in Cursor they can be specialised for testing, documentation or refactoring, each in its own context window; in Codex parallel cloud tasks work similarly.
Why it matters
A sub-agent’s real product is a conclusion rather than a transcript. Work that would fill the main context — reading twenty files to answer one question — happens somewhere else, and only the answer comes back.
How each tool handles it
- Cursor
- Subagents can be specialised for testing, documentation or refactoring.
- Claude Code
- Background subagents run with their own context while the parent continues.
- Codex
- Parallel cloud tasks and worktree threads fill the same role.
Frequently asked questions
Does a sub-agent share the parent’s context?
No — that is the point. Each runs in its own context window, so a search that reads many files does not spend the parent’s budget. What returns is the sub-agent’s final answer, not its whole transcript.
When are sub-agents worth spawning?
When work is genuinely independent and you only need the conclusion — a broad search, an audit across many files, several perspectives on the same question. For a single-file lookup the coordination costs more than it saves.
How does Codex do the same thing?
Through parallel cloud tasks and worktree threads. The mechanism differs — isolation comes from a separate task or a separate working directory rather than a spawned instance — but the effect is the same: independent work proceeding without spending the main session's context.