Deep Dive: Multi-Agent Dispatch - Spawn, Fork, Direct
Source-level analysis of the three ways Claude Code dispatches work: Spawn (a named sub-agent with a fresh context, its own tool pool, permission mode, and model), Fork (a synthetic agent that inherits the parent conversation byte-for-byte so parallel workers share the prompt cache), and Direct (the main agent just does the task itself). Covers sync-to-background promotion via a promise race, recursion guards on forking, git-worktree isolation, and a decision matrix for picking a strategy per task.
View source on GitHubKey takeaways
- 01
Spawned agents start from zero context - the dispatch prompt must carry all necessary background
- 02
Fork exists to share the prompt cache: byte-identical request prefixes make parallel workers dramatically cheaper
- 03
Fork workers run under strict rules: no further spawning, no chatting, commit before reporting, bounded report size
- 04
Sub-agents get independent tool pools and permission modes, not a copy of the parent's
- 05
Rule of thumb: specialist skills need spawn; splittable research suits fork; simple steps are best done directly
Flows built on this research
Agent Architecture
Choose the Right Dispatch: Spawn, Fork, or Direct
Three ways to hand work to a sub-agent - fresh-context spawn, cache-sharing fork, or just doing it yourself - and the decision matrix for picking per task.
4 steps · 90-150 minutes
Agent Architecture
Make Parallel Sub-Agents Share the Prompt Cache
Byte-identical request prefixes are why forked workers cost a fraction of spawned ones - engineer your dispatch so every parallel child hits the same cache entry.
4 steps · 60-120 minutes
Agent Architecture
Sub-Agent Delegation with Context Isolation
Delegate bounded work to sub-agents that run in fresh context and return only distilled results - the pattern behind scalable long tasks.
4 steps · 90-150 minutes
Agent Architecture
Single-Agent vs Multi-Agent: Decide and Design
A decision flow for the most expensive architecture choice in agent systems - grounded in what actually ships versus what demos well.
4 steps · 45-75 minutes
Memory & Context
Prompt-Cache-Aware Conversation Design
Structure your agent's context for prefix caching: stable prefixes, append-only history, and cache-friendly dynamic content.
3 steps · 45-75 minutes