Agent Loop
The agent loop is the core execution cycle where the agent reasons about the current state, selects an action, executes it, observes the result, and repeats until the task is complete.
What is Agent Loop?
The agent loop is the core execution cycle where the agent reasons about the current state, selects an action, executes it, observes the result, and repeats until the task is complete.
The agent loop is the core execution cycle where the agent reasons about the current state, selects an action, executes it, observes the result, and repeats until the task is complete.
Where is it used?
ReAct, LangGraph, and AutoGPT all implement a loop; the loop terminates when the LLM emits a final answer or a max-iteration guard triggers to prevent runaway agents.
How to build it
Implement `for step in range(max_iter): response = llm(messages); if no tool_calls: break; execute and append results` — this is the minimal agent loop in pure Python.
Further reading
Want to go deeper? These resources cover Agent Loop in more detail: