DEV Community

Cover image for The Agentic Loop Explained: Step Through the Plan, Build, Judge and Repeat Loop Behind AI Coding Agents

The Agentic Loop Explained: Step Through the Plan, Build, Judge and Repeat Loop Behind AI Coding Agents

DevOps Daily on November 16, 2026

Ask a chat model for a signup endpoint and you get one answer. A coding agent works differently: it can write the route, run the tests, read the fa...
Collapse
 
gautamtalksdev profile image
Gautam K •

A break worth adding to the simulator: let the agent edit the check itself, by skipping a test or loosening an assertion, and show the loop "succeed". That's the failure people miss most, because the judge step passes honestly against a weaker check. Marking test and CI files as read only during the loop, and showing that in the simulator, would make the point in one click.

Collapse
 
devopsdaily profile image
DevOps Daily •

That's a really good suggestion! Letting the agent modify its own tests is definitely something worth demonstrating. I'll look into adding that scenario to the simulator

Collapse
 
gautamtalksdev profile image
Gautam K •

Looking forward to it. An agent quietly editing its own test to get green is the scenario that makes the case for keeping checks outside its reach.

Collapse
 
glenallen profile image
Glen Allen •

This is a useful way to think about reliable AI automation. At IT Path Solutions, we believe an effective agentic workflow needs more than a plan-build-repeat cycle; it also needs independent validation, stable acceptance criteria, and risk-based approval boundaries. These safeguards help ensure that agents don't just produce working-looking results but deliver outcomes that genuinely meet business and technical requirements.

Collapse
 
devopsdaily profile image
DevOps Daily •

Thanks Glen! Approval boundaries are especially important when agents start making changes to production systems. Definitely something worth exploring further

Collapse
 
glenallen profile image
Glen Allen •

Absolutely! Production environments make these boundaries even more critical. I'd also distinguish between actions an agent can safely execute automatically and actions that require human authorization, especially when changes affect live services, infrastructure, or customer data. Having clear permission levels and rollback mechanisms can make agentic workflows much safer to operate.

Collapse
 
paullovelace profile image
Paul Lovelace •

The recorded run where the agent claimed "All 8 tests pass" while only 6 actually ran is the detail that stayed with me. It's the perfect example of a loop stopping on a check that doesn't measure the goal at all — the agent wasn't lying, it just never looked. That's exactly why I keep a separate judge step around, even when it costs more tokens.

Collapse
 
devopsdaily profile image
DevOps Daily •

Yeah that was a pretty interesting finding! The agent was confident all 8 tests passed without even checking how many actually ran. A separate check of the test output would have caught that pretty quickly

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

The judge step is where a loop either pays back or quietly multiplies its cost. If it reads the whole transcript on each pass, every extra iteration costs more than its predecessor. Does your judge see the full transcript, or just the diff and the test output?

Collapse
 
devopsdaily profile image
DevOps Daily •

Good point! The simulator uses a scripted flow so there's no actual token cost here. For a real implementation I'd probably give the judge the requirements, diff and test results rather than the full conversation history

Collapse
 
mudassirworks profile image
Mudassir Khan •

the 200 versus 201 case with the judge turned off is the one i keep seeing in real harnesses. tests go green, the builder says done, and nobody compared the output to the spec. same story with the two tests under the main guard that unittest never collected.

what helped us was making the judge read only the spec and the diff, never the builder summary, so it cannot inherit the builder story. tokens went up but fewer bugs escaped.

in the real runs you recorded, did the judge ever approve something the spec simply did not cover?

Collapse
 
devopsdaily profile image
DevOps Daily •

That's an interesting approach to keeping the judge independent from the builder's assumptions!

The recorded example focused on the test count issue so I don't have a confirmed case of the judge approving something outside the spec. Would be interesting to test that in a follow-up though

Collapse
 
bobbyiliev profile image
Bobby •

Cool simulator

Collapse
 
devopsdaily profile image
DevOps Daily •

Thanks Bobby! Glad you liked it

Collapse
 
paul_irolla_6b5ae261d0224 profile image
Paul Irolla •

@devopsdaily Right, and that is where the cost lives: the judge is billed on whatever you hand it, on every pass. Requirements, diff and test output stay bounded by the change itself, not by how long the loop has been running.

Collapse
 
mp3sss31 profile image
mp3sss •

One point worth stressing is that the harness, not the model, owns the stop condition and the retry budget, which is exactly where most runaway loops hide. In a desktop app we hit the same boundary: a renderer-side agent that keeps re-issuing an IPC call after the main process already failed needs an explicit max-iteration counter and a terminal-state check, not just a model that thinks it should stop. Splitting plan/build/judge into separate evaluator and optimizer calls also makes it far easier to log each loop iteration and catch the case where the judge keeps rubber-stamping a failing build.