## Definition The **ReAct pattern** — *Reasoning + Acting* — interleaves the model's internal reasoning (thoughts) with external actions (tool calls). Introduced by Yao et al. (2022 — see [[ReAct (Yao et al.)]]); it is the conceptual scaffold of almost every modern AI agent. ## The Trace ``` Thought 1: I need the schema for the orders table to answer this. Let me query it. Action 1: postgres.describe("orders") Observation 1: id (uuid), tenant_id (uuid), total (numeric), ... Thought 2: tenant_id is present. So the question is well-formed. Let me count rows. Action 2: postgres.query("SELECT COUNT(*) FROM orders WHERE tenant_id = $1", ...) Observation 2: 12834 Thought 3: I have what I need. Final answer: 12,834 orders for this tenant. ``` Each iteration: **Thought → Action → Observation → next Thought**. ## Why Interleaving Beats Either Alone - **Pure reasoning** (CoT only) — the model is reasoning about facts it may not have. Hallucinations cascade. - **Pure acting** (tool calls without reasoning) — the model picks tools mechanically and misses context-sensitive choices. - **ReAct** — reasoning informs which action to take *next*; observations refine reasoning *next*. The loop self-corrects. ## Relationship to Chain-of-Thought [[Chain-of-Thought]] is the *reasoning-only* version. ReAct = CoT + [[Tool Use]] formalised. ## Implementation in Modern Stacks - **Anthropic tool-use protocol.** Each Claude API turn can include a `thinking` block and a tool call. The host runs the tool, returns the result, and the next turn continues the trace. - **MCP tool calls in Claude Code.** Follow exactly the Thought → Action → Observation cycle. - **LangChain ReAct agents.** Original Python implementation of the paper. ## Pitfalls - **Thoughts that don't constrain actions.** The model writes plausible reasoning then takes an unrelated action. Sign of weak grounding. - **Tool-result echo.** The model paraphrases the observation as if it were a thought. Useless turn; cost without progress. - **Long traces without termination.** Add explicit "if you have the answer, output it" instruction; cap turn count. ## Related - [[AI Agent]] - [[Tool Use]] - [[Chain-of-Thought]] - [[Agentic Loop]] - [[ReAct (Yao et al.)]]