Loop Engineering

Designing the loop as a system — its parts, its shapes, and when you need an SDK at all.

Goal

Answer the questions a builder actually asks about loops: what is loop engineering, what are its parts, how many loops do I need, how many shapes are there, why is it needed — and do you have to code one on an SDK, or can Claude Code / Codex do it? Each question has its own page; this is the map.

What it is

Loop engineering is designing the iteration itself, instead of doing the iterating. Prompt engineering shapes one model call; the harness runs one agent’s loop; loop engineering designs the system of loops: what repeats, who checks the result, what counts as “done”, and what stops it. In one line: you stop being the person who prompts the agent — you build the thing that prompts the agent.

Crucially, looping is a way of organising a system, not a model. It isn’t a feature you switch on; it’s a pattern almost any agent framework can run, depending on how you wire the pieces. That’s why the paradigm is shifting from Prompt → Output to Goal → Loop → Evaluate → Improve → Repeat → Result — and why both Anthropic and OpenAI now push engineers to build the loop, not just the prompt.

The maturity ladder

Each generation fixed the last one’s failure — this is the shape of the whole field, and the map for the pages below:

flowchart LR
    subgraph P1["1 · Prompt engineering — human drives every iteration"]
      H[Human] --> A1[Agent] --> O1[Output]
      O1 -. feedback .-> H
    end
    subgraph P2["2 · Loop engineering — agent improves its own work"]
      G2[Goal] --> A2[Agent] --> R2[Research] --> D2[Draft] --> E2[Evaluate] --> I2[Improve]
      I2 --> A2
    end
    subgraph P3["3 · Orchestrated looping — teams iterate until done"]
      G3[Goal] --> Orc[Orchestrator - breaks down the goal]
      Orc --> RA[Research agent] & CA[Coding agent] & TA[Testing agent]
      RA & CA & TA --> EV[Evaluation agent - checks quality]
      EV -. next round .-> Orc
    end
    P1 ==> P2 ==> P3
YearLoopLesson it taught
2022ReAct — reason → act → observe, one model, one loopIteration beats one-shot answers
2023AutoGPT — goal-seeking loopFamous for spinning forever → loops need stop conditions
2025Ralph loop — the same prompt re-run against fixed anchor filesPersistent anchors keep long runs coherent
Early 2026Productised loops — a validator decides when work is done“Done” must be checked, not self-declared
Mid 2026Orchestration — a supervisor schedules and coordinates worker loopsOne loop doesn’t scale; teams of loops do

The five pages

PageQuestion it answers
The parts of a loopWhat’s inside a production loop
The four levels of loopsHow many loops you need, and what each one buys
Open vs. closed loopsWhich shape to choose, and when
Fleet loopingHow looping scales to teams of agents
Building a loopOff-the-shelf tool or your own SDK

The two framings compose. Levels tell you how many loops to wrap around the work; the axes below describe each individual loop you end up with — so any loop you meet is a point on three independent axes:

AxisOptionsDetailed in
ArchitectureOpen (explore) vs closed (measured)Open vs. closed
TopologySingle worker vs orchestrated fleetFleet looping
OversightHuman in / on / out of the loopFleet looping

Why you need it

  • One-shot calls cap out — quality comes from iterate-and-verify, and doing that manually makes you the bottleneck.
  • Trust requires a validator — unreviewed agent output doesn’t ship; a loop with a checker turns “plausible” into “verified”.
  • Cost control requires closure — open exploration is unpredictable spend; closed loops with thresholds make cost and quality measurable per run, so each run can be improved.

You stop being the person who prompts the agent — you build the thing that prompts the agent.

When orchestration is warranted, the structure those coordinated loops run on is a graph — see From prompts to graphs for where loop engineering sits in the wider lineage.

Sources