Lesson 11.4 · 24 min · video lesson
ReAct Agents: Interleaving Reasoning and Acting
What happens if we make an agent write down its reasoning before every action, and read the result before its next thought?
In short: A ReAct agent (Reasoning + Acting) interleaves three kinds of lines: a Thought that reasons about what to do, an Action that calls a tool, and an Observation with the tool's result. The cycle repeats until the agent writes a Final Answer. Reasoning keeps actions purposeful, and observations keep reasoning grounded in real data, which reduces hallucination compared with reasoning alone.
What you will learn
- What is a ReAct Agent
- ReAct Agent vs AI Agent
- Anatomy of a ReAct Agent
- The ReAct Prompt Template
- How a ReAct Agent Thinks and Acts
- A Full Trace Example
- Implementing a ReAct Agent
- Common Failure Modes and How to Fix Them
- Quick Summary
In this lesson
- What is a ReAct agent?
- Why interleave reasoning and acting?
- ReAct agent vs AI agent
- Anatomy of a ReAct agent
- The ReAct prompt template
- How a ReAct agent thinks and acts
- A full trace example
- Implementing a ReAct agent
- Common failure modes and how to fix them
- Worked example, step by step
- Practice: try it yourself
Key terms in this lesson
- ReAct
- An agent design that interleaves written reasoning (Thought) with tool use (Action) and results (Observation).
- Thought
- The model's short natural-language reasoning about what it knows and what to do next.
- Observation
- The tool's real output, appended to the transcript by the program, never by the model.
- Scratchpad
- The growing transcript of all previous Thought, Action and Observation lines sent to the model each step.
- Stop sequence
- A string that makes the model stop generating when it is produced, such as “Observation:”.
- Multi-hop question
- A question that needs several facts found in separate steps before it can be answered.
This lesson is part of the Generative AI Engineering and Complete AI Engineer tracks. See plans and pricing to open the full lesson, its video, labs and quiz, or try the free lesson first (free account needed).
← 11.3 The Agent Loop: Observe, Think, Act, Repeat · 11.5 Plan-and-Execute: Tackling Complex Tasks in Two Phases →