Flows category icon
Agent Architecture
Advanced

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.

4 steps12 verify checks120-180 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 multi-agent setup is ad-hoc: every coordination need gets a bespoke hack, and long-running agents leak resources or lose results. Claude Code's orchestration converges on six named patterns with shared infrastructure - lifecycle management, result delivery, and cleanup - underneath all of them.

GOAL:
Build the shared orchestration infrastructure (lifecycle, delivery, cleanup) and implement the six patterns on top: worker pool, pipeline, supervisor-worker, adversarial, fork-join, resume chain.

REQUIREMENTS:
- Shared lifecycle: register on dispatch, track foreground/background state, deliver results, clean up on completion
- Foreground-to-background promotion for long-running children without losing them
- Per-child transcripts persisted so completed or stopped agents can be resumed
- All six patterns implemented as reusable functions over the shared infrastructure
- Complete cleanup on every exit path - normal, error, and cancellation

CONSTRAINTS:
- Agent-to-agent communication must be explicit - a message not sent through the delivery path does not exist
- Every agent creation must have a matching cleanup or the system leaks under load

DEFINITION OF DONE:
- A long-running foreground child can be promoted to background mid-execution and still deliver
- Each of the six patterns runs end-to-end on a demo task
- Killing the parent mid-pattern leaves no orphaned processes, files, or connections
- A stopped agent resumes from its transcript and completes

COMMON FAILURES TO AVOID:
- Results delivered to a log nobody reads instead of the parent's next turn
- Background children killed accidentally by the parent's cancellation signal
- Cleanup on the happy path only, leaking sessions/files/connections on errors
- Implicit communication assumptions - agents 'reporting' in text no other agent receives

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

Agent-to-Agent Protocols (A2A)

Connect two agents over an explicit protocol - task handoff, acknowledgment, and failure handling - instead of hoping chat works out.

01Define the protocol
02Build the message layer
03Wrap agents as protocol endpoints

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 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
Flows category icon
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.

01Implement spawn: fresh context specialists
02Implement fork: inherited context, shared cache
03Add guards and async lifecycle

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 minutesAdvanced

Made with Emergent