Agentic AI / Patterns

ReAct

Intermediate [3/5]
Reasoning and Acting ReAct prompting Thought-Action-Observation

Definition

ReAct (Reasoning and Acting) is an agent paradigm that interleaves thinking (reasoning traces) with doing (actions and tool calls). The model explicitly reasons about what to do next, takes action, observes the result, then reasons again, creating a transparent problem-solving loop.

ReAct is the most common pattern for building AI agents, combining the strengths of chain-of-thought reasoning with tool use.

Key Concepts

  • Thought: Model's reasoning about current situation and next step
  • Action: Tool call or action the model decides to take
  • Observation: Result returned from the action/tool
  • Loop: Repeat until task is complete

Examples

Pattern
The ReAct Loop
REACT PATTERN: ┌─────────────────────────────────────────────┐ │ THOUGHT │ │ "I need to find the current weather in │ │ Tokyo to answer this question." │ └─────────────────────┬───────────────────────┘ ↓ ┌─────────────────────────────────────────────┐ │ ACTION │ │ weather_api(location="Tokyo") │ └─────────────────────┬───────────────────────┘ ↓ ┌─────────────────────────────────────────────┐ │ OBSERVATION │ │ {"temp": 22, "condition": "sunny", │ │ "humidity": 45} │ └─────────────────────┬───────────────────────┘ ↓ ┌─────────────────────────────────────────────┐ │ THOUGHT │ │ "I have the weather data. It's 22°C and │ │ sunny in Tokyo. I can now answer." │ └─────────────────────┬───────────────────────┘ ↓ ┌─────────────────────────────────────────────┐ │ ACTION │ │ finish("The weather in Tokyo is 22°C │ │ and sunny with 45% humidity.") │ └─────────────────────────────────────────────┘ LOOP CONTINUES UNTIL: - Task is complete (finish action) - Max iterations reached - Error requires human intervention
Example
ReAct for Research Task
QUESTION: "Who won the 2024 Super Bowl and by how much?" Thought: I need to search for information about the 2024 Super Bowl winner and score. Action: search("2024 Super Bowl winner final score") Observation: The Kansas City Chiefs won Super Bowl LVIII 25-22 over the San Francisco 49ers on February 11, 2024. Thought: I found the answer. The Chiefs won by 3 points (25-22). Let me verify this is correct by checking another source. Action: search("Super Bowl LVIII final score Chiefs 49ers") Observation: Kansas City Chiefs defeated San Francisco 49ers 25-22 in overtime at Allegiant Stadium in Las Vegas. Thought: Both sources confirm: Chiefs won 25-22 in OT. That's a 3-point margin. I have enough information to answer confidently. Action: finish("The Kansas City Chiefs won the 2024 Super Bowl (Super Bowl LVIII), defeating the San Francisco 49ers 25-22 in overtime. The margin of victory was 3 points.") WHY REACT HELPS: - Explicit reasoning catches errors - Multiple searches verify facts - Transparent decision-making - Knows when to stop

Interactive Exercise

Write a ReAct Trace

Write a ReAct trace for this task: "Find the CEO of OpenAI and their educational background"

Include at least 2 thought-action-observation cycles.

Pro Tips
  • Good thoughts explain WHY taking the next action
  • Limit max iterations to prevent infinite loops (typically 5-10)
  • ReAct works best with clear, focused actions
  • Combine with reflection for even better results

Related Terms