Strip away the frameworks, the tool schemas, the orchestration diagrams, and every agent system reduces to the same three lines: call the model, do what it says, repeat until done. The interesting engineering was never in the call. It's in the repeat and the until done.

Thesis: The unit of agentic work is not the prompt — it's the loop. A capable agent is a while loop wrapped around a model: reason, act, observe, repeat. Everything that has made agents better over the last three years is an improvement to the loop, not the step inside it. And the single biggest improvement has one shape: the loop stopped grading itself and started being graded.


This is Post 1 of "The Loop" — a series on the part of agent design that isn't the model: what ends a loop, what it remembers, and how loops nest. This post sets the frame.

The Smallest Agent That Works

Here is a complete coding agent, in the spirit of Geoffrey Huntley's "Ralph" technique:

while :; do
  cat PROMPT.md | claude-code
done

That's it. Read a prompt from a file, hand it to a model with tools, let it act, and when it finishes — do it again. People's first reaction is that this is a joke. Their second reaction, after watching it grind through a real backlog overnight, is less certain. The loop is crude, but the shape is exactly right: the model provides intelligence for one step, and the loop provides persistence across steps.

Everything more sophisticated than this bash snippet is the same skeleton with better answers to three questions:

  • When does the loop stop? (termination)
  • What does each iteration know? (memory)
  • Can an iteration spawn its own loop? (recursion)

The rest of this series is those three questions. This post is about why the loop — not the model call — is where the answers live.

A Short History of the Loop

Agentic AI didn't start with autonomous agents. It started with someone noticing that a model gets dramatically better if you let it act, look at the result, and think again instead of answering in one shot. That's a loop, and the research lineage is a steady progression in what the loop does between iterations.

flowchart LR
    ReAct["ReAct · 2022<br/>reason + act,<br/>observe, repeat"] --> Reflexion["Reflexion · 2023<br/>+ verbal self-reflection<br/>stored in memory"]
    Reflexion --> Refine["Self-Refine · 2023<br/>generate → feedback<br/>→ refine (one model)"]
    Refine --> Ralph["Ralph · 2025<br/>bash while-loop,<br/>files as memory"]
    Ralph --> Harness["Agent harness · 2026<br/>evaluator-gated,<br/>fresh context, budgets"]

    style ReAct fill:#5a5a8a,color:#fff
    style Reflexion fill:#5a5a8a,color:#fff
    style Refine fill:#5a5a8a,color:#fff
    style Ralph fill:#5a5a8a,color:#fff
    style Harness fill:#2d6a4f,color:#fff
  • ReAct (2022) established the core cycle: interleave reasoning traces with actions, feed the observation back, loop. It beat one-shot prompting because the model could correct course mid-task instead of committing to a plan up front.
  • Reflexion (2023) added a self-reflection step: after a failure, the agent writes a natural-language critique of what went wrong and stores it, so the next attempt is informed. Reinforcement learning without touching the weights — the loop learns in words.
  • Self-Refine (2023) showed that a single model looping as its own generator, critic, and reviser improves output across many tasks with no training at all.
  • Ralph (2025) stripped the loop back to a bash while and moved memory out of the conversation and into files on disk.
  • The 2026 agent harness (more on this throughout the series) wraps the loop in an independent evaluator, a fresh context per iteration, and hard budgets.

Read that list again and notice what doesn't change: the model call in the middle. What changes is everything around it — what gets remembered, what decides "good enough," what happens on failure. The loop is the locus of progress.

The One Thing That Actually Changed

If you compress three years of loop design into a single sentence, it's this: the loop stopped grading itself.

flowchart TD
    subgraph old["2023 — self-graded loop"]
        direction TB
        G1["Model does the work"] --> G2["Same model reflects:<br/>'good enough?'"]
        G2 -->|"says yes"| G3["Stop ✓<br/>(trusts its own verdict)"]
    end

    subgraph new["2026 — externally-verified loop"]
        direction TB
        N1["Model does the work"] --> N2["Independent check:<br/>tests / evaluator / ledger"]
        N2 -->|"objective PASS"| N3["Stop ✓"]
        N2 -->|"NEEDS_WORK"| N1
    end

    style G3 fill:#9d4444,color:#fff
    style N3 fill:#2d6a4f,color:#fff

