ReAct
A 2022 framework that interleaves reasoning (Chain-of-Thought) with acting (using external tools like Wikipedia or APIs), forming the basis of modern LLM agents.
Paper: ReAct: Synergizing Reasoning and Acting in Language Models
Authors: Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao · 2022
Read the paperThe Problem
By 2022, Large Language Models had demonstrated two distinct, powerful capabilities in isolation:
- Reasoning: Techniques like Chain-of-Thought (CoT) allowed models to perform complex logical deductions by generating step-by-step text. However, CoT was a closed system; the model could only reason over information already present in its prompt or its internal weights. If it needed a fact it didn't know (e.g., "Who won the World Series last year?"), it would hallucinate or fail.
- Acting: Other research had shown models could interact with external environments (like text-based games or web APIs) by generating "action" commands. However, these pure acting models often flailed blindly because they didn't pause to plan or reason about their long-term goals.
The gap was clear: reasoning without acting is blind (limited to internal knowledge), and acting without reasoning is foolish (lacking a plan).
The Idea
The authors introduced ReAct (Reasoning + Acting), a prompting framework that explicitly interleaves both capabilities in a continuous loop.
Instead of just generating a chain of thought to reach an answer, or just generating a sequence of API calls, a ReAct model is prompted to follow a strict, cyclical format:
- Thought: The model reasons about the current state, what it knows, and what it needs to figure out.
- Action: Based on the thought, the model generates a command to interact with an external tool (e.g.,
Search[Apple stock price]). - Observation: The external tool executes the command and returns the result back into the model's context window.
This loop repeats until the model's Thought concludes that it has enough information to output a final answer.
How It Works
ReAct is primarily a prompt engineering technique. You provide the model with a few-shot prompt demonstrating the ReAct loop.
Example Task: "What is the name of the author of the book The Shining, and when were they born?"
- Thought 1: I need to find out who wrote The Shining, then find their birthdate.
- Action 1:
Search[author of The Shining] - Observation 1: (From Wikipedia API) Stephen King is the author of the 1977 horror novel The Shining.
- Thought 2: The author is Stephen King. Now I need to find out when Stephen King was born.
- Action 2:
Search[Stephen King birthdate] - Observation 2: (From Wikipedia API) Stephen Edwin King (born September 21, 1947)...
- Thought 3: I have the birthdate. It is September 21, 1947. I can answer the question now.
- Action 3:
Finish[Stephen King, September 21, 1947]
Crucially, the "Observation" steps are not generated by the LLM. The system pauses generation, runs the requested tool, and pastes the result back in. The "Thought" steps allow the model to interpret the observations, recover from errors (e.g., if a search fails, the model can think "That didn't work, let me try a different search term"), and plan the next move.
Why It Mattered
ReAct was the foundational paper for the modern concept of an "AI Agent." It proved that LLMs could be more than just text generators; they could act as the central routing and reasoning engine for complex, multi-step workflows involving external software.
On benchmarks like HotpotQA (which requires multi-hop factual reasoning), ReAct significantly outperformed standard CoT because it could pull in perfectly accurate external information rather than relying on its sometimes-flawed internal memory. It also dramatically reduced hallucinations and increased interpretability, because every piece of information used by the model was explicitly fetched in the Observation step.
What Came After
ReAct fundamentally changed how developers build LLM applications. Frameworks like LangChain and LlamaIndex were built around the ReAct paradigm, making it easy for developers to give models access to databases, web browsers, and APIs.
While ReAct relied entirely on prompt engineering and in-context learning, the next wave of research (like Toolformer) began fine-tuning the actual model weights to use tools natively. Today, most state-of-the-art models (like GPT-4 and Claude 3.5 Sonnet) have ReAct-like loops natively baked into their instruction tuning, allowing them to autonomously write and execute code or browse the web without needing a rigid few-shot prompt.