Skip to content

AI 202 · Module 3

ReAct: Reasoning + Acting

Why can an agent not simply think everything through first and then act?

Start Section 1
0 / 6 completed
Sync my progressJoin a session to keep progress across devices and share it with your instructor

Info

After you join, your completed lesson numbers are sent to your instructor together with your learner code, so they can see your progress. Use the codes your instructor gave you, and do not enter your name, company secrets or other personal data. Progress is kept with the rest of that session's data.

Learning objectives

  • Explain how ReAct alternates Reasoning, Action and Observation
  • Describe the loop: Goal, Reason, Choose Action, Act, Observe, Update State, Reason Again
  • Distinguish a reasoning step, an action step, an observation, a state update and a next-step decision
  • Explain the relationship with AI 201: which tool is safe versus when and why to choose it
  • Recognize how an early error propagates through a loop, and how evidence limits it
  • Trace a ReAct loop for your own use case using simulated data

Problem and need

8 min

Thinking it all through first does not work

In Module 2 the agent built a Candidate Plan. But a plan is written before the agent has seen everything. Real situations answer back: a source is empty, a number does not match, a page says something unexpected. The core question of this module is: why can an agent not just think everything through first and then act, instead of reasoning, acting and observing in turn?

Work scenario (simulated)

An assistant is asked why lab bookings fell. It reasons for a long time and writes a full 12-step plan in one go. Step 3 turns out to rest on a data file that is empty for last term. Steps 4 to 12 were all built on that file, so the whole plan has to be thrown away. If the assistant had run step 3, looked at the result and only then decided step 4, it would have caught the problem at once.

  • Reasoning without acting is guessing about a world the agent has not yet looked at
  • Acting without reasoning is a sequence of moves with no reason behind them
  • Observations are the evidence that keeps reasoning connected to reality
  • Alternating them lets each result shape the next decision

Warning

A confident chain of reasoning is not evidence. The agent should prefer what it observed over what it assumed, and a person should be able to read the trace and see why each step was taken.

Key takeaway: Reasoning tells the agent what to try; acting and observing tell it whether the reasoning was right.

Core concepts

10 min

The ReAct loop

ReAct is a pattern in which an agent alternates Reasoning and Acting, and uses each Observation to decide what to reason about next. It is a way of making iterative decisions, and it is the basic loop under many agent designs.

The ReAct loop
  1. Goal: what the agent is trying to achieve
  2. Reason: what does the current state mean, and what is the best next move?
  3. Choose Action: pick one available action that fits
  4. Act / Use Tool: carry the action out
  5. Observe Result: read what came back
  6. Update State: record what is now known and done
  7. Reason Again: return to Reason with the new state

Text equivalent: the loop starts from the Goal. The agent Reasons about the state and chooses an Action. It acts, often by using a tool, then observes the result. It updates its State with what it learned and Reasons again. The loop continues until the goal is reached or a Stop Condition from Module 1 applies.

One turn of the loop (simulated)
PartWhat it looks like
Reasoning"Bookings fell, but I do not know for which lab. I should look at bookings by lab first."
ActionOpen the booking table and group by lab
ObservationLab C fell by 40 percent; the others are flat
State updateKnown: the drop is in Lab C only. Not yet known: why
Next-step decisionCheck whether Lab C had a closure or a schedule change
Check yourself

What is the main reason ReAct alternates reasoning and acting?

What is the main reason ReAct alternates reasoning and acting?

Key takeaway: ReAct: Reason, Act, Observe, Update State, Reason Again, until the goal is met or a stop condition applies.

10 min

Five parts of a step: which is which?

To read or write a ReAct trace you must tell five things apart. They are easy to mix up, and mixing them up hides mistakes.

Five parts of a ReAct step
PartQuestion it answersExample (simulated)
Reasoning stepWhat does the situation mean, and what should be done?"The drop may be in one lab only, so group by lab."
Action stepWhat does the agent actually do?Group the booking table by lab
ObservationWhat came back from the environment?Lab C down 40 percent, others flat
State updateWhat does the agent now know and what has been done?Drop located in Lab C; cause unknown; one action used
Next-step decisionGiven the new state, what comes next?Check Lab C schedule; if unavailable, ask a person
  • A reasoning step is thought; it changes nothing in the world until an action is taken
  • An observation is not chosen by the agent; it is whatever the environment returned
  • A state update should record only what was observed or done, not what is hoped
  • A next-step decision should follow from the state, not repeat the previous one by habit

Weak trace

  • Reasoning and result are blended into one sentence
  • The state is never written down
  • A next step appears with no link to what was seen

Readable trace

  • Each part is labeled and separate
  • The state is updated after every observation
  • Each next step follows from the state, and a person can check it
Check yourself

A trace line reads: "The tool returned an error, so the record does not exist." Which part is mixed up?

A trace line reads: "The tool returned an error, so the record does not exist." Which part is mixed up?

Key takeaway: Keep reasoning, action, observation, state update and next-step decision separate, so every step can be checked.

10 min

