ReAct Pattern
Think → Act → Observe
The Problem: Regular AI can only answer from memory. Ask it "What's the weather today?" and it has no idea — it can't look outside the window or check a weather website.
The Solution: Think, Act, Observe
ReAct stands for Reasoning + Acting. It's a pattern that lets AI solve problems step by step, using tools along the way. The model enters an agent loop -- think, act, observe -- calling external services via function calling.
Think of it like a detective solving a case:
- 1. Think: "I need to find out who was at the scene..."
- 2. Act: Interview witnesses, check security cameras
- 3. Observe: "The witness saw a red car leaving at 9pm"
- 4. Think: "Now I should check traffic cameras..."
- 5. Repeat: until the case is solved!
Where Is This Used?
- AI Assistants: ChatGPT, Claude — when they search the web or run code
- Customer Support Bots: Look up orders, check account status
- Research Agents: Find papers, compare data, compile reports
- Coding Assistants: Read files, run tests, fix bugs
Fun Fact: The ReAct paper (2022) showed that this simple pattern can solve problems that stumped AI before. By "thinking out loud" and using tools, AI makes fewer mistakes and can explain its reasoning!
Try It Yourself!
Use the interactive simulator below to see ReAct in action. Watch how the agent thinks, acts, and observes step by step.
AI agent works in cycles: thinks about the task, takes an action, observes the result, and repeats until it finds the answer
Click "Play" to see how the agent works
ReAct (Reason + Act) is a way to make AI solve tasks step by step. Instead of guessing the answer, the agent thinks, uses tools, and checks the result. It's similar to how humans solve unfamiliar problems.
Try it yourself
Interactive demo of this technique
What is the population of Tokyo and what rank is it among the largest cities in the world?
The population of Tokyo is about 14 million people. It is the largest city in the world.
Thought: I need to find current data about Tokyo's population. I should not rely on memory. Action: search("Tokyo population 2025 metropolitan area") Observation: Tokyo metropolitan area is the largest in the world, ~37.4M people. Tokyo city proper — ~14M.
Thought: I need to verify the ranking among world cities. Action: search("largest cities in the world by population ranking 2025") Observation: By metro area: 1) Tokyo (37.4M), 2) Delhi (32.9M), 3) Shanghai (29.2M).
Thought: Now I have verified data. It's important to distinguish city vs. metro area.
Answer: The Tokyo metropolitan area has about 37.4 million people and ranks #1 in the world. Tokyo city proper has about 14 million residents.
ReAct prevents the model from hallucinating — every fact is confirmed by an action (search). Without tools the model gave an inaccurate answer.
Create a free account to solve challenges
4 AI-verified challenges for this lesson
This lesson is part of a structured LLM course.
My Learning Path