Loop Engineering
Prompt engineering shapes one request. Context engineering shapes what the model knows. Loop engineering shapes what happens on turn forty.
Loop engineering is the design of the cycle an agent runs: which tools it can call, what the results look like coming back, when it stops, and who gets to interrupt. The model emits tokens. Every other part of that cycle is a decision somebody made, on purpose or by default.
Take a coding agent pointed at a failing test. Prompt engineering gets the instruction right. Context engineering hands it the diff and the test output. Loop engineering decides the rest. Does a second failure come back as an error to retry or a signal to stop and ask? Does the agent read the whole file or grep for the symbol? Can it push a branch without a human looking? And what stops it after forty turns with nothing to show?
We pull it out as its own skill because this is where the money and the ugly failures live. A prompt problem gives you a bad answer once. A loop problem gives you the same bad answer on every turn, bills you for all of them, and commits the result. Anthropic’s agent guidance puts a maximum iteration count in the design for that reason, not in the postmortem. The rest of the controls are just as unglamorous: tool granularity, error messages the model can act on, compaction before the window fills, checkpoints worth rolling back to, and a stopping condition that isn’t “the model decided it was finished.” Evals are how you find out which of those you got wrong.
In Effective AI, this is Session 3 work. The cohort arrives with something that runs, then has to make it survive a new model and a bad day.
When an agent burns a budget and commits the wrong thing, the prompt takes the blame. The loop deserves it.
Resources
- Anthropic, “Building effective agents” (Anthropic, 2024) — the composable patterns, tool design appendix, and the case for stopping conditions
- Prompt Engineering — shaping the single request
- Context Engineering — deciding what earns a place in the window
- AI Engineering Glossary — harness, human-in-the-loop, compaction, guardrails: the vocabulary loop engineering works in
- Evaluations — how you learn which loop decisions were wrong
- AI Cost-Savings Scorecard — agentic guardrails and a deterministic harness are two of its nine cost levers
- Compounding Engineering — a loop worth keeping is a loop worth improving
- Effective AI — where cohorts harden their loops in Session 3
Nerdy