Choosing an action, and how AI 201 fits

Many ReAct actions use a tool. Two different questions are involved, and they belong to two different courses.

AI 201 asks

  • What tool can the agent use safely?
  • What data may it reach, with what permission?
  • Which actions need confirmation from a person?

AI 202 asks

  • When and why should the agent choose that tool?
  • What evidence in the current state points to it?
  • What is the expected outcome, and what if it fails?

This course does not teach how tools are built or connected. It assumes the safe tools have been set up, as in AI 201, and focuses on the decision to use one.

Evidence-driven tool choice (simulated)
Situation in the stateReasonable actionWhy
Need a number that is stored in a tableRead the tableThe evidence needed is exactly there and reading is reversible
Two sources disagreeLook for a third source, or ask a personChoosing silently would hide the conflict
The next action would send data outside the teamStop and ask for approvalIrreversible and external, so a person decides
The needed tool is not availableSay so and choose another approach or escalateDo not invent a result

Info

Human-AI-Human: a safe tool is a permission, not an instruction. The agent should have a reason for each use, the reason should be visible in the trace, and a person should confirm actions with real impact.
Check yourself

Which statement separates AI 201 from AI 202 best?

Which statement separates AI 201 from AI 202 best?

Key takeaway: AI 201 makes a tool safe to use. AI 202 decides when and why to use it, based on evidence in the current state.

Error propagation

10 min

Error propagation in a loop

Because each turn builds on the previous state, a mistake early in the loop can spread. A wrong reading of an observation becomes a wrong state, which shapes the next reasoning step, which shapes the next action. This is error propagation.

How one early error spreads
  1. Observation is misread: an empty file is taken to mean "no bookings"
  2. State is updated wrongly: "no bookings last term"
  3. Reasoning builds on it: "so the drop is total, look for a shutdown"
  4. Action follows the reasoning: search for a shutdown notice
  5. The wrong direction continues, and later steps look consistent with it

Text equivalent: the five stages run in a chain. A misread observation produces a wrong state; the wrong state produces a wrong piece of reasoning; that leads to a wrong action; and the agent continues confidently in the wrong direction because each later step is consistent with the earlier mistake.

Ways to limit error propagation
HabitWhat it looks like
Keep observations separate from conclusionsWrite down what came back before saying what it means
Check surprising resultsAn empty or extreme result triggers a second look, not a conclusion
Prefer evidence over assumptionIf the state has an unverified assumption, mark it as unverified
Cap the loopA step limit and a stop condition after repeated errors
Involve a person at key pointsEscalate when results conflict or the next action has real impact

Info

Formal evaluation, verification and reflection are covered in a later module. Infrastructure for reliable recovery belongs to other courses (AI 301 and AI 302). Here the goal is only to read a trace and see where an error entered.
Check yourself

The agent reads an empty result and immediately concludes there is no data, then plans around that. What habit would have helped most?

The agent reads an empty result and immediately concludes there is no data, then plans around that. What habit would have helped most?

Key takeaway: An early misreading spreads through every later step. Separate observations from conclusions, and check the surprising ones.

Practice and apply

12 min

Practice: Trace a ReAct Loop

Activity 3 asks you to trace a ReAct loop. First work the example, then do it for your own use case. Please do not enter real company secrets, client personal data or any unauthorized sensitive information in this exercise.

Worked example (simulated). Goal: explain why lab bookings fell this term
TurnReasoning stepActionObservationState updateNext-step decision
1Do not know where the drop is; group by labGroup the booking table by labLab C down 40 percent; others flatDrop is in Lab C; cause unknownCheck Lab C schedule
2A closure or a schedule change could explain itOpen the Lab C scheduleTwo weeks marked "under maintenance"Maintenance overlaps the drop; not yet confirmed as the whole causeCompare with last term
3Need a baseline to see if two weeks explain 40 percentOpen last term bookings for Lab CLast term had no maintenance; the drop equals two weeks of lost bookingsMaintenance explains most of the dropWrite the note and ask a person to confirm the maintenance dates
  1. Identify the current goal
    State the goal of your use case in one sentence and the state you start from.
  2. Write the reasoning decision and choose an action
    Write why you would do the next thing, then name one action from your available actions.
  3. Inspect the observation and update the state
    Write what came back exactly, then what is now known and not yet known.
  4. Decide the next step
    Choose the next action from the new state. Repeat for at least three turns, and note where a person should confirm.
  • Reasoning step: why, given the state
  • Action step: what the agent does
  • Observation: what came back, unchanged
  • State update: what is now known and done
  • Next-step decision: what follows from the new state

Info

Deliverable: the ReAct Trace, a table of at least three turns with the five parts labeled. It becomes part of your Agent Planning & Reasoning Canvas.
Check yourself

In your trace, which entry belongs in the Observation column?

In your trace, which entry belongs in the Observation column?

Key takeaway: Human-AI-Human: a person defines the goal and limits, the agent reasons and acts step by step with a visible trace, and a person reviews the trace and stays responsible.

What next?