
Agent Loop
An agent loop is a repeated process in which an AI program thinks, performs an action, looks at the result, and then plans the next step based on it. This loop continues until the task is completed or a limit is reached.
A chat program usually responds once and is then done. An agent loop makes more out of it. The program first considers what to do. Then it carries out a step, for example a search on the internet. Afterward it reads the result and decides anew how to proceed. These four stages repeat until the goal is reached. This very repetition is called a loop. A program that works this way is referred to as an agent.
Why it matters
Many tasks cannot be solved in a single pass. “Find the cheapest flight to Lisbon and put it in my calendar” requires several steps. Some steps depend on the result of the previous ones. Only once the price is known can you compare. A single response pass cannot manage that.
The loop also allows for self-correction. If a step fails, the model sees the error message and tries a different approach. That is why this design is considered the most important step from pure chat programs to software that actually gets work done. A large share of current AI products in the enterprise sector is built on it.
How it works
The loop consists of four phases that alternate. In the planning phase, the language model formulates which step makes sense next. Then it selects a tool. Tools are previously approved functions, such as a search engine, a calculator, or access to files. The execution is not carried out by the model itself, but by the surrounding program. It calls the tool and sends the result back.
This result is appended to the conversation history so far. So in the next pass, the model sees everything that has already happened. This carried-along history is the agent’s memory. At the end of each round, the program checks whether the goal has been reached. If so, it outputs the answer. If not, the next round begins.
Without a brake, this would be risky. That is why upper limits are set: a maximum number of rounds, a cost limit, or a time limit. Otherwise an agent can get caught in an endless loop and repeatedly attempt the same unsuccessful step. For sensitive actions such as deleting data or making a payment, human confirmation is often built in.
Where you encounter the term
Coding assistants such as Claude Code or Cursor work this way. You describe a change, the tool reads files, writes code, runs tests, and reacts to error messages. The research features of large chat services, often called “Deep Research”, also run as an agent loop over many minutes and dozens of websites.
In finance and tech reports, two figures keep coming up. First, the success rate for multi-step tasks, since small errors per step add up over many rounds. Second, the cost, because every round means a new model call. An agent can consume a hundred times as much computing power for a single task as a normal chat response. When providers talk about “agentic AI”, they almost always mean exactly this process.