Delegation and parallelism
The fix for context rot is not a bigger window — it is more, shorter conversations. This chapter is about the two mechanics that make horizontal scaling practical: subagent delegation within a session, and parallel sessions across worktrees. Go wide, not deep.
On this page
There is a ceiling on how much work a single session can do before context rot sets in. The instinct is to push the ceiling higher — use the 1M window, compact aggressively, add more discipline. The insight is the opposite: stop trying to scale the single session and scale the number of sessions instead. This chapter is about the two mechanics that make horizontal scaling practical — delegating within a session to a subagent, and running sessions side-by-side across isolated worktrees.
Representation
Context as Currency made the case that context decays non-linearly. The consequence — understated there, fleshed out here — is that the best response to “this task is too big for one session” is almost never “make the session bigger.” It is “make the tasks smaller and run more of them.”
Two mechanics enable horizontal scaling:
Subagent delegation. A child agent spawned from inside a session with its own isolated context, tools, and sometimes its own git worktree. The child works on a bounded sub-task and returns a summary; the research or exploration context does not pollute the parent. Delegation is within-session scaling.
Parallel sessions. Multiple independent agent sessions running side-by-side, each with its own context, usually in its own git worktree to prevent file conflicts. Each session owns a logical workstream. This is cross-session scaling.
When to go wide vs when to go deep
Not every task scales horizontally. Two legitimate shapes:
Go wide (multiple short sessions) when the tasks are independent, can be serialized with handoff files, or naturally factor into parallelizable sub-problems. Examples: implementing separate features, reviewing multiple PRs, batch operations across files, porting chapters.
Go deep (one long session) when the task requires continuous reasoning across many interconnected decisions that would lose coherence if split. Examples: debugging a subtle concurrency bug where every clue informs the next, designing a complex API where each endpoint’s shape depends on the others, working through a proof or derivation.
Default to wide. Most work decomposes into independent units better than practitioners expect. The two-minute overhead of writing a handoff file is almost always less than the cost of context degradation in a three-hour session.
The delegation economics
Subagent delegation has a specific economic profile worth internalizing. Spawning a child agent costs:
- Startup overhead: the child’s briefing doc re-injection, its own system prompt, initial tool registration — usually ~8–15K tokens. Not cheap; not ruinous.
- Result summarization: whatever the child did has to compress into a return value the parent can act on. Long child-sessions that produce vague summaries waste the delegation.
- Context switching: the parent pays a small attention cost when re-engaging after the child returns.
The delegation pays back when the avoided cost — the tokens the parent would have consumed doing the work itself — exceeds the startup + summary cost. For a well-scoped research task that would have taken the parent 40K tokens of file-reading, a subagent with 15K startup and a 2K summary saves ~23K tokens net. For a trivial task that would have taken the parent 3K tokens, delegation is a net loss.
Operation
Tri-tool delegation surface
| Primitive | Claude Code | Gemini CLI | Codex CLI |
|---|---|---|---|
| Spawn subagent within session | Task tool (with subagent_type) | agent-chaining via prompts | Agents SDK for programmatic; limited in-CLI |
| Subagent context isolation | yes, first-class | prompt-level | via Agents SDK |
| Subagent worktree isolation | isolation: worktree frontmatter | via explicit git worktree add | via explicit git worktree add |
| Built-in git worktree flag | --worktree / -w (v2.1.49+) | manual git worktree add | manual git worktree add |
| Agent-team coordination | Agent Teams feature | manual | Agents SDK |
| Resume parallel session | claude --continue / --resume | gemini --continue | codex resume |
Subagent patterns
The mental model: a subagent is a function call with bounded input, a clear contract, and a short return value.
You: "Delegate a search: use a subagent to find every file in
src/features/ that uses pandas (not polars). Report a
bullet list of paths plus the pattern used in each. Do
not edit anything."
[Agent spawns subagent with Task(subagent_type='general-purpose', ...)]
[Subagent reads src/features/, greps, builds list, returns summary]
Agent: "Found 7 pandas usages: ..."
[200-token summary in parent context;
parent's context is unchanged from before the task]
The contract matters — the prompt to the subagent specifies exactly what the deliverable looks like (“bullet list of paths plus pattern”). Without a contract, the subagent may return 2,000 tokens of exploration results, and you’ve turned delegation into pollution.
Parallel-session patterns
Multiple independent agent sessions, each in its own git worktree, working on separate workstreams. Each session reads the same briefing doc (so conventions propagate automatically) and writes to an isolated branch.
The canonical flow:
- Identify 3–5 independent tasks (fix bug A, add feature B, refactor module C).
- For each, spin up a worktree-isolated session:
claude --worktree fix-bug-a(orgit worktree add+ agent launch for the other CLIs). - Each session completes its task and commits. No file conflicts because worktrees isolate the filesystem.
- Merge each session’s branch into main via PR or direct merge.
Claude Code’s v2.1.49 --worktree flag makes this a single command. Gemini and Codex require the manual git worktree add incantation but the outcome is the same.
Evolution
Horizontal scaling is a practice convergence ahead of a product convergence. The insight — many short sessions beat one long one — is now widely shared; the tooling to make it frictionless is still mostly Claude-first.
Convergence: git worktrees as the filesystem-isolation primitive. All three tools treat git worktrees as the right mechanism for filesystem-level parallelism. Claude Code has built-in CLI support (--worktree / -w since v2.1.49, Feb 2026). Gemini and Codex rely on git worktree add + manual session launch. The outcome is identical; the keystrokes differ.
Emerging: handoff-file automation. A few practitioners are experimenting with auto-generated handoff files — the agent produces the Right now / Why / Next step / Context sections at session-end automatically, based on the session transcript. The output is uneven today; the human-written version is usually better. But as models improve at meta-cognition over their own sessions, expect automated handoff to become a viable shortcut.
When delegation goes wrong
Three failure modes to watch for:
Over-delegation. Spawning subagents for tasks the parent should have done directly. Signal: the parent’s context keeps growing from summaries rather than work-in-progress. Fix: the decision rule above — delegate research, not implementation.
Under-contracted delegation. Subagents that return too much. Signal: the parent gets a 2,000-token summary and has to re-summarize it. Fix: specify the deliverable format in the subagent prompt; treat it like an API call with a declared return shape.
Premature parallelization. Running five sessions on tasks that turn out to be coupled. Signal: sessions start invalidating each other’s analysis mid-work. Fix: decomposition gate. If you can’t write a one-sentence summary of what each session will produce without referencing the others, they are not parallelizable — sequence with handoffs.
Quick reference
- Horizontal scaling — many short sessions — beats vertical scaling — one long session — for most work.
- Two mechanics: subagent delegation (within-session context isolation) and parallel sessions (cross-session filesystem isolation via worktrees).
- Delegate when the task has high context cost (lots of files to read) and a compressible result (a short summary). Don’t delegate when the output is itself what the parent needs to keep working with.
- Subagent prompts are tighter than main prompts — specify the deliverable format explicitly.
- Parallel sessions require worktree isolation. Without worktrees, “parallel” becomes “overlapping edits.”
- Handoff files (
CURRENT_WORK.md) bridge between sessions cheaply. Two minutes to write saves ten minutes of re-discovery. - Claude Code has the most ergonomic surface for delegation + worktree workflows today. The practice ports to Gemini and Codex; the plumbing is more manual.
- Go wide by default. Go deep only when the task genuinely needs continuous reasoning across interconnected decisions.