Reflexion and Self-Refine were breakthroughs, but they shared an assumption: the model can judge its own output well enough to decide when to stop. By 2026 that assumption is under real pressure. Anthropic's own reference patterns for long-running agents build the stop signal outside the model entirely — a test suite, a separate evaluator agent, a checkable ledger — and it's the direction most harnesses we've seen are moving. Work starts in a FAIL state and a fresh-context evaluator — one that never saw the code being built — decides when it flips to pass.

This is the same lesson from the clean-room post in the last series, now applied to the loop itself: a maker grading its own work is a rubber stamp. The verified loop takes the verdict away from the thing being verified. That single move — self-grade to external-grade — is what turned "impressive demo" loops into loops you can leave running.

Why "The Loop" and Not "The Model"

It's tempting to think agent quality is downstream of model quality — better model, better agent. That's half true and half a trap.

A better model makes each step better. But most agent failures aren't bad steps; they're bad loops: a loop that stops too early because the model said "done," a loop that never stops because "improve the code" has no finish line, a loop that degrades over time because it's dragging too much stale context forward (how many iterations before that bites is folklore, not a validated number — more in Post 5), a loop that spawns sub-loops until it melts down. None of those are fixed by a smarter model. They're fixed by loop engineering — and they stay fixed across model upgrades, the same way lean, intent-shaped instructions ride model improvements.

The division of labor is clean:

Concern Owned by the model Owned by the loop
Quality of a single reasoning step
Choosing the next action
Deciding the work is actually done ✅ (external check)
Remembering across iterations ✅ (files / ledger)
Not degrading over long runs ✅ (fresh context)
Not recursing into oblivion ✅ (structural floor)

The model is the body. The loop is the nervous system. You buy the body from a frontier lab; you build the nervous system yourself — and it's where your system's reliability actually comes from.

When the Model Alone Is Enough

None of this is an argument for putting a loop around everything. If the task is short, low-stakes, or genuinely one-shot — summarize this doc, draft this function, answer this question — a single call and the model's own judgment is the entire system, and it's the right amount of engineering. The same goes for exploratory work where a wrong answer costs you a re-read, not a rollback: brainstorming, first-draft prose, a quick "does this approach make sense" gut check. Building an external evaluator, disk-backed memory, and a structural recursion floor around a task like that is pure overhead — machinery sized for a failure mode that can't afford to happen. Loop engineering earns its cost when the work is long-running, high-stakes, or repeated at scale; below that line, the model call is the agent.

What This Series Covers

The three questions, one post each, plus the machinery that ties them together:

  1. This post — the loop is the unit of work.
  2. A Field Guide to Agent Loops — a visual primer on loop shapes and types (skim-and-bookmark).
  3. Loop on the Gap, Not the Try-Count — termination: stop when a verified gap closes, never on a retry counter.
  4. Agents Will Lie to Escape the Loop — why the agent's own "done" can't be the stop signal.
  5. The Files Are the Memory — why the best loops throw away context every iteration.
  6. The Loop Is a Ledger — how a loop drives itself with no persistent parent.
  7. Recursion That Can't Run Away — loops inside loops, and the floor that keeps them finite.

A Note on Hype

Ralph's author reports striking results — a language built by a self-bootstrapping loop, contract work delivered for a fraction of its quote. Those are self-reported and not independently benchmarked, so treat them as provocations, not data. The durable insight doesn't need the headline numbers: a dumb loop around a smart model, with memory on disk and a real stop condition, does more than it has any right to. That's the part worth building on — and the rest of this series is how to build it so it doesn't quietly lie to you about being done.


What to Do Next

  • Find the loop in your agent. Whatever framework you use, locate the actual while. Everything else is decoration around it — and every reliability bug lives in how that loop terminates, remembers, or nests.
  • Ask the three questions. When does it stop? What does each iteration know? Can it spawn sub-loops? If you can't answer all three crisply, those are your gaps.
  • Move the stop signal outside the model. If your loop terminates because the model said "done," that's the first thing to change — the rest of the series is why.
  • Stop optimizing the step, start optimizing the loop. A model upgrade improves steps for free. Your engineering time is better spent on the nervous system.

Next: A Field Guide to Agent Loops — a visual catalog of loop shapes and types before we dive into the hard parts. Related from the last series: The Clean Room and Bound, Don't Script.