
AI agents · Five patterns · Arrow keys to step
An agent system is a graph: model calls, tools, routers, checks, memory and people, joined by handoffs that carry state. Pick a pattern, step a token of state through it, and click any node to see what it reads and what it writes.
step 1 of 13
One model in a loop: it reads the task, calls a tool, reads what came back, and decides what to do next until it decides it is done.
← → step through · Tab to a node, Enter to pin it · Esc to unpin
The token now holds
"Dates before 1970 come out wrong. Fix it."
The token is here
Person
Asks for the work and gets the answer.
Asks for the work, and approves what cannot be undone.
Start here. One model in a loop with a few well-described tools handles most tasks, and it is the easiest graph to debug: every decision is made in one place.
One model, so one bill and one prompt cache. Every turn resends the history, so a long task gets dearer per turn as it goes, and each turn waits on the one before.
The model decides when it is finished. It can stop early, retry a failing tool forever, or never run the tests at all.
The tests here are just another tool, and the model is the one reading their output. Move them out of the loop into a gate the run must pass, and "done" stops being the model's opinion.
At list prices an Opus token costs 40× a Haiku token, so which tier sits on the busiest node matters more than how many nodes there are.
Draw any agent system and the same six kinds of node turn up. A model call reads its context and decides or writes something. A tool is code the model asks to run. A router picks where an input goes next. A gate is plain code that passes or fails the work. Memory is whatever outlives a single call, and a person asks for the work and approves what cannot be undone.
The edges matter as much as the nodes. Every handoff carries some state, and the design question at each one is how little it can carry. A worker that hands back a three-line summary instead of every file it read keeps the next model's context small, cheap and sharp.
Start with the simplest graph that could work, which is usually one model with a few good tools, and add nodes only when a measured failure asks for one. A router earns its place when requests really do come in different kinds. Workers earn theirs when the job splits into independent pieces. An evaluator earns its place when there is a rubric and a first draft is usually close.
Each node you add is another call to pay for, another place to fail, and another handoff where state can get lost. More agents is not more intelligence; it is more plumbing.
A model asked whether its own work is finished tends to say yes. So every decision a script can make (does it compile, do the tests pass, is the data well formed) should be a gate in code, not a model's opinion. Gates are free, fast, and cannot be talked round. Models hold only the checks that need judgment or eyes, and they hold them against criteria written down before the work began.
People belong at the steps that cannot be undone. Ask them once, late, with everything they need to say yes at a glance.