What is a ReAct agent? The reason and act loop

Also called ReAct, ReAct prompting, reason and act

Definition

A ReAct agent is an AI agent that alternates a written reasoning step, an action such as a tool call, and an observation of the result, repeating the cycle until it can answer.

A ReAct agent is an AI agent that cycles through three steps: a thought, an action, and an observation. The pattern comes from ReAct: Synergizing Reasoning and Acting in Language Models (Yao et al., 2022), which prompted a language model to write free-form reasoning between actions such as Wikipedia searches. The written reasoning lets the model plan, track progress, and change course when an observation contradicts its plan. Most current agent loops descend from this design, although few still use the paper's text format.

How a ReAct agent works#

A ReAct agent works by repeating a thought, an action, and an observation. The thought states what the model knows and what it should do next. The action calls a tool, such as a search. The observation is the tool's result. All three are appended to the context, and the loop continues until the model emits a finish action.

In the paper, the authors prompted a frozen PaLM-540B model with a few human-written example trajectories: six for the HotpotQA question-answering task and three for FEVER fact checking. The HotpotQA agent had three actions:

search[entity]   returns the first five sentences of the entity's Wikipedia page
lookup[string]   returns the next sentence on the page that contains the string
finish[answer]   ends the task with an answer

Thoughts do not touch the environment, so they produce no observation; they only update the context. The authors report that ReAct beat imitation and reinforcement learning baselines by 34 and 10 absolute points of success rate on the ALFWorld and WebShop decision-making tasks. Its documented failures include loops that repeat earlier thoughts and actions, and uninformative searches, which made up 23% of the errors the authors examined.

ReAct vs native tool calling#

ReAct is a prompting pattern, while native tool calling is an API feature. The original ReAct agent wrote its actions as plain text that the application had to parse, so one malformed line could break the loop. With native tool calling, the model returns a structured call with JSON arguments, and the API keeps it separate from prose.

ReAct prompting (2022) Native tool calling
Action format Text such as search[entity], parsed by the application A structured call with JSON arguments
How the model learns the format Example trajectories in the prompt Training, plus tool schemas sent with each request
Reasoning step A written thought before every action Optional; reasoning models reason internally
Typical failure Action text the parser cannot read Invalid arguments, caught by schema validation

The loop itself survives inside modern frameworks. DSPy's ReAct module is documented as an agent that interleaves reasoning and tool calls to fulfill a signature, and it ends when the model calls a submit tool or the turn budget runs out. LangGraph's prebuilt agent was named create_react_agent until LangGraph v1 deprecated it in favor of LangChain's create_agent.

When to use the ReAct pattern#

Use the ReAct pattern when a task needs information the model lacks and each step depends on what the previous one found, as in multi-hop question answering. When the steps are known in advance, a fixed workflow is cheaper and easier to test. The written thoughts make runs easier to audit, because every action arrives with a stated reason.

The paper credits that visible reasoning with improved human interpretability and trustworthiness. The authors also tested a fallback to chain-of-thought self-consistency when ReAct runs out of steps, and concluded that combining the model's internal knowledge with retrieved knowledge helps on reasoning tasks.

The AI agent frameworks comparison shows how current frameworks implement the loop, and what AI agents are covers where it fits in agent design.

Cite this definition

The AI Engineering Editors. "What is a ReAct agent? The reason and act loop." The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/react-agent

Title
What is a ReAct agent? The reason and act loop
Author
The AI Engineering Editors
Publisher
The AI Engineering
Updated
View as Markdown

Part of the AI agents hub · Updated