Skip to content
Guides/Concept

What Is Loop Engineering?

Short answer

Loop Engineering is the practice of designing the loop around an AI agent: what it reads, who receives the work, how the result is checked, what gets remembered, and when the loop stops or runs again.

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.

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

The five moves

  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

Example

A CI fix loop reads the latest failing run, hands the task to a coding agent in an isolated worktree, runs lint/test/build, asks a separate checker to review the diff, writes a short run note, and stops for human approval before merge.

Common failure modes

Treating a long prompt as a loop even though it has no discovery source, memory, or schedule
Letting the same agent both create and approve the work
Running repeatedly without a stop rule, budget cap, or human review point

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