All concepts

ReAct Agent

Alternate reasoning, tool actions, and observations until the task is solved.

Agentic AI · Intermediate · ~8 min

In plain English

Think, act, look at what happened, think again. The model narrates its reasoning, picks a tool, sees the result, and repeats until it's done.

Why it's worth your time

It's the base pattern under nearly every agent framework — and knowing the loop is how you debug one.

If you remember three things

  • Reason → act → observe, repeated
  • Observations enter as new context each turn
  • Without a hard stop it will loop forever

Overview

ReAct interleaves reasoning and acting in a loop: the model writes a Thought, takes an Action (a tool, retriever, or API call), reads the Observation, and repeats. Grounding each step in real tool results curbs hallucination; the loop halts when evidence suffices or a stop rule fires.

How it works

  1. Start: Question The user asks a task that may require external information or computation.
  2. Question -> Thought The LLM decides what it needs next.
  3. Thought -> Action It calls a tool, retriever, browser, or database.
  4. Action -> Observation The result is appended to the loop state.
  5. Observation -> Final Answer The loop stops when enough evidence is gathered or a stop rule triggers.

In an interview

ReAct is a loop of Thought → Action → Observation. The LLM reasons about what it needs, calls a tool, feeds the result back into its context, and iterates until it can answer. Interleaving reasoning with real observations grounds the model in facts instead of pure generation. You need stop conditions to bound the loop.

Production defaults

Step cap
8–12 iterations, then stop and report honestly
Token budget
enforced in code. Loop cost is roughly quadratic in steps if you resend everything
Repeat detection
identical tool + identical args twice means break the loop, don't try a third time

What breaks

  • Loops on the same tool forever — Uninformative errors. Return 'no match; try a wider date range', not a stack trace.
  • Cost 10× the estimate — Full history resent each turn. Summarize old observations, keep the goal verbatim.

Watch it explained

AI Agentic Design Patterns: ReAct Explained | Reasoning + Acting in AI Agents — CodeCraft Academy, 6:49

Related