Lesson 2 · Agent Orchestration
Workflows vs Agents: Six Shapes
Almost every orchestration you will meet is built from a handful of shapes.
Your win for this lesson
Given a task, you can say whether it needs a workflow or an agent, and name the shape that fits: prompt chaining, routing, parallelization, orchestrator-workers, evaluator-optimizer or autonomous agent.
0. Warm-up: recall from last time
Answer these first, before reading anything new. Coming back to an idea after a gap is what makes it stick.
1. The one distinction that matters
Anthropic calls both of these agentic systems, but splits them by who decides the path:[1]
- Workflow: LLMs and tools are orchestrated "through predefined code paths." You decide the steps; the model fills them in.
- Agent: the LLM "dynamically directs its own processes and tool use." The model decides the steps.
This is the same test you just used for the Explore subagent. A path designed in advance means a workflow; a path decided by the model at runtime means an agent. It also explains graph engineering: a graph is a workflow whose nodes may themselves be agents. You fix the shape, and each node is free to work out its own part.[2]
Every shape below is built from one block: the augmented LLM, a model with retrieval, tools and memory.[1] Before reaching for any of them, remember that for many tasks a single well-prompted call is enough.[1]
2. Five workflow shapes
① Prompt chaining
Split the task into fixed steps; each call takes the previous output. A code gate between steps can stop bad output early.
Use when the task breaks cleanly into the same steps every time. Example: write an outline, check it against rules, then write the document.
② Routing
Classify the input, then send it to a prompt (or model) specialised for that category.
Use when inputs fall into distinct categories you can classify reliably. Example: refund / technical / general support queries; easy questions to a small model, hard ones to a big one.
③ Parallelization
Run several calls at once and combine the results. There are two kinds: sectioning (different independent subtasks) and voting (the same task several times).
Use when you want speed, or more confidence from several attempts. Example: three prompts review code for vulnerabilities, and it is flagged if enough agree.
④ Orchestrator-workers
A central LLM breaks the task down at runtime, hands the pieces to workers, then combines their results. The dashed boxes show that the workers aren't known in advance.
Use when you can't predict the subtasks. This is the difference from ③: there, you fix the subtasks; here, "the orchestrator determines subtasks based on the input."[1] Example: a code change that touches an unknown set of files. Anthropic's research system uses this shape.[3]
⑤ Evaluator-optimizer
One LLM generates, another critiques, and they loop until the evaluator accepts.
Use when you have clear evaluation criteria and refining measurably helps. Example: a translation critiqued and revised. In code, the "evaluator" is often not an LLM at all: it can be the test suite, which is a sensor from Lesson 1.
3. The sixth shape: the autonomous agent
⑥ Autonomous agent
An LLM uses tools in a loop based on feedback from the environment, until a stop condition. This is Claude Code itself.
Use when the problem is open-ended, you can't predict or hard-code the number of steps, and you trust the model's decisions. The cost is higher spend and the risk that errors compound, so Anthropic advises sandboxing and guardrails.[1]
Connecting to Lesson 1
The Ralph loop is shape ⑥ restarted from scratch over and over, with tests acting as an evaluator (⑤). The Lesson 1 code-review graph (parallel reviewers → verifier → fixer → tests) is ③ followed by ⑤. Most real systems are combinations of these six shapes.
4. How to choose
Go down this list and stop at the first one that works. Each step adds cost and failure modes.
- One call, plus retrieval and examples. Often enough.
- Fixed steps? → chaining. Distinct input types? → routing. Independent parts, or want votes? → parallelization.
- Clear pass/fail criteria? → add an evaluator-optimizer loop.
- Subtasks only known at runtime? → orchestrator-workers.
- Open-ended, unknown number of steps? → autonomous agent, with a strong harness.
"Success in the LLM space isn't about building the most sophisticated system. It's about building the right system for your needs."Schluntz & Zhang, Anthropic [1]
5. Practice: recall the shapes
Without scrolling up, list the six shapes and give each a one-line "use when."
- Prompt chaining: the task always breaks into the same fixed steps.
- Routing: distinct input categories, each best handled separately.
- Parallelization: independent parts (sectioning) or several attempts (voting).
- Orchestrator-workers: subtasks only known at runtime.
- Evaluator-optimizer: clear criteria, and refining helps.
- Autonomous agent: open-ended, unpredictable number of steps.
Shapes 1–5 are workflows (you design the path). Shape 6 is an agent (the model chooses the path).
6. Practice: pick the shape
Choose the simplest shape that fits each scenario.
Primary source to read next (≈25 min)
Erik Schluntz & Barry Zhang, "Building effective agents" (Anthropic, Dec 2024). Nearly every later framework, including LangGraph tutorials and graph-engineering posts, reuses its vocabulary. Read the patterns section, then skim Appendix 2 on tool design: the authors say they spent more time optimising tools than the overall prompt.
Stuck or curious?
Ask me in the terminal. Good questions to try: "Which shape is Claude Code's plan mode?" or "Is evaluator-optimizer the same as a Ralph loop?"
Quick reference: Six Orchestration Shapes · The Five Zoom Levels