LEARN · 5 MIN
What is an agent loop?
The 30-second and five-minute answer.
A loop repeats work until a condition says it is done. An agent loop is an agent repeating the same shape: look at the job, decide the next step, act with a tool, check the result, then repeat until the goal is met or there is no useful work left.
while True:
state = look_at_the_job()
step = decide_next_step(state)
if step is None:
break
result = act_with_a_tool(step)
if check_result(result):
breakOne model call can answer a question. A loop can carry work across many passes. It remembers what happened, chooses what to do next, and keeps checking whether the work is finished.
That is why the loop, not the single call, is the working system. The model supplies judgment. The loop supplies control: what happens next, what gets checked, when to ask a human, and when to stop.
In programming, a loop is control flow. In the AI industry, an agent loop is the model and tools cycle that lets an agent pursue a goal over multiple steps. Simon Willison's short definition, an LLM agent runs tools in a loop to achieve a goal, is a definition of the agent. The loop is the engine inside it.
Sources: Simon Willison, Anthropic Building Effective Agents, ReAct.