Back to Vault
Claude Code Internals
Tier 1

Deep Dive: Agent Orchestration Patterns

Read the Article Fetched 2026-07-08 6 related flows

Summary

Follows a dispatched agent through its full lifecycle - foreground vs background execution, auto-backgrounding of long tasks, sidechain transcripts for resume, layered tool filtering, and result handoff - then catalogs six reusable orchestration patterns: worker pool, pipeline, supervisor-worker, adversarial verification, fork-join, and resume chain. The adversarial verification agent, which must run real commands and issue a PASS/FAIL verdict while being forbidden from editing the project, gets special attention as a defense against LLM self-verification failure modes.

Key Takeaways

  • Never trust an implementer's self-verification: a separate read-only agent must build, test, and probe adversarially
  • Re-inject critical constraints every turn - long conversations make agents forget their rules
  • Layer tool filtering: global denylist, per-agent-type restrictions, then per-instance allowances
  • Every agent creation needs matching cleanup - eight resource types released in one finally block
  • Explicit communication beats assumption: teammates are told exactly which tool makes messages visible
  • Token economy is architectural: read-only scouts skip project docs and run on cheaper models

Reliability Note

English summary of a contributed deep-dive article (original text in Chinese) analyzing a reverse-engineered Claude Code snapshot. Unofficial - verify against official Anthropic docs and behavior.

Flows informed by this source

6
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 QA & Security

Stand Up an Adversarial Verification Agent

Stop trusting your agent's own 'it works': dispatch a read-only verifier that must run real commands, probe adversarially, and return an evidence-backed PASS/FAIL verdict.

01Define the verifier with hard read-only constraints
02Feed it the real task and require evidence
03Add adversarial probes

+1 more steps to Done

Best forproduction-grade builds with strict verification

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

01Specify the delegation contract
02Implement the isolated sub-loop
03Wire dispatch into the parent and distill

+1 more steps to Done

Best forproduction-grade builds with strict verification

4 steps90-150 minutesAdvanced
Flows category icon
Harness Engineering

Verification Loops: Never Trust an Unrun Edit

Wire verification into your agent so every edit is checked by machines - syntax, tests, behavior - before it counts as done.

01Verify at the write boundary
02Add the post-change verify step
03Gate completion on evidence

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps60-100 minutesIntermediate
Flows category icon
Harness Engineering

Observability for Agent Runs

Instrument your agent like production software: traces, session replay, cost tracking, and failure analysis on open standards.

01Instrument spans across the loop
02Build session replay
03Track the economics

+1 more steps to Done

Best forbuilders who have shipped a basic app before

4 steps90-120 minutesIntermediate

Made with Emergent