Skip to main content
blog.philz.dev

The Two Agentic Loops & Differing

Two Agentic Loops

There are two loops in using agentic coding agents. The right-hand loop is the agentic loop, and we've already talked about it in The Unreasonable Effectiveness of an LLM Agent Loop with Tool Use. The agent takes a prompt, and calls tools repeatedly until there are no more tool calls to make, and then responds to the user. This is "one turn."

The left-hand loop is the user's workflow when the first, agentic loop concludes. After the agent does its thing, and I either run the code to test it or I review the diff. Repeat in a loop I abandon hope, get distracted, or finish.

There's a bit more to say about Code Review, in the left loop, and guard rails, implied in the right loop.

Code Review #

I worked quite a bit on sketch.dev's diff viewer and wrote about right-hand editable diffs. I've used Mondrian (~2006), Review Board, Gerrit, Phabricator, and GitHub Pull Requests all to provide code reviews for co-workers. The expected latencies were days. Reviewing agentic code is different: you're going to feed the review right back into the agent. The agent is always going to agree with you! ("You're absolutely right," says Claude, ever so irritatingly.)

You don't need to give the agent much structure about your review. If you type a file name, quote some code, and leave a comment, the agent tends to fix the issue. (Various "todo" developments seem to have helped various models' keep track of what they have and haven't done.)

Differing Screenshot

Differing is a largely vibe-coded tool that I'm using to review my agentic diffs. It supports right-hand editable diffs, in that I can edit the files directly. It accumulates comments, which I can copy/paste into the agent chat. It uses Monaco's diff viewer under the covers. It ships as a single binary that you run locally.

Guard Rails #

The agents produce better results if your code base has guard rails. Without a loop, an LLM might provide, say, invalid SQL. Once it's able to run the SQL against your database, it will provide syntactically valid SQL. (It might still be wrong, but it's going to compile!)

This isn't surprising. We build the same kinds of guard rails for ourselves and our teams. Tests, linters, type checkers, and so on. "If you liked it you should have put a test on it," as "Beyoncé" said.

Programming with agents changes the annoyance coefficient of some of these checks. They're easier to add: I recently wrote a lint rule for Go with a single prompt; I've added eslint-typescript to code bases with a single prompt. They're less tedious to resolve, since the computer does most of the resolution for the more pedantic rules.