Loop Engineering: The Four-Stage System That Decides What Your AI Agent Does Next
Watch on TikTok
Most people picture an AI agent loop as a few lines of code: a while True: block that keeps calling an agent. This video argues that view is wrong and walks through what a real production loop looks like. On screen, the creator opens with that exact naive snippet, crosses it out, and replaces it with a four-stage cycle: discover, execute, verify, persist. The framing he uses is "the loop is not the model, the loop is the system that decides what the model should do next." The slides are plain typographic cards with a recurring sequence, discover -> execute -> verify -> persist, that the whole video builds toward.
The Naive Version People Start With
The video shows a code block labeled "what most people think":
while True:
call_agent()
The creator calls this "just calling an agent inside a while loop" and then strikes a line through it on screen. His point is that wrapping a model call in an infinite loop is not engineering. It has no notion of where work comes from, whether the output is correct, or what the system learned. A production loop has four distinct stages, and the rest of the video defines each one.
Stage One: Discover Work
The first slide, titled "01 discover" under the header "find the work," lists where work actually originates. The on-screen items are new GitHub issues, failed CI jobs, customer tickets, and stale documentation. The card asks "where does the work come from?" The idea is that a real loop does not wait for a human to hand it a prompt. It scans real sources for work that needs doing and picks up tasks on its own.
Stage Two: Execute Work
The "02 execute" slide, headed "do the work," lists what the agent does once it has a task: research, write code, update docs, ship the task. The caption reads "the agent does what it was assigned." This is the stage most people think of as the whole job, but in the video it is only one quarter of the loop.
Stage Three: Verify Work, With Separate Roles
The creator calls verification the stage "where most people get it wrong." The "03 verify" slide is headed "check the work," and the next slide drives the key rule home with a two-box layout under "separate the roles":
- BUILDER: creates the work
- REVIEWER: approves the work
Between the two boxes is a "not equal" sign, and the caption states "the agent that builds it should never approve it." The creator says production systems increasingly separate the builder from the reviewer. The agent that wrote the code is not the one that signs off on it. That separation is what keeps the loop from rubber-stamping its own mistakes.
Stage Four: Persist Memory
The "04 persist" slide, headed "remember the work," shows a brain icon and the line "forget yesterday, repeat the same mistakes tomorrow." The creator's point is direct: if the system has no memory of what happened in past runs, it relearns the same lessons every cycle and makes the same errors. Persisting memory is what lets the loop improve over time instead of resetting each run.
The Full Loop and What Powers It
The video then shows the four stages as a circle diagram labeled "the production loop," with DISCOVER, EXECUTE, VERIFY, and PERSIST arranged around the word "loop" and the sequence discover -> execute -> verify -> persist underneath. A following slide titled "modern agent systems" lists the building blocks these loops rely on: automations, tools, subagents, worktrees, and memory layers. The caption reads "built around the model, not just the model." The pieces map to the stages. Automations and tools feed discovery and execution, subagents and worktrees support the builder/reviewer split, and memory layers handle persistence.
The Shift: From Prompts to Systems
The closing slides strike through "the loop is the model" and replace it with "the loop decides what the model does next." The final framing slide, under "the shift in AI engineering," reads "from building prompts to building systems that generate them," capped with the line "engineer the loop." The creator's argument is that the work is moving up a level. Instead of hand-writing one prompt at a time, you build the system that figures out what to work on, does it, checks it with a separate reviewer, and remembers the outcome. He closes with a card branding the four stages as Discover, Execute, Remember, and a central "AI" chip, and points to a fuller breakdown in his Skool community linked in his bio.
Key Takeaways
- A production agent loop has four stages: discover work, execute work, verify work, and persist memory. A bare
while True: call_agent()is not one of them. - Discovery means the system finds its own work from real sources: GitHub issues, failed CI jobs, customer tickets, and stale docs.
- The builder and the reviewer should be different agents. The agent that creates work should never be the one that approves it.
- Without persisted memory, the system forgets past runs and repeats the same mistakes every cycle.
- These loops are built from automations, tools, subagents, worktrees, and memory layers, all wrapped around the model rather than being the model itself.
- The broader shift is from writing individual prompts to building systems that decide what the model does next.
Published June 23, 2026. Writeup generated from a favorited TikTok.