ReAct: Synergizing Reasoning and Acting in Language Models
- Publication
- ICLR 2023Conference
- First submitted to arXiv
- arXiv:2210.03629
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{transformersreact2022,
title = {{ReAct: Synergizing Reasoning and Acting in Language Models}},
author = {Shunyu Yao and Jeffrey Zhao and Dian Yu and Nan Du and Izhak Shafran and Karthik Narasimhan and Yuan Cao},
year = {2022},
eprint = {2210.03629},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2210.03629}
}
In 2022, Chain-of-Thought (CoT) showed everyone that asking a large language model to “think step by step” noticeably improves its arithmetic and commonsense reasoning.
But CoT does all its thinking inside its own head.
The model relies on knowledge stored in its parameters. If it misremembers a fact halfway through, every subsequent step builds on that mistake, eventually producing a very orderly argument for the wrong answer.
Meanwhile, other research let language models act in an environment, such as planning robot movements, clicking buttons on a web page, or calling a search engine. Most of those approaches predicted actions without giving the model much room to pause and think about the situation.
This paper from Princeton University and Google Research's Brain team proposes alternating the two, so the model can think a step, take an action, observe the result, then think about the next step. The authors call it ReAct, combining Reasoning and Acting.
It is also one of the starting points most often cited in the history of agents that look things up for themselves.
Defining the Problem
Start with the paper's motivating example. The question comes from HotpotQA, a multi-hop question-answering dataset that requires combining information from multiple Wikipedia sources:
Aside from the Apple Remote, what other device can control the program Apple Remote was originally designed to work with?
To answer, you first need to find the program Apple Remote was designed for, then look up what else can control it.
The authors have the model answer in four ways:

