a practical guide to loop engineering

Loop engineering, made practical.

Learn how AI agents act, observe, verify, and repeat. Then use the decision tool to choose between a prompt, a fixed chain, and a real feedback loop.

yes no context += tool results -> repeat Context state, goal, evidence Model choose next action tool calls? Tools tests, APIs, files end turn stop when there is nothing useful to observe

Three tasks, three honest answers

Same model, same tools. The right shape changes with the task, not the hype.

“Translate this changelog into French.”
SINGLE PROMPT

Nothing to react to. One input, one correct-enough output. A loop here just adds latency and cost.

“Fix the failing tests, and keep going until they pass.”
LOOP

It has to run them. Read the failure, change something, run again. That feedback is the whole job, so it needs a loop.

“Scaffold the API, then add auth, then write the docs.”
CHAIN

Fixed order, no surprises. Three known steps in sequence. A plain chain is simpler and easier to trust than a loop.

The test I actually use

Is there anything for the model to react to? If acting produces information it should use next, like an error, a test result, a diff, a price, then you want a loop. If it doesn’t, you are paying for a loop and getting a prompt.

That is the core of it. The rest is knowing which loop, and when to put a human in front of the risky parts. The tool runs this same logic on your wording, then names a pattern. You stay the engineer.

Run it on your task

decision test choose the lightest pattern
Does acting create information the agent should use next?
PROMPT
No feedback One clear transform. One answer out.
CHAIN
Known sequence Several fixed steps, decided in advance.
LOOP
Real feedback Act, observe, revise, and repeat until done.

the catalogue

Seven loops worth knowing by name

Each page is blunt about when the pattern fits, when to walk away, and how to start small.

  1. 01 Retry Loop Try, check, retry until it passes. The simplest loop. low cost · low risk
  2. 02 Plan → Execute → Verify Loop Make a plan, do a step, verify it, then proceed. medium cost · medium risk
  3. 03 Explore → Narrow Loop Try several paths, then converge on the most promising. high cost · medium risk
  4. 04 Human-in-the-Loop Run autonomously until judgment or a risky action is needed. medium cost · low risk
  5. 05 Verification / Evaluator Loop Wrap an agent in a grader that scores and sends feedback back. high cost · low risk
  6. 06 Event-Driven Loop An event fires, the agent runs, a real system updates. medium cost · medium risk
  7. 07 Hill-Climbing Loop Analyze run traces and improve the harness itself. high cost · medium risk

If you only remember one distinction

Reach for the lightest one that does the job. Move up only when it stops being enough.

Prompt
One shot in, one answer out. Best when the task is a single deterministic transform and there is no feedback worth reading.
Chain
Fixed steps in order. A to B to C, decided in advance. Predictable, traceable, and nothing between the steps surprises you.
Loop
Act, observe, decide, repeat. For real feedback and genuine iteration, where the next move depends on what just happened.

field notes

Recent writing

Everything in the blog →