
How the ReAct Loop Works: Reason Act Observe and Recover
August 22, 2026An AI chatbot responds to a message. An AI agent pursues a goal through a sequence of decisions, observations and actions. The distinction is not intelligence in the abstract; it is the operating loop around the model.
OpenAI describes an agent in terms of a model, tools and instructions. Anthropic uses a similarly practical definition: a model that can use tools in a loop with some control over how it reaches the goal. Both definitions point away from the popular image of a digital employee and toward a software system with explicit interfaces.
The four parts of a useful agent
1. A model interprets the task, selects the next step and produces structured decisions. A stronger model may handle more ambiguity, but it does not remove the need for constraints.
2. Context is the information visible at the current step: instructions, user input, tool definitions, retrieved evidence, prior observations and current state. Context is working memory, not the whole knowledge base.
3. Tools let the system read or change the environment. Search, database queries and file inspection are perception tools. Sending a message, editing a record or running code are action tools.
4. A harness runs the loop around the model. It validates arguments, enforces permissions, stores state, requests approval, records traces, handles timeouts and decides when the task is complete.
This is why an agent is not simply “an LLM with a long prompt.” The surrounding software determines what the model can observe and what consequences its outputs may have.
A small example
Consider an invoice-review assistant. A chatbot can explain an invoice pasted into a conversation. An agent can retrieve the invoice, compare it with an approved purchase order, flag a mismatch and prepare a review record. If it can also approve payment, the system crosses into a much higher-risk category.
The model may be identical in both versions. What changes is the action space and therefore the required control.
Workflow or agent?
A deterministic workflow follows a predefined path. An agent selects the path dynamically. Use a workflow when the steps are known, inputs are structured and failures are predictable. Use an agent when the task requires exploration, tool choice or adaptation to intermediate results.
Many reliable systems combine the two: the agent handles interpretation and research, while code owns calculations, permissions and irreversible state changes.
What an agent is not
An agent is not automatically autonomous, trustworthy or persistent. It may operate only in read-only mode. It may require approval for every external action. It may forget everything after the session unless state is deliberately stored.
Avoid the agent label when a direct model call, search query or script solves the problem. Every loop adds latency, cost and additional failure paths.
A design checklist
Before building, write down:
- the goal and completion condition;
- information the agent may read;
- tools it may call;
- actions that require confirmation;
- time, cost and retry limits;
- evidence retained for review;
- recovery when the model is wrong.
The architecture becomes clear when authority is described as precisely as capability. Continue with How the ReAct Loop Works, AI Agent Tools and MCP and AI Agent Safety.
Primary sources
Adaptation note: This article was informed by the architecture presented in AI Agents in Depth: Design Principles and Engineering Practice by Bojie Li and contributors, Apache License 2.0. Its structure, language, examples and conclusions were independently developed and expanded for Stariy.com.



