Skip to content
Guides/Concept

What Is Loop Engineering?

Short answer

Loop Engineering is the practice of designing a controlled outer cycle around model-driven work. The cycle gives an AI agent a clear goal, bounded context, independent evidence, a budget, durable memory, and explicit decisions to stop, retry, or escalate, so repeated work remains verifiable, reviewable, and under human control.

Updated 2026-07-14
First-hand site test
Definition and action paths reviewed

Reviewed against the linked source, the site's safety rules, and the current behavior of its browser-only generators. Sources are evidence, not endorsements.

Site evidence · maintained by TianMingAI · reviewed 2026-07-21

Does a loop specification add control that an ordinary prompt does not make visible?

What we tested

We generated a CI-repair goal with the site's real Codex output function and inspected the artifact for a trigger, measurable outcome, validation evidence, forbidden shortcuts, bounded retries, fallback, persistence, and a human approval point.

Observed result

The artifact made each outer-loop decision inspectable while leaving the inner implementation path open. The added value was not a longer prompt: it was the explicit evidence and terminal states that decide whether work may continue, stop, or return to a person.

What this does not prove

This demonstrates the structure produced by this site, not a universal definition or proof that every runtime enforces the fields. Addy Osmani's current writing uses investigation, implementation, verification, and repeat; other teams may name the stages differently.

Why it matters

A strong prompt can get one useful answer. A strong loop can keep returning to the same kind of work without losing safety, budget, or human judgment. That difference matters once an agent is expected to watch CI, follow review comments, refresh content, clean data, or handle any repeated task.

Origin and source context

Addy Osmani's article provides a useful recent articulation of Loop Engineering for AI agents and helped popularize the term. The broader pattern—feedback, verification, bounded retries, and human control—draws on established engineering practice, so this guide does not claim one person invented every part of it.

Read Addy Osmani's Loop Engineering article

The control sequence

  1. 01
    Goal
  2. 02
    Attempt
  3. 03
    Evidence
  4. 04
    Decision
  5. 05
    Stop, retry, or escalate

The sequence is deliberately explicit. Evidence is evaluated before another attempt begins, and every exit path is decided in advance rather than left to the agent's confidence.

Deterministic outside, model-driven inside

Outer control loop

The outer loop should be as deterministic as the task allows: fixed inputs, validation commands, iteration and budget limits, approval points, and named exit paths.

Inner agent work

The inner work is model-driven: the agent interprets context, proposes a change, and explains its reasoning. That flexibility is useful, but it does not get to redefine success or authorize irreversible actions.

The four layers

The four layers
LayerWhat it handlesWhat breaks when it is missing
Prompt EngineeringOne instruction for one responseThe agent has no durable structure
Context EngineeringThe information inside the current runThe agent works from weak or stale inputs
Harness EngineeringTools, permissions, checks, and guardrails for one runA single run can act unsafely
Loop EngineeringDiscovery, handoff, verification, persistence, and schedulingRepeated work drifts, overspends, or never stops
4 of 4 rows

Compare adjacent concepts

The five operating questions

  1. 01What does the loop read first?Discovery
  2. 02Who or what receives the work?Handoff
  3. 03Who checks the result?Verification
  4. 04What gets saved for next time?Persistence
  5. 05When does it run again or stop?Scheduling

Practical checklist

  • Name the discovery source: CI, issues, commits, inbox, queue, or saved report
  • Define the handoff: which agent works, where it works, and who owns the final decision
  • Use a validation step plus an independent checker
  • Persist the run note so the next pass has memory
  • Set the schedule, stop rule, budget cap, and human approval point

A safe example with explicit exits

A CI repair loop reads one failing run, gives a coding agent the smallest reproducible failure, lets it make a scoped change in an isolated worktree, and asks a separate checker to inspect the commands, evidence, and diff.

Stop rule

Stop when lint, tests, and build pass and the checker finds no unrelated change. Also stop after three failed attempts, any repeated identical failure, or the pre-set budget limit—whichever happens first.

Fallback

Keep the failure logs and run note, discard or revert the unapproved worktree change, and report the smallest unresolved blocker plus the next safe diagnostic step.

Human approval

A person must review the evidence and approve before merge, deploy, deletion, purchase, or any external communication.

Common failure modes

Gaming the metric: the agent satisfies a narrow check while weakening the real outcome, such as deleting a test to make CI green.
Repeated identical failure: the same attempt and error recur without new evidence, but the loop keeps spending time and tokens.
Stale memory: an old run note or summary overrides newer repository state, requirements, or human decisions.
Budget exhaustion: retries continue until the token, time, or money limit is consumed without producing a reviewable result.
Irreversible action: the loop merges, deploys, deletes, purchases, or communicates externally without a human approval gate.

Related templates

FAQ

No. Automation can trigger a task. Loop Engineering also defines the handoff, checker, memory, stop rule, budget, and approval point around that task.

Sources & further reading