The Illustrated ReAct Agent

An agent isn't magic — it's a loop: Reason → Act (call a tool) → Observe, repeat until it can answer. Step through a real trace below; the tools actually run.

agentstool use reasoning loopBYO-10 ReAct agent

Why an agent at all?

A plain LLM has two weaknesses for real tasks. It can't act on the world — it can't run code, query a database, hit an API, or look something up — and it's unreliable at things like exact arithmetic or fresh facts, because it's generating text, not computing. An agent fixes this by giving the model tools and a loop: the model decides what to do, a tool actually does it, and the result is fed back so the model can decide the next step.

The ReAct idea: interleave reasoning and acting

"ReAct" stands for Reason + Act. Instead of answering in one shot, the model alternates between thinking out loud and taking actions:

Then it loops: the new observation informs the next thought. The model never does the arithmetic or lookup itself — it orchestrates. Crucially, the scratchpad (the growing transcript of thoughts/actions/observations) is fed back every step, so the model always sees what it has learned so far.

The intern analogy. Think of the LLM as a sharp intern with no memory and no hands. It can reason brilliantly, but it can't open a spreadsheet or call the bank. You give it a phone (tools) and a notepad (the scratchpad). It says "I'll call accounting" (Action), you dial and read back the answer (Observation), it writes it down and decides the next call. The intern's judgment drives the task; the tools do the work.

One more essential: a max_steps cap. Because the model controls the loop, a confused model could loop forever. The cap forces a stop — a small detail that matters a lot in production.

The loop

Try it

Pick a task and press ▶ — or step one beat at a time and scrub the timeline backwards to replay any phase. Watch three things: the loop diagram highlights which phase you're in; the scratchpad grows with each Thought / Action / Observation (and shrinks again when you scrub back); and the tools genuinely execute — the calculator really evaluates the expression, the search really looks it up. The two-step task is the interesting one: the first Observation gets substituted into the second tool call, exactly how a real agent chains steps together.

Pick a task  ·  tools available: calculator search

Scratchpad (what gets fed back to the model each step)

Where agents help — and where they bite

Agents are powerful when a task needs multiple steps, real tools, or decisions the model can't make in one shot: research that requires several lookups, workflows that branch on intermediate results, or anything touching live systems. But that power comes with costs you should respect:

A good rule from Anthropic's Building Effective Agents: use the simplest thing that works. Many "agent" problems are better solved by a fixed workflow (a predetermined sequence of steps); reach for a true autonomous agent only when you genuinely need the model to decide the path at runtime.

Check yourself

The big picture: grounding an LLM in tools — a calculator, a search index, your RAG retriever — beats a bare model for real tasks, because the model brings judgment and the tools bring truth. Build the loop yourself in BYO-10, then scale it to stateful, multi-agent systems with LangGraph in Phase 8.