Skip to content

ReAct Pattern: Overview

ReAct (Reasoning + Acting) is the simplest AI agent architecture. The agent alternates between reasoning about what to do next, taking an action, and observing the result.

The name “ReAct” combines:

  • Reasoning: The model thinks about what to do
  • Acting: The model executes a tool or completes the task
graph LR
A[User Request] --> B[Reasoning]
B --> C{Decision}
C -->|Use Tool| D[Action]
C -->|Task Complete| E[Final Answer]
D --> F[Observation]
F --> B

The ReAct pattern follows a simple loop:

sequenceDiagram
participant User
participant Agent
participant Tools
User->>Agent: Initial request
loop Until task complete
Agent->>Agent: Reason about next action
alt Use a tool
Agent->>Tools: Execute tool
Tools-->>Agent: Tool result
Agent->>Agent: Observe result
else Task complete
Agent->>User: Final answer
end
end
graph TB
subgraph AppLayer["Application Layer"]
App[Control Loop]
end
subgraph AgentLayer["Agent Layer"]
LLM[LLM]
Memory[Conversation History]
end
subgraph ToolLayer["Tool Layer"]
T1[Read File]
T2[Write File]
T3[Execute Code]
T4[Search]
end
App --> LLM
LLM --> App
App --> T1
App --> T2
App --> T3
App --> T4
T1 --> Memory
T2 --> Memory
T3 --> Memory
T4 --> Memory
Memory --> LLM

Here’s how ReAct handles a legal document review task:

graph LR
Start[Start Task] --> Reasoning[Reasoning]
Reasoning --> Action[Action]
Action --> Observe[Observe]
Observe --> Decision{Task<br/>Complete?}
Decision -->|No| Reasoning
Decision -->|Yes| End[Complete]
  • Simple: Easy to understand and implement (~200-400 lines)
  • Transparent: Clear reasoning at each step
  • Debuggable: Can trace exactly what the agent did and why
  • Flexible: Works with any LLM that supports tool calling
  • No Quality Checks: Agent doesn’t verify its own work
  • Can Loop: May get stuck repeating actions
  • No Planning: Decides one step at a time
  • Error Prone: No recovery mechanism
✅ Use ReAct When…❌ Avoid ReAct When…
Building prototypes or MVPsProduction systems need reliability
Learning agent fundamentalsComplex multi-step workflows
Simple, linear tasks (3-5 steps)Quality assurance required
Small tool sets (< 10 tools)Error recovery is critical
Fast iteration neededCompliance/audit trails needed

Here’s what the conversation looks like:

sequenceDiagram
autonumber
participant User
participant Agent
participant Tools
User->>Agent: Review contract.pdf
Note over Agent: Need to read file first
Agent->>Tools: read_file
Tools-->>Agent: Contract contents
Note over Agent: Found missing clause
Agent->>Tools: write_file FINDINGS
Tools-->>Agent: File written
Note over Agent: Task complete
Agent->>User: Review complete
graph TB
subgraph Simple["ReAct Simple"]
R1[Reason] --> A1[Act]
A1 --> O1[Observe]
O1 --> R1
end
subgraph Robust["Plan-Execute-Verify"]
P[Plan] --> E[Execute]
E --> V[Verify]
V -->|Pass| Next[Next Step]
V -->|Fail| Retry[Retry]
Retry --> E
Next --> E
end

Key Difference: ReAct is a single loop, while Plan-Execute-Verify separates planning, execution, and verification into distinct phases.

  • Learning: Perfect for understanding agent concepts
  • Prototyping: Quick to build and iterate
  • Simple Tasks: 3-5 steps, clear requirements
  • Demos: Easy to explain and visualize

Continue to one of the implementation guides:

  1. Claude SDK Implementation - Direct API integration (most control)
  2. Model Agnostic Design - Support multiple LLM providers
  3. LangChain Implementation - Using LangChain framework (fastest development)