You do not hand it a task, you hand it an outcome. It makes an attempt, a separate critic scores that attempt against your goal, the gaps go back in, and it tries again. It stops when the result genuinely passes your bar, or it stops and tells you it is stuck. It is never allowed to simply declare itself done.
The finished state that ends the loop. Checkable: a number, a threshold, a pass or fail signal. "Write me a deploy script" is a task. "The next deploy ships in a day with zero rework" is an outcome.
The rubric the judge scores against. What has to be true before "passed" would mean you would actually ship it. Vague criteria make a weak loop, every time.
What produces each attempt, and the context it loads. It never grades its own work. That separation is the whole trick.
A separate critic, usually a different model. It returns a score and the specific gaps. The gaps are the fuel for the next round.
The rules. Pass, ship it. Fail, feed the gaps back and retry. No progress two rounds running, stop and ask a human. It never spins silently.
An ordinary agent tells you it is done. A loop has to prove it against a standard you wrote, with a critic that did not do the work. That is the difference between output and a result.
A run costs real model time, so it is approved by hand. Describe the outcome you would want looped and it goes straight to the operator.
Every failure of an AI system in production comes down to the same thing: it decided for itself that it was finished. The fix is not a better prompt. It is structural. Separate the thing that does the work from the thing that judges it, write down what passing means before you start, and refuse to accept "done" from the only party with an interest in being done.
That is all a loop is. It is also why a loop can be trusted with work that matters, and a single-shot agent cannot.
You do not need this system to use the idea. Paste these, in order, into any model.
ACTOR Produce an attempt at this outcome: <outcome>. Load only what is relevant. Do not grade your own work. JUDGE (start a new chat, so it has not seen the attempt being made) Score this attempt 0 to 100 against these criteria: <criteria>. List every specific gap. Be skeptical. Do not be generous. CONTROLLER (you) Score past the bar? Ship it. Below the bar? Hand the gaps back to the actor and run it again. No progress two rounds running? Stop, and change the approach.