Agent Loops, Explained
An agent loop is the control flow wrapped around an agent's skills and tools that forces work to completion: plan, act, check the result, recover from failure, and repeat until verification passes or a budget runs out. Loops attack the two dominant agent failure modes: stopping early and declaring false success.
Key takeaways
- A loop is defined by two things: its verification method (how it knows it's done) and its recovery behavior (what happens on failure). Missing either, it's just repetition.
- Plan-execute-verify is the reference pattern: criteria written before execution, evidence checked per step.
- False success is structural: generation and self-assessment share the same blind spots. External checks break the loop.
- Boundedness matters as much as persistence: a loop without a budget is an incident waiting for a trigger.
- Closed-loop versus open-loop is the reliability distinction: check-and-correct versus fire-and-forget.
Why loops exist
Agents fail in two dominant ways: they stop early, and they declare false success. Both failures share a root: nothing in a bare generate-and-respond cycle checks output against the goal. A loop is the control flow that adds the check and refuses to stop until it passes.
The distinction that matters is closed-loop versus open-loop. Open-loop is fire-and-forget: cheap, fine when errors are cheap. Closed-loop routes output back through verification, and becomes mandatory the moment a wrong result costs more than checking would have.
What defines a loop
Two properties define any loop pattern; a loop missing either is just repetition.
Verification method: how does it know it's done? The strong answer is always evidence, never assertion: a test suite's exit code, a rendered page inspected, a file parsed back. And the criterion must be written before the work, or verification degrades into rationalizing whatever happened.
Recovery behavior: what happens on failure? Retry with diagnosis, backtrack to a known-good point, escalate to a human, or abort. The worst answer is the silent one: loops that have never met a failure they acknowledge.
To these, production adds a third: boundedness. Budgets, iteration caps, abort criteria. A loop without a budget is an incident waiting for a trigger. The full five-axis treatment is the Loop Reliability Model.
The named patterns
| Pattern | One-line definition | Reach for it when |
|---|---|---|
| Plan-execute-verify | Plan with per-step criteria, execute one step, verify on evidence, repeat | False success is expensive |
| Checkpoint-resume | Persist state at durable checkpoints; reconcile on every resume | Work outlives a session or context window |
| Budgeted retry | Retry under an explicit budget with mandatory diagnosis between attempts | Flaky environments, external dependencies |
| Reviewer loop | Fresh-context review against a rubric before acceptance | Producer bias hides defects |
These compose. A production workflow might run plan-execute-verify per task, budgeted retry around each flaky operation, checkpoint-resume across sessions, and a reviewer loop before anything lands.
Why self-assessment fails
False success is structural, not moral. Generation and self-assessment run on the same model with the same blind spots: whatever misunderstanding produced the error also approves it. The fix is external evidence: exit codes and rendered output that cannot be argued with, or fresh-context review that does not share the producer's reasoning. This is why every strong verification step reads captured output rather than trusting the narrative.
Where to start
Adopt plan-execute-verify on one workflow where false success has burned you. Add a budget and an escalation path before adding anything clever. Then measure: our first Lab benchmark pre-registers exactly this comparison, one-shot versus PEV on a fixed bug-fix task set, so the completion-rate claim gets a number instead of a vibe.
Frequently asked questions
What is an agent loop?
The control flow that forces agent work to completion: plan, act, verify against evidence, recover from failure, repeat until done or out of budget.
What is a plan-execute-verify loop?
A loop where the agent writes a plan with per-step success criteria before executing, then advances only when each step's captured output meets its criterion.
Why do agents declare false success?
Self-assessment uses the same model that produced the work, inheriting its blind spots. Loops fix this with external evidence: exit codes, tests, rendered output, fresh-context review.
Summary
- Topic
- Agent loops
- Definition
- Control flow forcing completion: plan, act, verify on evidence, recover, repeat under a budget
- Best used for
- Any task where stopping early or false success is expensive
- Related concepts
- plan-execute-verify, false success, verification step, loop reliability
- Common mistakes
- Verification theater, unbounded retries, loops without recovery behavior
- Recommendation
- Start with plan-execute-verify; add budgets and escalation before adding sophistication