Chapter 2: Think, Act, Observe, Repeat
Every agent runs a loop. The model thinks about what to do, takes an action, observes the result, then decides whether to continue. Without this loop, the model generates one response and stops. With it, the model can work through multi-step problems.
The "think" step sends the accumulated context to the model. The model responds with a plan: which tool to call, what arguments to use, or whether to ask the user for clarification. This is where intelligence lives.
The harness parses the model's output and executes the requested tool. Read a file. Run a command. Search the web. The model can't do any of this itself. The harness is the bridge between thinking and doing.
The tool's output flows back into the context window. Now the model can see what happened. Did the file exist? Did the test pass? This feedback is what turns a single generation into an iterative problem-solver.
A loop without exit conditions is a time bomb. Every production harness checks: Is the task done? Have we hit the token budget? Are we past the max iterations? Did the human intervene?
The loop doesn't decide when to stop. The harness does.
Click the tabs to see how different agent architectures organize their loops. ReAct is the simplest. Plan-Execute separates planning from execution. Reflexion adds self-critique. Claude Code optimizes for tight code iteration.
The loop shape determines what the agent can do, not the model inside it.