ReAct: Reasoning and Acting
ReAct (Reasoning + Acting) is a prompting paradigm for large language models that interleaves chain-of-thought reasoning traces with discrete action calls to external tools, enabling agents to dynamically update their beliefs and behavior in response to environmental feedback. It matters because it closes the loop between thinking and doing — solving the critical limitation of pure chain-of-thought, which can hallucinate facts it cannot verify, and pure action-only agents, which cannot self-correct. The counterintuitive fact: ReAct agents frequently outperform fine-tuned task-specific models on multi-hop question answering despite using only prompting, because interleaved observations act as a grounding signal that prevents compounding reasoning errors.
A language model left to reason in isolation is like a scientist who must write the entire paper before running any experiment — errors compound silently with no opportunity for correction. ReAct breaks this by treating reasoning and acting as an alternating dialogue: Thought → Action → Observation → Thought → Action → … until a terminal answer is produced. Each observation from the real world (a search result, a database row, a calculator output) anchors the next reasoning step to ground truth, making the agent self-correcting by construction. The "aha moment" is realizing that the LLM's context window itself becomes a working scratchpad that accumulates evidence, turning a frozen snapshot model into a dynamic, evidence-gathering reasoner.
Practitioners often conflate ReAct with simple tool-calling APIs (e.g., OpenAI function calling) and assume the two are interchangeable. The critical difference is that ReAct mandates that reasoning traces are generated in the same token stream as action decisions — the Thought step is not post-hoc commentary but is causally upstream of the Action step. Stripping thoughts out and just emitting action calls degrades into a reactive policy that loses the chain-of-thought grounding; conversely, generating thoughts after actions (as some implementations mistakenly do for logging) reverses the causal order entirely. The correct mental model: Thought is a plan written before the action, not a summary written after it.
How It Works
ReAct operates by prompting the LLM to generate interleaved trajectories of three token types — Thought, Action, and Observation — within a single autoregressive decoding pass.
Formal Trajectory Definition
Let the agent's trajectory be a sequence of triples. At each step , the model generates a thought and action conditioned on the full history, then receives observation from the environment:
Explanation: The full ReAct trajectory is a time-ordered interleaving of thoughts, actions, and observations — the model only ever sees the prefix of this sequence when generating its next token. Here is a free-text reasoning string, is a structured action (e.g., `Search[entity]`, `Lookup[keyword]`, `Finish[answer]`), and is the environment's response appended to the context.
Autoregressive Factorization
The LLM parameterized by produces the next token sequence by conditioning on the growing context :
Explanation: Both the reasoning trace and the action are generated token-by-token from the same autoregressive distribution — there is no separate "reasoning head"; thinking and acting share identical model weights. where concatenates the original query with all prior steps.
Action Space Definition
The action set is task-specific but typically includes a Wikipedia-style API:
Explanation: The action vocabulary is deliberately small and deterministic so that each call returns a crisp, parseable observation that the LLM can incorporate without ambiguity.
Trajectory Likelihood and Few-Shot Prompting
ReAct uses in-context learning rather than gradient-based training. The model is conditioned on demonstration trajectories :
Explanation: The answer probability marginalizes over all possible reasoning-action trajectories, but in practice greedy or beam decoding collapses this to a single trajectory — the sum is conceptual, not computational.
Comparison with Chain-of-Thought
Pure CoT omits the action and observation:
Explanation: Without the observations, all reasoning is closed-loop hallucination over the model's frozen parametric knowledge — any factual error in propagates uncorrected through all subsequent steps. The gap between equations [4] and [5] is precisely the grounding benefit of ReAct: every is an external correction signal injected into the context. ---
Shunyu Yao is a PhD student at Princeton (later affiliated with Stanford) working at the intersection of NLP, cognitive science, and AI agents; his undergraduate background in philosophy informs his emphasis on the cognitive plausibility of LLM reasoning. His 2022 paper ReAct: Synergizing Reasoning and Acting in Language Models (with Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao) introduced the interleaved thought-action-observation paradigm that became foundational to modern LLM agent design. Surprisingly, the paper was partly inspired by Yao's reading of classical AI planning literature from the 1980s, drawing a direct line from STRIPS-style action theory to modern prompt engineering.
Karthik Narasimhan is an assistant professor at Princeton whose research program focuses on language-grounded agents that learn to act in text-based and robotic environments. His earlier work on learning to navigate text-based games (2015–2018) established the conceptual scaffolding for action-conditioned language models that directly preceded ReAct. He is notable for bridging reinforcement learning theory with modern transformer-based agents at a time when most NLP researchers had not yet engaged seriously with agentic settings.
---
---
Intuition
Imagine a detective interrogating witnesses to solve a case. A pure chain-of-thought detective locks herself in a room and reasons entirely from memory: "The butler was angry, angry people commit crimes, therefore the butler did it." She may be brilliant, but if her memory of the butler's motive is wrong, she convicts an innocent man with perfect logical consistency. A pure action-only detective runs around randomly interviewing witnesses with no theory to guide which witness to visit next, wasting time and missing the crucial lead. The ReAct detective does neither — she forms a hypothesis (Thought), then tests it by interviewing a specific witness (Action), updates her theory based on what the witness actually says (Observation), then forms the next hypothesis. Each witness interview is targeted by the current theory, and each answer sharpens or refutes it. The context window is her case notebook: a running log of hypotheses and evidence that accumulates until the case is closed. The key insight is that the notebook itself is the reasoning — it's not a summary of thinking, it's the thinking, made legible enough to drive the next action.
Historical Development
Why It Matters
Prerequisites
What This Leads To
See Also
Chain-of-Thought Prompting · Retrieval-Augmented Generation · Tool-Augmented Language Models · Reflexion · Tree of Thoughts · LLM Agents · Prompt Engineering