Module 10 · The agent loop · Lesson 4 of 5
Planning: ReAct, plan-and-execute, reflection
How an agent picks its next step: interleaved thinking and acting, plan-and-execute with replanning, reflection with a critic, and search as the dear extreme; what reasoning models absorbed, and the cost and failure mode of each.
Why it matters
The loop says the model picks the next action on every lap; it does not say how. A model that acts on its first idea wanders. A model that plans everything up front follows the plan after the world has changed. A model that keeps criticising its own draft never stops. The planning style is the largest lever on how many laps an agent takes, and so on cost and latency. Interviewers want to hear when each named style pays and how it fails.
The idea
Interleaved reasoning and acting
The oldest style alternates a short thought with one action. The model writes why it is about to do something, calls one tool, reads the observation, and thinks again. It has no plan beyond the next step, which is its strength: every decision uses the latest observation. It is the default shape of native tool use, where the thought is a sentence of text before the tool-use block. Cost is one model call per lap.
Plan and execute
The second style splits planning from doing. One call writes a numbered plan: the steps, the tool each needs, what done looks like. A cheaper loop then executes the steps, often on a smaller model, and a check after each step asks whether the plan still holds. On a surprise, a failed step or an observation that contradicts a premise, the planner is called again and rewrites the rest. The plan gives the run a shape you can show a user, approve before execution and log; the price is that it was written before any evidence arrived.
Reflection
The third style adds a critic. After a draft answer, or after a trajectory of several laps, a call examines the work against the task and lists what is wrong. The agent retries with the critique in context. Reflection catches errors the actor could not see while acting, and it is the backbone of evaluator-optimizer workflows. It costs at least two calls per attempt and usually three (draft, critique, revise), and it needs a reason to stop: a critique that says good enough, or a cap on rounds.
Search
The expensive extreme explores several candidate next steps at once, scores them, keeps the best and expands again: a tree of partial trajectories rather than a single line. It wins on puzzles where early choices are hard to undo and a wrong branch is cheap to abandon. It multiplies cost by the branching factor at every depth, so it rarely fits a product and almost never a latency budget.
What reasoning models changed
Current frontier models think before they answer, in tokens you are billed for but do not have to prompt for, and adaptive thinking decides how much to deliberate per request, steered by an effort parameter. A single lap now contains the think-then-act of the first style and much of the plan of the second, without the prompt engineering that used to produce them. The practical effect: a plain loop on a reasoning model at a high effort setting often matches a hand-built plan-and-execute at far lower engineering cost. Explicit plans still earn their keep when a human must approve the plan, when steps run on different models, or when the plan itself is the artefact the user wants.
Cost arithmetic
Assume a task of five tool calls and a context that grows to 30,000 tokens. Interleaved: five laps, about 90,000 input tokens in total as the context grows. Plan-and-execute: one planner call, five cheaper executor laps, perhaps one replan; roughly the same tokens, but most of them on a smaller model. Reflection on the final draft: two more calls at full context, about 60,000 tokens, for one critique and one revision. Search with branching three to depth two: nine trajectories where one would do. Latency follows the call count, so reflection and search both land outside a tight interactive budget.
| Interleaved | Plan-and-execute | Reflection | Search | |
|---|---|---|---|---|
| Steps | One thought, one act, one observation per lap | Plan once, execute n steps, replan on surprise | Draft, critique, revise, repeat | Branch, score, keep the best, expand |
| Cost | One call per lap | One planner call plus n cheaper laps | Two to three calls per attempt | Branching factor to the power of depth |
| Adaptivity | Highest; every step uses the latest result | Low between replans | High on quality, not on direction | High, at great expense |
| Fit | Short, observation-driven tasks | Long tasks; plans a human must approve | Quality-critical drafts | Combinatorial puzzles; offline |