Loop Engineering — The Complete Guide
The full companion course to the video. Everyone says stop prompting your agent and write a loop — almost nobody explains what a loop actually is. This does: the inner loop, the outer loop, the runner that connects them, and the gate that decides when to stop, built from the floor up across 12 chapters.
Download the 30-Page Master Handbook
Get the full production handbook with all 13 engineering steps, complete Docker Compose configs, Better-Auth TypeScript scaffolding, deep health probes, and the 16-point verification suite.
Sign in with Google or GitHub to download the complete 30-page PDF handbook & runnable configs.
Zero spam · Free forever · 1-click modal
What this course is
This is the complete written course behind the video "The Inner Loop, the Outer Loop, and the Gate." The video is the tour; this is the whole machine, one part at a time. It takes you from "I prompt my agent" to "I can look at any agent system, name its two loops, name its runner, and say exactly what makes its loop safe to leave running."
Most explanations of loop engineering fail for the same reason: they are built on a vocabulary you were never given. Words like agent, tool, context, memory, and hook get used as if everyone already shares a precise definition. This course refuses to do that. It installs ten words first, then builds every chapter out of exactly those ten and nothing else.
What's inside the 57-page PDF
Part I — What a loop actually is
- The ten words you must own — the vocabulary the rest of the field skips, with an example and a common misconception for each.
- An agent is already a loop — the one idea the whole course turns on.
- The two loops — the inner turn your agent already has, and the outer one that decides to run it again.
- The missing machine: the runner — the non-intelligent part that re-summons the model, and the five runners every agent loop in the wild is built from.
- The full chain — spec → runner → agent → tools → gate, and why the loop itself never runs a single command.
Part II — What makes a loop worth running
- Memory: the loop's spine — the one property that separates a loop that learns from a loop that only repeats.
- The gate — why an agent will tell you it's done when it isn't, and how a real stop-condition catches it.
- Loops you can trust — the one universal move, the line between a demo and production, and a checklist that would have prevented most of the public agent failures of the past two years.
- A real, running example — a four-line shell runner, a
PROMPT.mdspec, and apytestgate you can build with your own hands.
Use it this week
Read it once, then build the running example against a real task you actually ship. Bounding the loop — making non-deterministic software safe enough to act in the real world — is the whole of what we mean by AI Reliability Engineering.
This is Volume 1 of 3. Volume 2 picks up at the gate and memory in depth — what happens when the loop trusts the agent's word instead of a fact.
Want more guides like this?
Subscribe to get weekly AI agent reliability insights and new guide notifications.
Subscribe to Newsletter