The agent loop, also called the perceive-plan-act loop, is the repeated cycle where an AI agent observes its situation, decides what to do next, and then takes an action.
This is the basic control pattern behind many agentic systems. Instead of asking a model for one one-off answer, you let it keep checking the world, updating its plan, and acting until the task is done or it should stop.
You reach for it when the task is dynamic, multi-step, or depends on intermediate results: calling tools, browsing, querying databases, drafting, revising, or recovering from errors. In practice, most teams start with a simple loop before adding more complex orchestration.
A typical loop has three stages:
Perceive
The agent gathers inputs: the user request, prior messages, tool outputs, environment state, or sensor data. In LLM-based agents, this often means reading the conversation plus the latest tool result.
Plan
The agent decides what to do next. This may be a full plan or just the next step. The decision can be produced by a model prompt, a policy, or a hand-built controller.
Act
The agent executes the chosen action: call a tool, write a message, update memory, trigger a workflow, or ask a follow-up question.
Then the loop repeats. The action changes the environment, which creates new observations, which may change the plan. That feedback cycle is the core idea.
A useful way to think about it: perception tells the agent what is true now, planning chooses a next step, and action makes the world different.
User: “Find the latest invoice total for Acme and email it to me.”
A simple agent loop might look like:
Invoice total = $12,480.The loop stops when the task is complete, the agent hits a limit, or a human must intervene.
The main design question is whether the task benefits from iterative feedback. If not, keep it simpler.