Planning · Free preview

Reason and Act

Think, act, observe, repeat

ReAct interleaves reasoning and action: the agent thinks one step, takes a tool action, observes the real result, then thinks again — letting later steps depend on what earlier actions actually returned.

Think, act, observe, repeat

Plan-then-act decides the whole route up front. But some steps can't be planned in advance — they depend on what an earlier action actually returns. ReAct weaves reasoning and action together: the agent thinks one step, calls a tool, observes the real result, and only then thinks about the next move. The observation is the hinge — each new thought reacts to ground truth instead of a guess.

Three pieces make the loop work, and you'll build all three:

Watch this agent work out a date difference with one tool, then feed that real number into a second tool — each thought shaped by the last observation.

Now build the mechanism yourself. The goal is "What is 12 * 8, then add 4?" You're given a fixed calc(expr) tool and a deterministic script of steps. The starter takes one action and quits with Answer: (unknown) — it never observes, never loops. Implement the loop body so it prints each Thought, Action, and Observation in turn, feeds 96 forward into 96+4, and stops on the answer step with Answer: 100.

ReAct's power is the observation step: the agent reacts to what the tool actually returned, then loops — and a real stop condition is what turns that loop into an answer instead of an infinite spin.

In the full academy, you watch a real agent run this — live:

🔒 Live code execution, real agent runs, mastery tracking and verifiable credentials unlock with the full academy.

This is 1 of 50 lessons.

The full academy: write real code, watch real agents run, and earn verifiable credentials — across 8 tracks, in a 3D campus.

Unlock the full academy — $100 →

14-day refund · 🔒 Stripe-secured checkout · lifetime access

More free lessons: An LLM Is a Function  ·  The Agent Loop  ·  Define a Tool  ·  Give an Agent a Tool  ·  Durable State

← The Agent Marketplace