ReAct: Reason + Act Pattern
Thought -> Action -> Observation -> Thought ... — the loop that powers most modern multi-step agents.
ReAct: Reason + Act Pattern is a free AI Agents lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Agents learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is ReAct?
ReAct stands for Reason + Act. It is the canonical pattern for multi-step LLM agents — published by Yao et al. in 2022 and still the foundation of most modern agents.
The Loop
At each step, the agent emits three things:
- Thought — what to do next, in natural language
- Action — which tool to call and with what arguments
- Observation — the tool result, fed back in
Repeat until the agent emits Final Answer.
A Concrete ReAct Trace
User: Who won the 2024 US presidential election?
Thought: I do not know off the top of my head. I should search.
Action: search('2024 US presidential election winner')
Observation: Donald Trump defeated Kamala Harris.
Thought: I have the answer.
Final Answer: Donald Trump won the 2024 US presidential election.Why It Works
The "Thought" step lets the model lay out its reasoning before committing to an action. This is chain-of-thought applied to agents.
Without Thought, the model often picks bad tools or wrong arguments.
Modern ReAct Uses Function Calling
Old ReAct parsed Action lines from plain text. Modern implementations use the function-calling API:
- Tools defined as JSON schemas
- Model returns tool_calls instead of text Action lines
- Errors are caught by the model when results are appended
Variants of ReAct
- Plan-and-Execute — full plan first, then execute
- Reflexion — agent self-critiques after each step
- Tree-of-Thoughts — explore multiple Thought branches
When ReAct Excels
- Tasks with exploratory steps (research, debugging)
- Tasks where the next action depends on the previous result
- Tasks where the plan cannot be known up front
When ReAct Underperforms
- Fixed pipelines (translation, classification) — overkill
- Very long-horizon tasks — Plan-and-Execute is better
- Real-time control loops — too slow
Common Failure Modes
- Loops where the agent calls the same tool repeatedly
- Premature Final Answer without enough info
- Confusion when tools fail
- Token-budget blowups on chatty Thought steps
ReAct + Self-Reflection
After Final Answer, ask the agent: "Was that correct? Could it be better?" Many implementations add this reflection step for higher quality.
Frameworks That Implement ReAct
- LangChain create_react_agent
- LlamaIndex ReActAgent
- AutoGen UserProxyAgent + AssistantAgent
- Hand-rolled — easier than it looks
Cost Profile
ReAct adds 2-3x more LLM calls than single-shot. Each Thought is an LLM call, and Observations add tokens. Budget MAX_STEPS and per-step token caps.
Three Steps
What are the three components of a ReAct step?
Recap
ReAct is the foundation of multi-step agents. Master the loop and you can build any tool-using agent.
Frequently asked questions
Is the “ReAct: Reason + Act Pattern” lesson free?
Yes — the full text of “ReAct: Reason + Act Pattern” is free to read here on the web, and the AI Agents course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Agents course, upgrade to CoddyKit PRO.
What will I learn in “ReAct: Reason + Act Pattern”?
Thought -> Action -> Observation -> Thought ... — the loop that powers most modern multi-step agents. You practise AI Agents with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start AI Agents?
No prior experience is required. AI Agents on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “ReAct: Reason + Act Pattern” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this AI Agents lesson?
Yes. Every AI Agents lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.