Skip to content

engineer@aine:~/book/chapters$ cat 09_agent-orchestration-patterns.md

CHAPTER 09Agent Orchestration Patterns

Generator-critic loops, the goal pattern, the Ralph loop, git worktrees, subagent arrangements, orchestration as code, and the dark factory at the end of it. The chapter closes with the honest limit: your attention, not your tooling.

  • 33 sections
  • 12k words
  • ~55 min
  • 6 figures
key takeaways7 points
  • 01One agent goes further with a scratchpad you control than with compaction you cannot see.
  • 02SDD is itself an orchestration pattern: the spec is the shared coordination artifact.
  • 03A generator and a separate critic catch more than one agent reviewing itself.
  • 04Isolation comes in three levels: context windows, worktrees, and separate machines.
  • 05The same subagent building block arranges four ways: orchestrator-worker, pipeline, fan-out/fan-in, router.
  • 06Tools change faster than the thinking behind them, so the patterns are what to learn.
  • 07Your brain is the real limit. Find your number of parallel streams and treat it as the cap.
four ways to arrange subagentsascii

inside this chapter

  • Why Software Engineers Need to Understand Agent Orchestration Patterns
  • Why Using a Single Agent Doesn't Scale
  • The Tradeoffs of Orchestrating Multiple Agents
  • One Agent, Bigger Jobs: Compaction and Scratchpads
  • Compaction: The Automatic Fix That Gets Messy
  • Scratchpads: Memory in a File You Control
  • Practice
  • SDD as an Orchestration Pattern
  • Using Different Models in Different SDD Phases
  • The Generator-Critic Loop
  • Worked Example: Adversarial Code Review
  • Practice
  • The Goal Pattern: Looping Until the Goal Is Met
  • The Ralph Loop
  • How It Works
  • What Makes It Work, and What Keeps It Safe
  • Tools
  • Practice
  • Running Multiple Agents in Parallel on the Same Codebase
  • Context-Window Isolation
  • Git Worktrees
  • Isolated Cloud VMs
  • Practice
  • The Subagent Pattern
  • Ways to Arrange Work
  • Practice
  • The Advisor: A Stronger Model for the Hard Parts
  • Workflows: Orchestration as Code
  • A Fixed Script: Letting the Agent Decide
  • Practice
  • The Dark Factory: Where This Is All Going
  • Two Modes of Working
  • Final Considerations

figures

fig 9-1
Compaction lets the system summarize your context in the dark; a scratchpad puts the same memory in a file you can read, edit, and carry into a fresh window.
Compaction lets the system summarize your context in the dark; a scratchpad puts the same memory in a file you can read, edit, and carry into a fresh window.
fig 9-2
SDD treats the spec as a shared coordination artifact that every phase reads from and writes to, which makes it safe to run different phases on different models.
SDD treats the spec as a shared coordination artifact that every phase reads from and writes to, which makes it safe to run different phases on different models.
fig 9-3
One agent generates, a separate agent critiques, you filter the findings, and the work loops back until it passes a clear bar.
One agent generates, a separate agent critiques, you filter the findings, and the work loops back until it passes a clear bar.
fig 9-4
Three levels of isolation for running agents in parallel: separate context windows, separate worktrees on one machine, and separate cloud machines.
Three levels of isolation for running agents in parallel: separate context windows, separate worktrees on one machine, and separate cloud machines.
fig 9-5
The same subagent building block arranged four ways: orchestrator-worker, sequential pipeline, fan-out/fan-in, and router.
The same subagent building block arranged four ways: orchestrator-worker, sequential pipeline, fan-out/fan-in, and router.
fig 9-6
The dark factory assembles every pattern in this chapter into one self-running line: a spec goes in, agents plan, write, and test in a loop, and a reviewable change comes out.
The dark factory assembles every pattern in this chapter into one self-running line: a spec goes in, agents plan, write, and test in a loop, and a reviewable change comes out.

vocabulary introduced here

man aine →

read this chapter

Chapter 9 is in the Early Release.

The code ANSE2026 gives you 30 days of free access to the O'Reilly platform, which covers this book and everything else on it.