TL;DR
ReAct prompting asks a language model to write its work in three kinds of lines: a Thought (free-form reasoning), an Action (a call to an outside tool, such as a search), and an Observation (what the tool returned). The lines alternate until the model writes a final answer. Because the model sees what each action returned, it can catch a bad fact or a failed search and change its plan, which a model reasoning alone cannot do.
Where you'll see it: the tool-using agents that answer questions by searching the web, the browsing and shopping agents that click through websites, and the agent loops built on frameworks that log every thought before each tool call.
Intuition
A detective with a notebook
Picture a detective asked a question about a historical event. She can think hard in her head, but she can also walk to the archive, look something up, and read what she finds. A good detective writes down what she wants to know, goes to get it, and then decides what to ask next based on what came back. A bad one either guesses from memory or keeps fetching the same file without thinking.
Chain-of-thought prompting (chain of thought) gives a model the first kind of work: it writes out its reasoning and then answers. That helps on arithmetic and logic, but everything the model "knows" comes from its weights, which were fixed at training time. If a fact is wrong or missing, the reasoning builds on the error and the model has no way to look again.
ReAct, from the paper of the same name, gives the model the second kind of work as well. The model is allowed to act on the world, and the world answers back. The name is short for Reasoning and Acting. The core claim is that the two help each other. Reasoning tells the model what to look up next and when it has enough. Acting brings in facts that the reasoning can then use.
flowchart LR T[Thought: what do I need next?] --> A[Action: search or lookup on a tool] A --> O[Observation: what the tool returned] O --> T T -->|enough information| F[Finish: final answer]
The loop is the whole mechanism. Nothing about it requires training a new model. It is a prompt: a few worked examples in which a person has typed the thoughts, actions and observations by hand, followed by the new question. The model continues the pattern.
Why the observations matter
A plain reasoning trace is a closed system. Each token is chosen from what the model already wrote, so one wrong step tends to be carried forward into every later step. An observation breaks that closure. It is text that the model did not generate, which arrives mid-trace and can contradict what the model was about to say. The model is then conditioned on evidence it could not have invented.
This is also why ReAct traces are easier to read. The trace is a log of questions asked, answers received and conclusions drawn, so a person can see where it went wrong.
The math
ReAct is a prompting method rather than a new model, so the mathematics is a way of writing down what the model is conditioned on at each step. Following the paper, treat the task as an agent interacting with an environment. At step the agent sees an observation and chooses an action according to a policy . The context is everything so far:
Here is what the environment shows the agent at step , is the action it takes, and is the rule that picks the action given the context. The policy is simply the language model's next-token distribution, read off at the point where an action should be written.
The action space gains a language part
ReAct enlarges the set of things the agent may write. Let be the set of actions that change the environment, such as a search query or a click. Let be the set of all possible strings of language. The extended action space is
An element is a thought. A thought does not change the environment, so it produces no observation from outside. Its only effect is to extend the context:
Because the thought is now part of the context, every later step can read it. That is the mechanism by which reasoning steers acting. In the paper's terms, the agent can reason to act (a thought picks the next search) and act to reason (an observation supplies a fact the thought then uses).
What the prompt contains
For a question-answering task the paper uses three action types against a simple Wikipedia interface: search[entity] returns the first five sentences of an entity's page, or a list of the top five similar entities if the page does not exist; lookup[string] returns the next sentence containing a string, like Ctrl+F; and finish[answer] ends the episode. A ReAct exemplar is a complete trace in this format, with the thoughts written out by a person. For HotpotQA the paper uses six such exemplars and for FEVER three.
The thoughts in those exemplars do specific jobs. The paper lists several: decomposing the question ("I need to search x, find y, then find z"), extracting facts from observations ("x was started in 1844"), doing small arithmetic ("1844 < 1989"), suggesting a new search when the old one failed, and synthesising the final answer.
Worked examples
This trace is illustrative. It is written in the ReAct format, but it is not output from the paper's experiments. The question is: "Which came first, the instrument or the company that built it?" The tool returns the start of each Wikipedia page it is asked about.
- Thought: I need the start date of the company, then the date of the instrument.
- Action:
search[Acme Organ Works] - Observation: Acme Organ Works was founded in 1868 in Ohio.
- Thought: The company started in 1868. Now I need the instrument's date.
- Action:
search[Acme Organ No. 3] - Observation: The Acme No. 3 organ was completed in 1871.
- Thought: 1868 is earlier than 1871, so the company came first.
- Action:
finish[the company]
Interpretation: the answer is supported by two observations, and each step can be checked against the one before. If the second search had returned "page does not exist, similar entities: ...", the next thought would have to change the query. That is the feedback a pure reasoning trace does not get.
The paper uses PaLM-540B on HotpotQA (exact match, EM, in percent) and FEVER (accuracy, in percent). The rows that matter here are:
| Method | HotpotQA EM | FEVER accuracy |
|---|---|---|
| Standard (no reasoning, no acting) | 28.7 | 57.1 |
| CoT (reasoning only) | 29.4 | 56.3 |
| Act (acting, no thoughts) | 25.7 | 58.9 |
| ReAct | 27.4 | 60.9 |
| CoT-SC (self-consistency over CoT) | 33.4 | 60.4 |
On FEVER, ReAct beats CoT by points. On HotpotQA it is slightly behind, points. Read on its own, ReAct is not the winner on HotpotQA.
The reason the paper gives is in its failure analysis. The authors hand-labelled 50 correct and 50 incorrect trajectories for each of ReAct and CoT. Among CoT's failures, 56 percent were hallucinated facts. For ReAct the hallucination share of failures was 0 percent, but its failures were more often reasoning errors (47 percent) and uninformative searches (23 percent). Interpretation: acting makes the model more grounded and less flexible. The paper's combined systems do best: ReAct falling back to CoT-SC reaches 35.1 EM on HotpotQA, and CoT-SC falling back to ReAct reaches 64.6 accuracy on FEVER.
On ALFWorld, a text game where the agent must carry out household tasks such as putting a cleaned object somewhere, the paper compares the best of six trials of each method. Act-only reaches a success rate of 45 percent. ReAct reaches 71 percent. The relative gain is
so about 58 percent more tasks are completed. The paper reports that ReAct beats Act in each of its six controlled trials, with relative gains from 33 to 90 percent and an average of 62 percent.
The same pattern appears on WebShop, where the agent must buy a product that matches an instruction. There, one-shot ReAct gains an absolute 10 points over the previous best method, which the paper attributes to reasoning about which products and options match the instruction. Interpretation: when an environment is long and the goal has many parts, a written plan that gets updated is worth more than reacting to each observation alone.
Tradeoffs and failure modes
ReAct is useful when the answer depends on information the model does not have, or when the task has many steps that need to be kept in order. It is less useful when the model already knows the answer, because every extra step costs time and tokens and gives the model another chance to go wrong.
| Situation | What goes wrong | Better choice |
|---|---|---|
| The question needs a fact from a source that changes over time | The model answers from stale weights and states them confidently | ReAct, or retrieval (see [[retrieval-augmented-generation |
| A simple factual question inside the model's training | Extra searches add cost and noise, and a bad search can derail the trace | Plain prompting or [[chain-of-thought-prompting |
| A search returns nothing useful | The model repeats the same query or invents a result | Limit the step count, add a rule to rephrase the query, or back off to a non-acting method |
| The model loops, repeating earlier thoughts and actions | Tokens are spent without progress | Step limit, loop detection, or a sampling method other than greedy decoding |
| Thoughts are hallucinated | A plausible but false claim enters the context and then drives the actions | Human correction of a thought, or check the claim against an observation |
The paper's own answer to the trade-off is a fallback rule. ReAct backs off to self-consistency over CoT (CoT-SC) when it fails to answer within a step budget (7 steps on HotpotQA, 5 on FEVER), and CoT-SC backs off to ReAct when fewer than half of its sampled answers agree. Both directions come from the same observation: acting protects against hallucination, while free reasoning handles structure that the action space does not capture.
There is also a deeper failure mode. The loop is only as good as the environment. In the paper's setup the Wikipedia interface returns only the first five sentences of a page, or a short list of similar entities, and the authors found that a search returning nothing useful (23 percent of ReAct's sampled failures) derailed the reasoning. The agent is then limited by its tools, not only by its reasoning.
History
ReAct was introduced by Shunyu Yao and colleagues in a 2022 preprint, and the work was later published at a major machine-learning conference in 2023. It came in the same period as chain-of-thought prompting, which Wei and colleagues had shown in 2022 could make language models reason in steps. The question the ReAct authors asked was what happens when the steps can touch the outside world.
Before ReAct, language-model agents that acted on environments were usually trained with imitation or reinforcement learning on large numbers of episodes. The paper's claim was that a frozen model with a handful of hand-written examples could already act sensibly, provided it was also allowed to write its reasoning. The method caught on because it needed no training, its traces could be read by people, and it was easy to adapt to a new task by writing new examples. Later agent frameworks borrowed the thought, action and observation loop almost unchanged.
Check yourself
QuestionRecall: what are the three kinds of line in a ReAct trace, and what does each one do?Show answer
A Thought is free-form reasoning that does not change the environment; it updates the plan and the context. An Action is a call to an outside tool or environment, such as a search or a click. An Observation is the text the tool returns, which the model did not write and which is added to the context for the next step.
QuestionComputation: on FEVER, ReAct scores 60.9 and CoT scores 56.3. On HotpotQA, ReAct scores 27.4 and CoT scores 29.4. What is the difference in points on each task, and which task does ReAct win?Show answer
On FEVER the difference is points in ReAct's favour. On HotpotQA it is points, so ReAct is 2.0 points behind CoT. ReAct wins FEVER and loses HotpotQA. The paper's explanation is that FEVER claims depend on up-to-date facts that a search can supply, while HotpotQA failures in ReAct were often due to rigid step structure and weak search results.
QuestionWhy? The paper finds CoT hallucinates much more often than ReAct, yet ReAct makes more reasoning errors. What causes each pattern?Show answer
CoT has no access to outside facts, so when it lacks a fact it can invent one and then reason correctly from the invented fact. ReAct grounds its claims in observations, so it hallucinates less. But ReAct must fit its reasoning into a fixed alternation of thoughts and actions, and a bad search or a repeated loop leaves it with no way to recover, which shows up as reasoning error. The structure that protects against invention also limits flexibility.
QuestionApplied: you are building a support agent that answers questions about a product's current pricing from a database, and its first search returns an empty result. Using ReAct, what should the next thought do, and what guard should stop the loop?Show answer
The next thought should say that the search returned nothing useful and propose a different query, such as a shorter product name or a synonym, rather than repeating the same action. The guard is a step limit: after a fixed number of steps, such as the paper's seven steps on HotpotQA, the agent should stop acting and either back off to a non-acting method or tell the user it could not find the price. Without a limit the agent can loop, repeating earlier thoughts and actions without progress.
Sources
- Yao et al., ReAct: Synergizing Reasoning and Acting in Language Models, 2022.
- Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, 2022.
- Yao et al., WebShop: Towards Scalable Real-World Web Interaction with Grounded Language Agents, 2022.
- Shridhar et al., ALFWorld: Aligning Text and Embodied Environments for Interactive Learning, 2020.