# ReAct: Synergizing Reasoning and Acting in Language Models

> Prompts a language model to alternate reasoning traces with tool actions and observations. Grounding thoughts in retrieved facts cuts hallucination, and on ALFWorld and WebShop it beats imitation and RL agents by 34 and 10 points.

- arXiv: https://arxiv.org/abs/2210.03629
- Authors: Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao
- Published: 2022-10-06
- Topic: Agents
- Visual carousel: https://instaxiv.com/p/2210.03629
- Explanation by InstaXiv, a secondary educational summary. Cite the original paper for exact results. InstaXiv is not affiliated with or endorsed by arXiv or Cornell University.

## Interleave thinking with tool calls and agents stop inventing facts

**+34** points of success on ALFWorld

## Reasoning and acting were studied apart

**Reason only, or act only:** Chain-of-thought reasons in a closed loop and hallucinates facts. Action-only agents call tools but cannot plan, track progress or recover from errors.

**ReAct:** The model alternates free-form thoughts with actions and reads each observation. Thoughts plan and update; actions fetch real evidence from Wikipedia or the environment.

Thoughts steer actions; observations ground thoughts.

## One loop, three kinds of text

1. **Thought**: Decompose the goal, note what is known, and decide what to look up next.
2. **Action**: Emit a tool call such as search[entity] or lookup[keyword], or an environment command.
3. **Observation**: The result is appended to the context, and the loop repeats until finish[answer].

## Gains are largest on interactive tasks

| Method | ALFWorld success | WebShop success |
| --- | --- | --- |
| Imitation / RL | 37 | 28.7 |
| Act only | 45 | 30.1 |
| **ReAct (+34 pts)** | **71** | **40.0** |

_Success rate (%). ALFWorld is best of six prompts against BUTLER; WebShop compares with IL+RL._

## Where ReAct still stumbles

- **Reasoning loops**: On HotpotQA the model sometimes repeats the same thought and action and cannot escape.
- **Bad search, bad answer**: Uninformative search results derail the reasoning; recovery depends on reformulating the query.
- **Prompt length limits**: Few-shot prompts hold only a few demonstrations; fine-tuning smaller models on ReAct traces helped.

Best used when: Tasks need fresh facts or multi-step interaction with tools and environments.

## Key takeaways

- Interleaving reasoning traces with actions beats either one alone on knowledge and decision tasks.
- Visible thoughts make agent trajectories interpretable and easy to correct by editing a thought.
- The thought, action, observation loop became the template for most LLM agents.

## Links

- arXiv: https://arxiv.org/abs/2210.03629
- PDF: https://arxiv.org/pdf/2210.03629
- Code: https://github.com/ysymyth/ReAct
- Project page: https://react-lm.github.io

## Citation

```bibtex
@article{yao2022react,
  title   = {ReAct: Synergizing Reasoning and Acting in Language Models},
  author  = {Yao, Shunyu and Zhao, Jeffrey and Yu, Dian and Du, Nan and Shafran, Izhak and Narasimhan, Karthik and Cao, Yuan},
  journal = {arXiv preprint arXiv:2210.03629},
  year    = {2022},
  url     = {https://arxiv.org/abs/2210.03629}
}
```
