The Agent Loop: How AI Agents Plan, Act and Check Their Work

Plants.work · · upskilling
The Agent Loop: How AI Agents Plan, Act and Check Their Work

How the Plan, Act, Observe cycle lets AI Agents handle multi-step work, with a procurement example, stop conditions and risks to watch.

Imagine typing this to an AI: "Check A4 paper stock at every branch. If any branch has fewer than 20 reams, request quotes from 3 suppliers and summarise them for me." A regular chatbot replies with a paragraph of advice. An AI Agent gets to work: it opens the stock file, reads the numbers, decides what to do next, and repeats until the job is done. The engine behind that behaviour is called the Agent Loop.

If the word Agent is still new to you, start with What is an AI Agent. This article goes one level deeper, into how an agent thinks, acts and checks its results on every round.

What is the Agent Loop

The Agent Loop is a cycle the AI repeats in three beats: Plan (decide the next step), Act (call a tool) and Observe (read what came back). It then uses that result to plan the next round, until it decides the task is complete or hits a stop condition.

The idea became widely known through the research paper ReAct: Synergizing Reasoning and Acting in Language Models (Yao et al., 2022), which had the model alternate between writing out its reasoning and taking actions. The paper reports that this approach beat earlier methods by an absolute success rate of 34% on ALFWorld and 10% on WebShop.

The three beats of each round

1. Plan: decide the next step

The model reads the goal, the history of what it has done, and the latest result, then chooses what to do next, for example "I need to read the stock file first".

2. Act: call a tool

The model does not run anything itself. Claude's tool use documentation is explicit: the model only emits a structured request (a tool name plus arguments), and your code or the provider's servers actually run it. The result is then fed back into the conversation. For the mechanics, read What is Tool Calling.

3. Observe: read the truth from the environment

Anthropic's Building effective agents (December 2024) stresses that at each step an agent should get "ground truth" from its environment, such as tool results or code execution output, to judge whether it is really making progress rather than guessing.

Example: how many rounds does one procurement task take

Back to the A4 paper request. A real loop might look like this:

  1. Plan: I need stock levels → Act: read Google Sheets → Observe: the Bang Na and Khon Kaen branches are below the threshold
  2. Plan: find suppliers we have bought from → Act: search the procurement system → Observe: 3 suppliers found, but one has no email address
  3. Plan: request quotes from the 2 with email, and note that the third needs a phone call → Act: draft emails → Observe: drafts ready, but not sent because this is external communication
  4. Plan: everything I can do myself is done → summarise and ask you for approval before sending

Notice that the plan changed in round 2 because of what the agent observed. That is the advantage of a loop. And in round 3 the agent paused for a human before doing something that cannot be undone.

A loop must know when to stop

An agent without stop conditions can run forever, so good systems define several exits:

When you do not need a loop

Anthropic separates workflows (steps predefined in code) from agents (the model chooses its own steps) and recommends starting with the simplest solution that works. If your task always follows the same order, such as receive a file, convert it, pass it on, a plain workflow is cheaper and more predictable. More in AI Assistant vs AI Agent vs Agent Platform.

Watch out for

A good agent is not the one that thinks best. It is the one that checks real results every round and knows when to stop.

How to get started

  1. Pick a task that genuinely needs decisions along the way, not one with fixed steps
  2. Write the goal and a clear definition of "done"
  3. Give it only the 2 or 3 tools it really needs in the first version
  4. Set Max Iterations and the points where a human must approve
  5. Turn on intermediate steps every time you test, so you can see what the agent thought and did each round

Once the loop makes sense, the next step is to build one. The n8n AI course on Plants.work Learn is a good place to start, and if you want to know which career paths this skill opens up, try the AI Career Assistant.