On Friday, Claude Code creator Boris Cherny made an appearance at Meta’s @Scale conference and, surprisingly, the first question from the audience was about loops.
“Are the loops the next cycle of hype,” the questioner asked, “or are they real?”
Cherny’s response was an emphatic “yes, they are real,” he said.
“Two years ago, we wrote the source code by hand. We started transitioning to agents writing the code. And now we’re transitioning to the point where agents are asking agents to then write the code,” he continued. “As big a step as it was from source code to agents, loops are just as important and a big step.”
Later in the talk (around the 32:00 mark in the YouTube video posted above), Cherny was specific about the loops he continues to run in his own work. One agent continually looks for ways to improve the code architecture, while another looks for duplicate abstractions that can be unified. They submit pull requests like any other coder, and since the code is constantly changing, they never stop running.
It is a powerful idea, especially with such an important figure as Cherny behind it. With the shift to agent AI, the focus for most users has been on managing their agents as best as possible: setting clear goals, monitoring discrete units of progress, and not allowing them to stray too far beyond the message. The loop goes a step further by authorizing a swarm of agents to work continuously in the background, without ceasing. That’s a lot of trust to put in AI, but as models improve rapidly, it could be the next step in getting AI to handle the real work.
The first thing to recognize is that this is not entirely new. Recursive loops (functions that call themselves to repeat an action, along with a condition that stops the loop) are a mainstay of introductory computer science courses. These loops follow non-deterministic logic (i.e. it is a subagent that chooses when to stop the loop rather than a clear condition), but the same basic approach applies. As soon as programmers started using AI to complete tasks, some version of the recursive loop was sure to emerge, with AI supervising AI.
Unlike classical computing, agent loops can be maddeningly simple. One of the most popular tricks is ralph loop (named after Ralph Wiggum), which basically summarizes all the work the model has done and asks if it has achieved its goal. It’s a way to deal with AI models getting lost when they run for too long; Essentially, the model bounces back and forth until the task is completed.
Another way to think about loops is as part of the overall push to achieve more compute at test time. As OpenAI researcher Noam Brown observed earlier this monthContemporary models can solve almost any problem if enough computing is applied to them. That means that one way to ensure that a problem is solved is to keep applying computing to it until it is finished. This is particularly true for escalation problems, such as improving a codebase, where the model can continue to make incremental improvements until a certain threshold is reached. Or, as in Cherny’s example, you can keep making incremental improvements as long as there is compute to spend on it.
If that sounds expensive, it should be. Like agent AI above, AI loops consume tokens much faster than simple question-and-answer chatbots, and since the goal is to keep the loop running all the time, there’s no limit to how much you can spend. That’s fine for Anthropic, which is ultimately in the token sale business, but for everyone else, it can be an expensive way of working.
Still, depending on the problem the agent loop is trying to solve and the right setup that allows monitoring of token spending, drift, and other classic AI problems, the benefits could be staggering enough to outweigh the costs.
When you purchase through links in our articles, we may earn a small commission. This does not affect our editorial independence.