Flows category icon
Agent Architecture
Advanced

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 steps12 verify checks90-150 minutesWorks with: emergent · chatgpt · claude · cursor
Start Guided Walkthrough

The Route

0/4 verified

Context Pack

Paste this first. It briefs the AI on requirements, constraints, and the Definition of Done before your first build prompt.

Context Pack
PROJECT CONTEXT:
My agent either does everything in one bloated context or spawns sub-agents indiscriminately, paying full prompt cost for trivial lookups. Claude Code distinguishes spawn (fresh context, specialist definition), fork (inherited context, shared cache), and direct execution - each with distinct costs and fit.

GOAL:
Implement spawn and fork dispatch paths with correct context handling, and encode a decision policy for when each strategy (including direct) applies.

REQUIREMENTS:
- A spawn path: named agent definitions with fresh context, own tool pool, own permission mode and model
- A fork path: child inherits the parent conversation and system prompt for cache sharing
- A direct-execution default for tasks below dispatch overhead
- Recursion guards: forked children must not fork again
- A written decision matrix the orchestrator prompt actually encodes

CONSTRAINTS:
- A spawned agent knows nothing - its dispatch prompt must carry complete background
- Fork children must run under strict behavior rules (no chatting, bounded reports)

DEFINITION OF DONE:
- Spawn produces a sub-agent with zero parent history and an independent tool pool
- Fork produces a child whose request prefix is byte-identical to the parent's
- A forked child attempting to fork is refused by a guard, not by luck
- The decision matrix is followed in transcripts: specialists spawned, research forked, trivia direct

COMMON FAILURES TO AVOID:
- Spawning with a one-line prompt and wondering why the sub-agent flails without context
- Forking for everything, including tasks needing a specialist definition the fork lacks
- Unbounded recursive forking melting the budget
- Dispatching a sub-agent (with full startup cost) for a two-step task the parent could do inline

Paste this into your AI builder first. It teaches the AI what you want before you give it the build prompt.

Related routes

More Agent Architecture flows that share ground with this one.

Flows category icon
Agent Architecture

Implement the Six Core Orchestration Patterns

Worker pool, pipeline, supervisor-worker, adversarial, fork-join, resume chain - build the reusable orchestration patterns every serious multi-agent system converges on.

01Build the shared lifecycle infrastructure
02Implement fan-out patterns: worker pool and fork-join
03Implement sequential and hierarchical patterns

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps120-180 minutesAdvanced
Flows category icon
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.

01Map what must be byte-identical
02Stabilize the shared prefix
03Measure cache performance

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps60-120 minutesAdvanced
Flows category icon
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.

01Analyze the workload for separability
02Score the three architectures
03Sketch the chosen architecture

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps45-75 minutesIntermediate

Made with Emergent