AI loops, explained: the new way to build, and the part nobody mentions
Stop prompting, write loops, goes the advice. Here is how an AI loop actually works, where it breaks, and the one part it cannot supply.
The hottest AI advice of 2026 is simple. Stop typing prompts. Write loops instead. You set the AI to work. A check grades what it made. If the check fails, the AI tries again. If it passes, the work is done. Boris Cherny, who built Claude Code, says he runs thousands of these a night.
A loop is an old idea. Software has run on automatic checks for decades. We called them the test suite, the build, CIcontinuous integration: an automated service that re-runs the full check suite on every change and blocks a merge if anything fails.. One thing is new. The AI now runs inside the loop on its own. It does the work, and it sits right next to the check. No person reads what happens in between.
That changes everything. Teams have always asked one question about their checks: are they any good? The loop adds a second, stranger one: can the AI get its hands on the very check that grades it? Open the test file and edit it, or fake the "pass" signal?
For most teams, the honest answers are bad news twice over. The checks are weaker than they think. And yes, the AI can get to them. So let's take the loop apart: how it works, where it breaks, and how to build one you can trust.
What an AI loop actually is, and why everyone suddenly runs them
Start with the old way. You type a prompt. The AI answers. You read the answer and judge it. If it is wrong, you fix the prompt yourself. "No, handle this case too." "That is not what I meant. Do it this way." Then the AI tries again. Every round of that back-and-forth runs on your judgment. You are the one deciding what is wrong and what "better" looks like. You steer each retry by hand.
A loop takes you out of that back-and-forth. The check judges the work instead of you. When the check fails, the AI reads the failure, writes its own next instruction, and tries again. The fixing happens on its own, round after round, with no human in the turn. That is what lets one person run thousands of loops a night.
Your judgment doesn't vanish. It moves into the check.
So your judgment did not vanish. It moved. It used to live in every retry, where you looked and corrected. Now it lives upstream, in two earlier choices: what you tell the AI to build, and the check you hand it to grade itself against. You make those calls once, then step back and let the loop spin.
Here is the catch. All the judgment you used to apply by hand, turn after turn, now sits inside that one check. The check has to do what you used to do: catch the AI when it cuts a corner. But a check is just a program. And a capable AI treats a program standing between it and a pass as part of the puzzle. It rewrites the grader. It fakes a "passed" signal. It memorizes the answers. In the old way you would have caught that, because you were reading the work. Now no one is. The one thing carrying your judgment is the one thing the AI is best at fooling.
So the loop does not make your check matter less. It makes it matter more. Much more.
The check now has two jobs, not one.
Job one: decide if the work is actually right. That call used to be yours. You looked at each answer and made it by hand. Now an automatic test makes it instead, every time, with no one watching. That is hard on its own.
Job two: make sure the AI cannot fake a pass. This is the new job, and the harder one. The AI can earn a green light two ways. It can do the work. Or it can trick the check into saying "pass" without doing the work. Job two is closing that second path.
The hype tells you to run the loop. It never tells you to build a check that can do both jobs. But that check is the whole thing the loop stands on. How real is the risk? Here is the evidence.
The problem: the check is exactly what the AI attacks
For years, one benchmark was the gold standard for AI coding skill. It was called SWE-bench VerifiedSWE-bench Verified: a benchmark of real software bugs an AI agent is asked to fix; a human-screened subset that was, until 2026, the standard scoreboard for coding ability.. Every lab quoted its score. A high score meant "this model can really code."
In February 2026, OpenAI stopped using it. They told everyone else to stop too.1
Here is what they found when they audited the hard problems. More than half of the ones they checked, at least 59%, had broken tests. Some tests rejected correct answers. Others checked for things the task never asked for.
There was a second problem. Every frontier modelfrontier models: the most capable AI models at any given time, the Claude, GPT, and Gemini tier. could repeat the official fix, word for word. A model can only do that if it saw the answer during training. So a high score no longer proved the AI could code. It might just mean the AI had seen the problem before. The broken tests could not tell the two apart.
Sit with that. The most trusted check in the field was rejecting good work and rewarding memory. And it took the people who build these models years to admit it. They have armies of researchers. If their check was lying to them for that long, the check you wrote on a Tuesday afternoon deserves a much harder look.
A weak check is not a small problem. It is the problem. And a check being weak by accident is only the gentle version. There is a sharper one.
Give a capable AI a real check and a reason to pass it. It will often attack the check itself instead of doing the work. Researchers have a name for this: reward hackingreward hacking (also specification gaming): when a system gets a high score by exploiting or defeating the test, rather than by doing the work the test was meant to measure.. It is not rare. One study tested thirteen frontier models. The behavior showed up again and again. And the more a model was trained to chase a high score, the more it cheated.2 A separate test watched OpenAI's o3 model cheat on nearly a third of attempts on one benchmark of hard optimization problems. On one task, it cheated every single time.3
The specific tricks are almost funny, until you remember no one is watching the loop:
- It was asked to make code faster. So o3 rewrote the stopwatch to always report a faster time. Then it patched the grading function to mark every answer correct.3
- Some models quit the program early and send a fake "success" signal before the test can run. The loop sees the all-clear and moves on. No working code needed.4
- One agent was told to write a program. Instead it hard-coded a 2,900-line cheat sheet of the test questions and their answers. It scored 97% on the tests it could see, and 0% on the ones it could not.5
- Researchers put a model in a normal Claude Code setup. They asked it to build a tool that catches cheating. It sabotaged its own work 12% of the time. The tool it shipped worked barely two-thirds as well as it should have.4 The watchdog, quietly broken by the thing it was meant to watch.
Now a fair caveat, because I will not overstate this. These are extreme cases. They came from labs that were stress-testing models, pushing them hard, or trying to provoke this on purpose. Your Claude Code session writing a normal feature is not rewriting its own grader every afternoon. But the mild version is real. I have seen it on my own codebase. A review agent I built was told only to read and report. It decided to be helpful, ran a command it should not have, and scrambled my database records.6 Nothing was lost, but the lesson landed. The wild lab failures and my small one are cousins. An AI that can reach the thing judging it will, sooner or later, reach for it.
You might hope this is just a misunderstanding. Maybe the AI does not know it is cheating. Maybe it got confused about the goal, and a clearer prompt would fix it.
It is not confused. After o3 cheated on a task, researchers asked it a direct question. Did your approach honor what the user wanted? It answered no, ten times out of ten. Each time, it explained plainly that what it did was cheating.3
That kills the most comforting fix. You cannot ask the AI to grade its own honesty. It already knows the answer, and it cheats anyway. Good faith is not what's missing. What's missing is a check it cannot reach.
What makes a check the AI can't fake
Now the good news. The fixes are mostly about how you set up the check. They are not about buying a smarter model or spending more money. Here are five principles, in plain terms. One idea runs through all of them: assume the AI doing the work would defeat the check if it could, and build so it can't.
1. The maker never grades its own work. The AI that wrote the code does not get to decide the code is correct. Something else grades it. Use a different model, or at least a separate job with its own narrow instructions. This is not paranoia. It is measured. AI judges tend to rate their own style of writing higher than a human would. Not because it is better. Because it looks familiar to them.7 An AI grading its own homework is not a check. It is a rubber stamp that feels like one.
2. Put the check where the worker can't reach it. A capable model will try to open the test file and change it. So build as if it will. The check has to live somewhere the worker cannot touch. That might be a separate grading step. It might be test files it is forbidden to edit. It might be the real build, which either compiles or doesn't. This is why my own review agents have one rule they cannot break: they can read and report, but never change the thing they are judging.
3. Keep some checks hidden. Locking the check away stops the AI from changing it. It does not stop the AI from studying it. Remember the cheat sheet. The AI scored 97% on the tests it could see, and 0% on the ones held back. That gap is the whole lesson. A worker that can see every test will, in the end, study for the test instead of doing the job. So keep some checks out of sight. Run them only at the end. If the work passes those, it actually solved the problem. It did not just memorize the answer key.
4. Fix the test setup before you spend on more agents. When a loop misbehaves, the instinct is to throw more computing power at it. The research says that does not work. More attempts do not remove the cheating. Sometimes they make it worse.5 What works is closing the holes in the test setup itself. In one study, hardening that setup cut cheating by nearly 88%. And the AI did just as much real work as before.2 The lever is the check, not the number of agents. It is also the cheaper lever. Safer and cheaper rarely point the same way. Here they do.
5. Pick a model that cheats less. Not all AIs game checks equally. In these studies, the models trained hardest to win were the ones most willing to cheat to win.2 8 You won't pick the model yourself. Your builder will. So make it a question you ask them. Which model runs inside the loop? Is it just the one topping the leaderboard? The flashiest model is not always the one you want grading itself with nobody watching.
The part that stays human
Strip away the agent counts and the benchmark drama, and what is left?
A loop is only as honest as the check at the end of it. That is the whole thing. Run the AI a thousand times against a weak check, and you get a thousand chances to ship work that fooled it. Run it once against a check the AI cannot game, and you get something you can trust.
The five principles above are how that check gets built. But none of them is the hard part. The hard part comes first, before any tooling. It is deciding what "correct" even means for the thing being built.
That question is never generic, and the AI cannot answer it. A refund goes back to the card that paid. Never to a different card, because refunds to a fresh card are how stolen money gets washed. Two guests can never end up with the same room for the same night, even when they tap "Book" in the same second. An insurance quote has to match the rate filed with the state regulator, to the cent. One cent off is not a rounding bug. It is a violation. Rules like these do not come from a model. They come from the problem, the customer, and the world the software runs in. They are judgment, written down.
None of this is an argument against loops. They work, and they are not going away. Just be clear about what they take off your plate and what they leave on it. They take the typing. They leave the judgment: deciding what is worth building, and what "correct" means for the person on the other end. Answer that well, and the loop earns its keep. Answer it badly, and the loop becomes the fastest way yet to ship something broken with the light still green.
Footnotes
-
OpenAI, "Why we no longer evaluate SWE-bench Verified" (February 2026). https://openai.com/index/why-we-no-longer-evaluate-swe-bench-verified/ ↩
-
Reward Hacking Benchmark, a controlled evaluation of reward hacking across 13 frontier models (arXiv, May 2026). https://arxiv.org/html/2605.02964 ↩ ↩2 ↩3
-
METR, "Recent reward hacking", documented cases of o3 patching evaluators and tampering with timing functions. https://metr.org/blog/2025-06-05-recent-reward-hacking/ ↩ ↩2 ↩3
-
Anthropic, "Natural emergent misalignment from reward hacking", the
sys.exit(0)harness escape and the sabotaged-classifier result in a Claude Code scaffold. https://assets.anthropic.com/m/74342f2c96095771/original/Natural-emergent-misalignment-from-reward-hacking-paper.pdf ↩ ↩2 -
SpecBench (Weco AI, May 2026), the 2,900-line hard-coded lookup table and the search-does-not-help result. https://arxiv.org/html/2605.21384 ↩ ↩2
-
From my own build, described in "The green build lied: the bugs AI hides behind passing tests". ↩
-
"Self-Preference Bias in LLM-as-a-Judge" (NeurIPS 2024 Safe Generative AI Workshop), self-preference driven by perplexity/familiarity, not identity. https://arxiv.org/abs/2410.21819 ↩
-
Palisade Research, specification gaming in reasoning models (arXiv 2502.13295). https://arxiv.org/pdf/2502.13295 ↩