Prompt Engineering

ReAct Prompting

Definition

ReAct (Reasoning + Acting), introduced by Yao et al. (2022), is a prompting framework that combines chain-of-thought reasoning with tool use in an alternating loop: Thought → Action → Observation → Thought → Action → ... The model generates a thought explaining its current reasoning, then selects an action (search, calculate, call API), receives an observation (the tool's result), uses that observation to inform the next thought, and continues until the task is complete. ReAct enables LLMs to interact with external tools and environments while maintaining a coherent reasoning trace, forming the foundation of most modern LLM agent frameworks.

Why It Matters

ReAct is the standard pattern for building LLM agents that can interact with external systems. Without a structured reasoning-action loop, LLMs that have access to tools tend to use them haphazardly, fail to incorporate observations into subsequent decisions, or get stuck in repetitive loops. ReAct's explicit thought steps create an interpretable audit trail that shows exactly why the model took each action—making agent behavior debuggable and trustworthy. Most production agent frameworks (LangChain agents, Anthropic tool use, OpenAI function calling loops) implement variants of the ReAct pattern.

How It Works

A ReAct prompt provides: (1) a description of available tools and their signatures; (2) format instructions specifying the Thought/Action/Observation structure; (3) few-shot examples of complete ReAct trajectories. At inference, the model generates a Thought (reasoning), then an Action (tool call specification), then the system executes the tool and appends the Observation to the context. This Action-Observation pair is added to the conversation history and the model generates the next Thought. The loop continues until the model generates a Final Answer action. The observation at each step provides ground truth feedback that grounds subsequent reasoning.

ReAct Prompting — Thought → Action → Observation Loop

ThoughtI need to compare this month's invoice to last month's to find the increase.
Actionget_invoice(month='current') → calls billing API
ObservationInvoice total: $149. New line item: 'Premium AI add-on — $50/mo added Mar 1'.
ThoughtI see a new premium add-on. Let me check when and how it was activated.
Actionget_subscription_changes(account_id='u-8821') → calls subscription API
ObservationPremium tier activated Mar 1 by user click on upgrade modal.
Final AnswerYour bill increased by $50 because you upgraded to the Premium AI add-on on March 1st via the upgrade prompt. You can downgrade in Settings → Billing.

Loop pattern

ThoughtActionObservationThought→ ...Final Answer

Real-World Example

A customer support agent built on ReAct can answer complex account queries that require multiple data lookups. When a user asks 'Why did my bill increase this month?', the agent thinks: 'I need to compare current and previous invoices.' It calls get_invoice(month='current'), receives the invoice data, thinks 'I see a new premium feature charge. Let me check when this was added,' calls get_subscription_changes(account_id=...), observes that the premium tier was activated 3 weeks ago, thinks 'I should also check if this was user-initiated or automatic,' calls get_activity_log(), and synthesizes the complete answer from all three observations—a task impossible without the ReAct tool-use loop.

Common Mistakes

  • Not providing clear tool descriptions—the model's tool selection quality is entirely dependent on how well tools are described in the prompt
  • Ignoring the observation quality—if tool outputs are verbose or poorly formatted, the model struggles to extract the relevant information
  • Allowing unbounded reasoning loops without a maximum step limit—without a stopping condition, ReAct agents can loop indefinitely on difficult problems

Related Terms

Ready to build your AI chatbot?

Put these concepts into practice with 99helpers — no code required.

Start free trial →
What is ReAct Prompting? ReAct Prompting Definition & Guide | 99helpers | 99helpers.com