Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Agent Patterns, Testing and Guardrails  ›  Lesson

ReAct — Reason, Act, Observe, Repeat

ReAct (Reason + Act) 12 minReAct interleaves short reasoning steps with single tool actions and their observations, grounding each decision in real results but planning only one step ahead.

ReAct — Reason, Act, Observe, Repeat

Asha asks: "Will it rain in Jaipur the day I arrive?" Tripmate does not know which day she arrives until it checks her booking, and it cannot know the weather until it asks for a forecast. The answer needs thinking and doing, woven together. That weave has a name: ReAct, short for reason + act.

The rule

Think a line, act once, read the result — then think again.

ReAct is the simplest widely used agent pattern. The model alternates three kinds of step:

  • Thought — a short piece of reasoning about what it knows and what to do next.
  • Action — one tool call chosen by that thought.
  • Observation — the tool's result, added to the context.

The cycle repeats until a thought concludes that the answer is ready.

Thought: I need Asha's arrival date in Jaipur. Her bookings will have it.
Action: get_bookings(user="asha", destination="JP")
Observation: Friday sleeper, arrives 2026-10-16 14:30.
Thought: Now I need the forecast for Jaipur on 16 October.
Action: get_weather(city="Jaipur", date="2026-10-16")
Observation: High 33°C, 10% chance of rain.
Thought: I have both facts. Rain is unlikely.
Answer: You arrive on Friday 16 October at 14:30; rain is unlikely (10%).

Why it works: each thought is grounded in real observations instead of guesses, and each action is explained by a thought, so the trace doubles as a record of why the agent did what it did. Compare it with plain chain of thought, which reasons only from what is already in the context: if a fact is missing, a pure chain can only guess it, while ReAct stops to look it up. Its weakness is that it only looks one step ahead, so long tasks can wander without a bigger plan.

The shortcut

When reading or debugging a ReAct trace, check each thought against the observation before it: "Does this thought follow from what was just observed?" The first thought that does not is where the run went wrong.

Debugging a bad ReAct runStep 1 of 4
  1. Read the trace

    Observation: "Arrives 2026-10-17 06:10". Next thought: "She arrives on the 16th; check weather for the 16th."

The trap is judging only the final answer. A ReAct run can reach a right answer by luck after a wrong thought, and the same flaw will bite on the next request.

Drills

Answer fast — trust the rule.

quick drill

What does ReAct interleave?

quick drill

In a ReAct trace, where does an observation come from?

quick drill

What is ReAct's main weakness on long, many-step tasks?

quick drill

A trace shows the observation "fare ₹1,450" followed by the thought "the fare is ₹1,540". What is wrong?

Remember

  • ReAct: thought, action, observation — repeated until the answer is ready.
  • Shortcut: check each thought against the observation just before it.
  • Trap: judging only the final answer, not the path that produced it.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWrite a ReAct trace

Write a short ReAct trace (thoughts, actions, observations, answer) for Asha asking "How much will my Udaipur train cost in total for two people?", then explain why this pattern suits the question.