Articles

The agent action loop and how it stops

The loop is the mechanism; the stopping condition is the control that bounds it.

Reading: 4 minAutomation & AI

Article cover: The agent action loop and how it stops

An agent is not a single model call; it is a model calling tools and reading their results until something tells it to stop. Anthropic draws the line this way: agents “are systems where LLMs dynamically direct their own processes and tool usage”, and in practice an agent is “typically just LLMs using tools based on environmental feedback in a loop.”

Because the loop is model-driven, nothing inside it decides when to quit. The stopping condition is a separate decision, and Anthropic says so plainly: the task “often terminates upon completion, but it’s also common to include stopping conditions (such as a maximum number of iterations) to maintain control.” This sheet is about that loop and the conditions — model-chosen and operator-imposed — that end it.

One turn: thought, action, observation

The pattern was named by the ReAct paper: “At time step t, an agent receives an observation ot” from the environment and “takes an action at” following a policy. Its contribution was to put reasoning inside that step; ReAct “prompts LLMs to generate both verbal reasoning traces and actions pertaining to a task in an interleaved manner.”

A thought is not an action. The paper is precise: a thought “does not affect the external environment, thus leading to no observation feedback” — it only updates the model’s own context. So a turn is a small sequence: the model writes a thought, emits an action (a tool call), the environment returns an observation, and the next decision is read off the trajectory so far. Anthropic stresses why the observation earns its place: it is “crucial for the agents to gain ‘ground truth’ from the environment at each step (such as tool call results or code execution) to assess its progress.” The loop is what makes a static model react to the real state of the world rather than its own first guess.

Two ways a loop ends

The first is completion. ReAct’s action space includes “(3) finish[answer], which would finish the current task with answer” — an action whose only effect is to end the trajectory. A modern runtime reaches the same end when the model answers instead of calling a tool: OpenAI’s Agents SDK “loops over the LLM until either” “A final-output tool is invoked” or “The model returns a response without any tool calls”, and the guide calls this “a while loop” that is “central to the functioning of an agent.”

The second is a bound. Anthropic’s “maximum number of iterations” is a stop imposed from outside the model. It is the only exit that does not depend on the model being right — which is exactly why it holds when completion never arrives.

When completion never arrives

The failure the bound guards against is documented in ReAct: “there is one frequent error pattern specific to ReAct, in which the model repetitively generates the previous thoughts and actions, and we categorize it as part of ‘reasoning error’ as the model fails to reason about what the proper next action to take and jump out of the loop.” A model repeating its own last steps will not converge on finish[answer]. Without an external bound it continues until something else ends it — a timeout, a cost ceiling or a permission check. A bound is not a formality wrapped around the loop: it is the control for the bad path, and it should be chosen deliberately rather than discovered in production.

Stopping is not always finishing

A stop can be a pause rather than an end. ReAct showed the pause already: human-in-the-loop interaction lets a person “inspect and edit ReAct’s reasoning traces”, changing the trajectory mid-loop. In graph-based runtimes the pause is a mechanism rather than a manual edit — an interrupt can “pause graph execution at specific points and wait for external input before continuing”, and the run is then expected to “resume after an interruption”. The consequence: a completion stop closes the work; a pause stop suspends it with its state intact, and resuming belongs to the state and checkpoint sheet of this layer. An agent that has merely paused has not finished.

What to keep

The loop is the agent’s mechanism, and its exit is a decision the builder makes, not a property the model has. Completion stops are the model’s answer; bound stops are the operator’s guarantee. A system needs both — a finish condition for the ordinary case and a bound for the case where the model never reaches it — and pausing for a human is a third stop. None of the three is automatic; each has to be named, chosen and tested.

Level and prerequisites. L4 — the advanced layer of the area, where the pieces named in the earlier sheets are assembled into a running control loop and the reader must reason about what keeps it bounded. Prerequisites: the L1 sheets on how a model generates text and what a context window is, the L2 sheet on tool calling and structured output, and the L3 sheet of this area that separates chatbots, workflows and agents, which fixes the vocabulary this sheet leans on.

Where to go next

References

  • Anthropic — Building effective agents — the definition of agents versus workflows, the environmental-feedback loop, and the maximum-iterations stopping condition.
  • Yao et al. — ReAct: Synergizing Reasoning and Acting in Language Models — the thought-action-observation step, the non-environmental thought, the finish[answer] action and the repetitive-loop failure mode.
  • OpenAI — A practical guide to building agents — the run loop and its two exit conditions.
  • LangChain — LangGraph persistence — the pause-and-resume stop, distinguished from completion.
Nodrius Field Kit — cover

Get the Nodrius Field Kit

Enter your email and we'll send you the complete Field Kit: eight technical resources in one download.

Your email address is sent to Nodrius and used to deliver the Field Kit to you by email. Marketing messages are separate and optional: the checkbox does not affect your download, and you are only added to our updates list if you tick it. Privacy Policy.

Privacy & cookies

This site does not use cookies, analytics or tracking, and it does not profile you. There is nothing technical to switch off, so Accept and Reject change nothing about how the site works: either choice lets you browse everything normally.

The only difference is what your browser remembers: two entries in local storage — your choice here, so this notice is not shown again, and a marker that the Field Kit offer has already been made — so the offer is presented once and not on every page. They contain no identifier, they are not shared with anyone, and the site sets no cookie for either.

What we do with your data
How your email address is used when you ask for a Resource, how long it is kept and which rights you have — in the Privacy Policy.
What the site stores in your browser
Two entries in local storage — your choice on this notice and whether the Field Kit offer has been shown — and no cookies, no session storage, no third-party content: in the Cookie Policy.