① Intuition
A pure-reasoning LLM can hallucinate facts; a pure-tool-calling agent gets lost without reasoning. What if we interleave?
Setup: imagine an LLM answering “What is the population of Paris?” In Chain-of-Thought (CoT) mode it reasons entirely from memory. In Act-only mode it calls tools but without a guiding plan. ReAct alternates between thinking and acting, letting each inform the other.
Predict: what's the most common failure mode of CoT-only on factual questions?
Confident wrong answers from stale or missing knowledge. CoT reasons entirely from the model’s parameters — if those parameters contain outdated facts or simply never saw a particular piece of data, the model will produce a fluent, confident answer that is factually wrong. There is no grounding mechanism to catch or correct the error mid-reasoning.
Now step through the widget below. Select a mode (CoT, Act, ReAct) and click Step to advance the trace.
Step through CoT, Act-only, and ReAct modes. Which one arrives at the right Paris population, and why?
ReAct — its thoughts direct tool calls and then integrate their results. CoT guesses ~2M from stale parameters. Act-only issues a bare search for “Paris” and gets an ambiguous disambiguation page (Paris, Texas), losing the thread. ReAct first thinks “I need the capital of France,” confirms it is Paris via a focused search, then immediately thinks “now fetch Paris’s population” and retrieves the precise 2023 figure.
Retrieval check
Answer all 2 correctly to mark this stage mastered.
② Math
ReAct is formalized as a policy conditioned on an interleaved context. At each step t, the agent samples an action from:
where the context grows with every step:
The action space is extended: where 𝒜 is the set of tool calls (search, lookup, etc.) and ℒ is the space of natural-language thoughts. A thought action is executed purely inside the model’s context — it does not interact with any external environment.
Show next line
Token cost: ReAct uses 2–5× more tokens than Act-only because each trajectory contains interleaved Thought steps that do not directly produce observations. This is a deliberate trade-off: more tokens per query buys substantially better factual accuracy and fewer dead-end action sequences.
Retrieval check
Answer all 1 correctly to mark this stage mastered.
③ Pseudo code
Arrange the steps of the ReAct loop in the correct order:
- If Finish: return the answer
- Parse block as Thought | Action | Finish
- If Action: run tool, observe result, append (Action, Observation) to c
- If Thought: append Thought to c
- Generate next token block from LLM given c
- Initialize context c with the user query
What keyword terminates the ReAct loop and returns a final answer?
Retrieval check
Answer all 1 correctly to mark this stage mastered.
④ Code (Python)
Implement a minimal ReAct scaffold. The loop drives a scripted LM through Thought / Action / Finish blocks, calling a canned search tool for grounding.
Retrieval check
Answer all 1 correctly to mark this stage mastered.
⑤ Original paper
Suggested reading order: §2 ReAct → §3 Knowledge-intensive tasks → §4 Interactive decision-making.