Operating system
Loop engineering
Loop engineering is the layer above prompt engineering, context engineering, and harness engineering: designing how an agent keeps working, checks evidence, spends budget, and stops.

Definition
Loop engineering is the practice of designing the system around an AI agent: what triggers it, what goal it pursues, what evidence it checks, how much budget it can spend, when it stops, and when a human must approve the output.
The agent-work stack
| Layer | What it controls | Example |
|---|---|---|
| Prompt engineering | The instruction | Refactor this file. |
| Context engineering | What the agent knows | Repo docs, tests, logs, source notes, product constraints. |
| Harness engineering | What the agent can do | Shell, browser, CI, PR creation, file tools, retrieval. |
| Loop engineering | When it keeps going and when it stops | Run tests, fix failures, repeat until green, blocked, or approval is required. |
Minimal loop spec
| Field | Question |
|---|---|
| Goal | What should be true when the loop is done? |
| Inputs | What source of truth can it inspect? |
| Actions | What can it change? |
| Verifier | What evidence decides success or failure? |
| Budget | How many turns, dollars, files, or minutes can it spend? |
| Approval boundary | What must never publish, send, delete, or spend without a human? |
Common failure modes
- No measurable stop condition.
- Verifier checks style instead of evidence.
- Approval boundary is implicit.
- The loop can mutate the source of truth it uses to grade itself.
- The task is too broad for one loop and should be split into smaller loops.
QuestionsFAQ
What is loop engineering?
Loop engineering is designing the operating cycle around an AI agent: trigger, goal, repeated action, verifier, stop condition, budget, and approval boundary.
Is loop engineering different from prompt engineering?
Yes. Prompt engineering shapes one instruction. Loop engineering shapes repeated work and the control system around it.
What is the most important part of a loop?
The verifier and stop condition. Without them, the loop can keep producing work that looks active but is not converging.