PaPoo
cover

What is the agent loop (perceive-plan-act)?

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.

Why it matters

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.

How it works

A typical loop has three stages:

  1. 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.

  2. 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.

  3. 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.

Tiny concrete example

User: “Find the latest invoice total for Acme and email it to me.”

A simple agent loop might look like:

The loop stops when the task is complete, the agent hits a limit, or a human must intervene.

Common pitfalls / when NOT to use it

The main design question is whether the task benefits from iterative feedback. If not, keep it simpler.

Related terms

同じ著者の記事