04. Agentic Workflows
ReAct (Reasoning and Acting)
ReAct (Reason + Act) interleaves reasoning traces with tool actions and observations so an agent can think, act, see results, and adapt until the goal is met — instead of guessing everything in one shot.
What you will learn
- Define ReAct and its three step types
- Walk a short Thought → Action → Observation trace
- Compare ReAct with plan-then-act
- List production pitfalls and controls
- Answer interview questions with short, solid answers
Definition
ReAct is a prompting and control pattern where the model alternates between reasoning (Thought) and taking a tool action (Action), then consumes the tool result (Observation) before the next thought. It continues until it can answer or a stop rule ends the run.
Named after the “Reason + Act” style of agent prompting, ReAct is a concrete interleaved form of the Observe–Think–Act loop used across modern tool-calling agents.
Introduction
This lesson (#3 in Agentic Workflows) follows Observe–Think–Act. OTA is the general loop; ReAct is a widely cited way to implement interleaved reasoning and acting with LLMs.
Next lessons cover scheduling, workflow patterns, HITL, and recovery — all of which still often use ReAct-style steps inside.
Why ReAct matters
- Grounds reasoning in real tool results (less hallucination)
- Adapts when early assumptions are wrong
- Produces readable traces for debugging
- Maps cleanly onto function-calling APIs
The ReAct step types
- Thought - short rationale for what to do next
- Action - structured tool/function call with arguments
- Observation - runtime result returned into context
- Finish - final answer when enough evidence exists
Example trace
Keep thoughts short and actions schema-valid. Long monologues burn tokens without better decisions.
- Thought names the information gap
- Action uses a declared tool only
- Observation is structured and concise
- Next Thought uses the observation — or Finishes
ReAct vs plan-then-act
Neither is always better. Match the pattern to uncertainty.
- Plan-then-act - draft many steps, then execute (good when stable)
- ReAct - decide one action at a time from fresh observations
- Hybrid - high-level plan milestones with ReAct inside each
- Production tip - store both plan state and ReAct traces when useful
How modern stacks implement ReAct
- Tool/function calling APIs instead of brittle string parsers
- Orchestrator loop: model → validate → execute → append observation
- Optional visible “Thought” channel or hidden chain-of-thought policy
- Frameworks (LangGraph, Agents SDK, etc.) encode the same loop
Failure modes and controls
- Tool thrashing - repeat similar calls → add budgets and reflection
- Invented tools - allowlist names in runtime
- Ignoring observations - require next thought to cite result ids
- Leaking thoughts to users - separate internal trace vs final answer
- Unbounded cost - max steps, max tools, timeouts
Program / implementation notes
Prefer native tool calling over regex-parsing “Action:” text when the provider supports it. Keep a run log of thought/action/observation triples.
- Validate every Action against schemas before execute
- Normalize Observation JSON for the next model turn
- Stop when Finish, verifier passes, or caps hit
- Eval traces: did each Action follow from the prior Observation?
- Next: Task Planning, Decomposition and Scheduling
Advantages and limitations
- Advantage: adaptive under uncertainty
- Advantage: grounded answers from tool evidence
- Advantage: debuggable step traces
- Limitation: more latency/cost than one-shot answers
- Limitation: weak tools still yield weak agents
- Limitation: verbose thoughts can distract or leak internals
Key points
- ReAct = interleaved Thought, Action, Observation until Finish.
- It is Observe–Think–Act with explicit reasoning traces.
- Use when tool results should change the next decision.
- Implement with structured tool calls and a bounded orchestrator.
- Control thrashing with caps, allowlists, and reflection.
- Hybridize with high-level plans when milestones help.
FAQs
Is ReAct the same as React.js?
No. Here ReAct means Reason + Act for LLM agents, not the UI library.
Do I need visible Thoughts in production?
Not always. Many systems keep internal reasoning/logs while exposing only tool calls and the final answer to users.
Can function calling replace ReAct?
Function calling is the Action channel. ReAct is the loop pattern that repeatedly thinks, calls functions, and observes.
When is plan-then-act better than ReAct?
When the path is stable and known — upfront plans reduce meandering. ReAct shines when observations frequently change the path.
Interview questions
- What is ReAct in Agentic AI?
Answer A pattern that interleaves reasoning traces with tool actions and observations so the agent adapts until it can finish the goal.
- What are the main ReAct steps?
Answer Thought (reason), Action (tool call), Observation (result), repeating until a Finish answer or stop rule.
- How does ReAct reduce hallucination?
Answer By forcing the model to ground later thoughts on real tool observations instead of inventing missing facts.
- ReAct vs plan-then-act?
Answer Plan-then-act drafts many steps before acting; ReAct chooses the next action after each observation. Hybrids are common.
- How is ReAct implemented with modern APIs?
Answer An orchestrator loop calls the model with tool schemas, validates returned function calls, executes them, appends observations, and repeats.
- What are common ReAct failure modes?
Answer Tool thrashing, invented tool names, ignoring observations, unbounded cost, and leaking internal thoughts to end users.
- Give a one-line ReAct example.
Answer Thought: need order status → Action: get_order(4821) → Observation: shipped → Finish: tell the user the ETA.
Related topics
Practice task
Complete each numbered practice step in a notebook or doc before opening the next lesson.
- Write a four-line ReAct trace for “reset password email bounced.”
- Label each line Thought, Action, Observation, or Finish.
- List five runtime controls you would wrap around Actions.
- Argue in three bullets when you would use plan-then-act instead.
- Answer interview questions 1, 2, and 4 in two sentences each.