(1a) Standard: It answers “iPod” directly. Wrong.
(1b) CoT: The model starts reasoning step by step: “Apple Remote was originally designed for Apple TV; Apple TV can be controlled with an iPhone, iPad, and iPod Touch.” The reasoning flows smoothly, but the first statement is wrong. The red portions are hallucinations. Naturally, the answer is wrong too.
(1c) Act-Only: Search without reasoning. The model searches for Apple Remote, then Front Row, and even finds “Front Row (software).” But it cannot turn these observations into an answer. It eventually answers “yes.”
(1d) ReAct:
- Thought 1: I need to search for Apple Remote and find out which program it was originally designed for.
- Act 1:
Search[Apple Remote] - Obs 1: Apple Remote is a remote control introduced by Apple in 2005… originally designed to control the Front Row media center program.
- Thought 2: It was designed for Front Row. Next, search for Front Row to find what else can control it.
- Act 2:
Search[Front Row] - Obs 2: [Front Row] was not found. Similar entries: “Front Row Seat to Earth,” “Front Row Motorsports,” “Front Row (software)”…
- Thought 3: Front Row was not found. I'll search for Front Row (software) instead.
- Act 3:
Search[Front Row (software)] - Obs 3: Front Row is a discontinued media center application…
- Thought 4: Front Row (software) can be controlled with Apple Remote or keyboard function keys. So the answer is keyboard function keys.
- Act 4:
Finish[keyboard function keys]
Correct.
Compared side by side, the four approaches each get stuck in a different place:
- Thinking without checking (CoT) can lead the model astray through misremembered facts.
- Checking without thinking (Act) can retrieve information without knowing how to use it.
The authors want to know whether interleaving reasoning and action can make up for the weaknesses of each.
Solving the Problem
Treating Thought as an Action
The authors first describe the problem in an agent framework.
At time , the agent receives an observation from the environment and chooses an action based on the context so far, .
ReAct's idea is to expand the action space to include language.
contains the original actions that affect the environment, such as search; is the language space. An “action” selected from is a thought.
A thought does not change the environment, so it produces no new observation. Its role is to organize the current context and write the result back into it for the next step:
In the example above, thoughts serve several purposes, including breaking down the problem (Thought 1), extracting key facts from observations (Thoughts 2 and 4), adjusting the plan after an exception (Thought 3), and assembling the final answer (Thought 4).
A Minimal Wikipedia Tool
For the two knowledge tasks, HotpotQA and FEVER, the authors design a very basic Wikipedia API with just three actions:
search[entity]: If the entry exists, return the first five sentences of the page. Otherwise, list the top five similar entries found by the search engine.lookup[string]: Return the next sentence on the current page containing that string, much like Ctrl+F in a browser.finish[answer]: Submit the answer and end the task.
The authors emphasize that these actions generally retrieve short passages using exact entity names, making them much weaker than the best lexical or neural retrievers of the time. This is deliberate, because they want to imitate how people browse Wikipedia and make the model use language reasoning to decide what to look up.
FEVER is a fact-verification dataset in which each claim is classified as “supports,” “refutes,” or “not enough information.” For both tasks, the model receives only the question or claim, without any reference passages.
How Do You Get the Model to Do This?
The main experiments train no new model. They use a frozen PaLM-540B with only a few demonstrations in the prompt.
The authors randomly choose six HotpotQA questions and three FEVER claims from the training sets, manually write complete thought–action–observation trajectories, and include them as examples. They also report that adding more examples did not help.
At inference time, it runs as a loop. The model continues the prompt with this step's thought and action and stops just before “Obs”; the program then actually runs the search and appends the result to the prompt as the observation, and the model writes the next step. The loop ends when the model writes finish or runs out of steps. The observations come from the environment; the model does not make them up.
When Should It Trust Itself?
While analyzing the results, the authors find that ReAct and CoT have different strengths, with ReAct more grounded in facts and CoT better at organizing a reasoning structure.
They therefore design two hybrids. Here CoT-SC is the self-consistency version of CoT, which samples 21 reasoning paths at temperature 0.7 and takes the majority answer.
- ReAct → CoT-SC: If ReAct cannot answer within the step budget, fall back to CoT-SC. HotpotQA allows seven steps and FEVER five. Among successful trajectories, only 0.84% and 1.33%, respectively, use all seven or five steps.
- CoT-SC → ReAct: If the most common answer among CoT-SC samples appears fewer than times, the model lacks confidence in its knowledge and switches to ReAct to check.
Discussion
Results on Knowledge Tasks
| Method | HotpotQA (EM) | FEVER (accuracy) |
|---|---|---|
| Standard | 28.7 | 57.1 |
| CoT | 29.4 | 56.3 |
| CoT-SC | 33.4 | 60.4 |
| Act | 25.7 | 58.9 |
| ReAct | 27.4 | 60.9 |
| CoT-SC → ReAct | 34.2 | 64.6 |
| ReAct → CoT-SC | 35.1 | 62.0 |
| Supervised SoTA | 67.5 | 89.5 |
Compiled from Table 1 of the paper. The model is PaLM-540B.
Between ReAct and Act, ReAct is better on both tasks. Both can search, but adding thought changes their ability to assemble an answer.
Against CoT, ReAct wins on FEVER (60.9 versus 56.3) but does slightly worse on HotpotQA (27.4 versus 29.4). The authors explain that “supports” and “refutes” in FEVER can differ by a small detail, making accurate information especially important.
The best results come from the two hybrids, with ReAct → CoT-SC reaching 35.1 on HotpotQA and CoT-SC → ReAct reaching 64.6 on FEVER. In additional curves over sample counts, both hybrids match the performance of CoT-SC with 21 samples using just three to five.
The last row, however, shows that all these prompting methods remain far behind the best supervised models. HotpotQA's 67.5 and FEVER's 89.5 come from systems trained specifically for those tasks.
What Goes Wrong?
To understand the difference between ReAct and CoT on HotpotQA, the authors sample 50 correct and 50 incorrect trajectories from each, 200 in total, and manually label their success and failure types:
| Type | Description | ReAct | CoT |
|---|---|---|---|
| Success: true positive | Correct reasoning and facts | 94% | 86% |
| Success: false positive | Correct answer, but fabricated reasoning or facts | 6% | 14% |
| Failure: reasoning error | Faulty reasoning, including getting stuck repeating steps | 47% | 16% |
| Failure: search result error | Search returns nothing or no useful information | 23% | — |
| Failure: hallucination | Fabricated reasoning or facts | 0% | 56% |
| Failure: label ambiguity | Correct answer with wording different from the reference | 29% | 28% |
Compiled from Table 2 of the paper. Success and failure percentages are calculated separately.
The table breaks down the causes of success and failure separately.
Hallucination is CoT's biggest problem. Among CoT's incorrect cases, 56% involve hallucination. Even among correct answers, 14% happen to arrive at the right answer through invented reasoning. Among ReAct's incorrect cases, hallucination accounts for 0%.
But ReAct has problems of its own. Reasoning errors account for 47% of its failures, far above CoT's 16%. The authors observe a failure pattern specific to ReAct: the model keeps repeating earlier thoughts and actions and cannot escape the loop. Interleaving thoughts, actions, and observations grounds the reasoning, but also makes it less flexible.
Failed searches can derail ReAct. In 23% of failures, search finds no useful information, and the model struggles to reorganize its reasoning.
The authors also find that some HotpotQA reference answers are outdated.
Smaller Models Come Out Ahead After Fine-Tuning
With prompting alone, ReAct is the worst of the four approaches on PaLM-8B and 62B, since smaller models struggle to learn both reasoning and action from a handful of examples.
The authors then fine-tune smaller models on 3,000 successful trajectories generated by ReAct itself. The results reverse.
- Fine-tuned PaLM-8B ReAct beats every prompting method using PaLM-62B.
- Fine-tuned PaLM-62B ReAct beats every prompting method using PaLM-540B.
Fine-tuning Standard or CoT is much less effective. The authors explain the distinction this way: those approaches teach the model to memorize potentially hallucinated facts, whereas ReAct teaches it how to reason and look things up on Wikipedia—skills that generalize better.
Beyond Question Answering
The authors also test two interactive decision-making tasks:
- ALFWorld: A text-based household game, with tasks such as finding a pepper shaker and putting it in a drawer. The best ReAct trial achieves an average success rate of 71%, versus a best of 45% for action-only Act and 37% for the imitation-learning method BUTLER.
- WebShop: A simulated shopping website with 1.18 million real products, where the agent finds products matching a user's description.
According to the abstract, with only one or two demonstrations, ReAct improves success rates on the two tasks by 34 and 10 percentage points over imitation-learning and reinforcement-learning methods, respectively. Those comparison methods train on to task examples.
You Can Build It Without a Framework
Another attraction of ReAct is its simplicity. You barely need a framework.
In March 2023, Simon Willison wrote a simple Python implementation using gpt-3.5-turbo. A system prompt asks the model to output Thought, Action, PAUSE, and Observation in sequence, followed by an Answer. The program uses a regular expression to extract the Action: line, runs the corresponding tool—Wikipedia search, his own blog search, or a calculator—and sends the result back as an Observation:, for at most five rounds.
He also warns that the calculator directly uses Python's eval(), which is extremely dangerous and should run in a sandbox such as WebAssembly. The implementation is also still quite fragile.
Once the model decides which tools to call, safety and robustness become engineering concerns. The paper spends relatively little time on them.
Conclusion
At its core, ReAct adds thought to the agent's action space, allowing the language model to alternate reasoning and action.
The paper's evidence shows:
- Looking things up without thinking wastes information. With the same search access, ReAct beats action-only Act on both HotpotQA and FEVER.
- Thinking without checking invites hallucination. Hallucination accounts for 56% of CoT's incorrect cases and 0% of ReAct's, although ReAct makes more reasoning errors and can get stuck in loops.
- Combining the two works best. Switching between ReAct and CoT-SC based on confidence or step limits produces the best prompting results on both knowledge tasks.
- Fine-tuning amplifies the effect. After training on 3,000 trajectories, smaller ReAct models beat the prompting approaches of larger models.
These prompting methods still lag far behind task-specific trained systems, and the Wikipedia tools are deliberately weak.
But the loop—think, look something up, observe, think again—stuck around. Later coding agents that search files and run commands follow much the same pattern. The tools have simply changed from three Wikipedia actions to grep, file reading, and a terminal.