Scrapeless Wiki

What Is a ReAct Agent? – Definition and How It Works

Informational P2 what is a react agent

Learn what the ReAct pattern is, how interleaving reasoning and action works, what the trace contains, and where the pattern breaks down.

ReAct is an agent pattern that interleaves reasoning and acting: the model states its thinking, chooses an action, observes the result, and repeats. The name is a contraction of reason and act.

1. The Pattern

Each iteration produces a structured triple:

Thought:      I need current pricing, which I do not have.
Action:       search({"query": "example product pricing 2026"})
Observation:  [three results with titles and snippets]
Thought:      The second result is the official page; open it.
Action:       fetch({"url": "https://example.com/pricing"})
Observation:  [page content]
Thought:      I have the figures. Answer.

Reasoning conditions the next action, and the observation conditions the next reasoning.

2. Why Interleaving Helps

Planning everything upfront fails when the world differs from expectation β€” a search returns nothing useful, a page moved, a form has an unexpected field.

Interleaving means each decision is made with the latest evidence rather than with an assumption formed several steps earlier.

3. What the Trace Provides

The explicit thought line is not only for accuracy; it makes runs auditable. A failed run can be read to see where the reasoning went wrong, which is far more informative than a sequence of tool calls with no rationale.

Treat those thoughts as a debugging aid rather than as a faithful account of the model's internal computation.

4. Structuring the Loop

  • Parse strictly. The action and its arguments must be machine-readable; free-form text invites malformed calls.
  • Validate arguments against the tool schema before executing.
  • Summarise observations. Raw page content floods the context within a few steps.
  • Cap iterations and detect repetition.
  • Define a finish action so completion is explicit rather than inferred.

5. Where It Breaks Down

Failure Cause
Oscillation Two actions alternate with no progress
Premature finish The model declares success before the goal is met
Context overflow Accumulated observations exceed the window
Reasoning drift Thoughts become plausible narration disconnected from evidence
Injected redirection Observation text read as instruction

6. Modern Variants

Native tool calling has largely replaced text-parsed actions: the model emits a structured call rather than a formatted line, removing a whole class of parsing failure while keeping the interleaved shape.

Reasoning models also perform much of the thought step internally, so explicit "Thought:" lines matter less than they did β€” the pattern's structure survives even as its surface changes.

7. When It Fits

Tasks that need external information, that cannot be planned fully in advance, and whose steps depend on prior results β€” research, troubleshooting, and navigation of unfamiliar systems.

For a single deterministic call, the pattern is unnecessary overhead.

8. Summary

ReAct interleaves reasoning and action so each step is chosen with current evidence, producing an auditable trace of thought, action, and observation.

Its structure remains the standard agent shape; the implementation has moved to native tool calling. Its failure modes β€” oscillation, premature completion, context overflow β€” are managed by caps, summarisation, and explicit success tests rather than by better prompting.