ReAct Prompting — Prompting Guide & Examples
ReAct (Reasoning + Acting) prompting interleaves chain-of-thought reasoning with concrete actions like searching, calculating, or calling APIs. The model thinks about what it needs to do, takes an action, observes the result, then reasons about the next step.
How It Works
Structure the prompt as a Thought→Action→Observation loop. The model first reasons about the problem (Thought), decides what action to take (Action), receives the result (Observation), then continues reasoning. This cycle repeats until the task is complete.
When to Use
Use ReAct for tasks requiring external information retrieval, multi-step problem solving with tool use, fact-checking, research tasks, and building AI agents that need to interact with external systems.
Model-Specific Tips
ChatGPT / GPT-4
GPT-4 supports ReAct well, especially with function calling. Define tools in the API and let the model decide when to use them. ChatGPT's plugin system is essentially ReAct.
Claude
Claude handles ReAct patterns naturally. Use XML tags for structure: <thought>, <action>, <observation>. Claude's tool use API formalizes this pattern.
Gemini
Gemini supports ReAct through its function calling API. Define available actions and let Gemini reason about when to invoke them.
Pros & Cons
Pros
- ✓ Combines reasoning with real-world actions
- ✓ Transparent decision-making process
- ✓ Foundation for building AI agents
- ✓ Handles complex multi-step tasks
Cons
- ✗ Requires tool/API integration to be fully effective
- ✗ More complex prompt engineering
- ✗ Higher token usage and latency
- ✗ Error propagation across steps
Example Prompts
Answer this question using the ReAct framework: Question: What is the population of the country where the 2024 Olympics were held? Thought 1: I need to find where the 2024 Olympics were held. Action 1: Search[2024 Olympics host city] Observation 1: The 2024 Olympics were held in Paris, France. Thought 2: Now I need to find the population of France. Action 2: Search[population of France 2024] Observation 2: ...
You are a research agent. Use the Thought/Action/Observation pattern to investigate: 'Is it more cost-effective to use GPT-4 or Claude 3 for a customer support chatbot processing 10,000 messages per day?'
Debug this production issue using ReAct: Error: API response times increased from 200ms to 2s after yesterday's deploy. Thought 1: I should first check what changed in yesterday's deploy. Action 1: Review deployment diff Observation 1: ...