Skip to content

ReAct Pattern: Reasoning and Acting Loop

CoreConceptJuly 29, 20263 min read

ReAct Pattern is for builders who need the term to survive contact with real products, tools, and failure modes. The goal is a practical mental model you can use in design review, not a glossary definition.

We will follow one concrete workflow, separate mechanism from product language, and end with a checkable practice. For nearby background, connect this with From LLM to Agentic AI and AI Agent Project Structure.

Concept map for ReAct agent loop
Concept map for ReAct agent loop

ReAct Alternates Thinking With Evidence

ReAct means the agent does not answer in one jump. It reasons about the next useful step, performs an action such as a search or API call, observes the result, and repeats until it can stop. The important product idea is the loop boundary, not the spelling of the prompt template.

The running example is a support agent diagnosing invoice INV-8127. A plain LLM may guess. A ReAct-style agent checks the billing API, reads account status, decides whether to refund, and returns an answer with tool evidence.

Decision map for ReAct agent loop
Decision map for ReAct agent loop

Quick reference

  • Reasoning selects the next action; actions change the information available.
  • Observations are external evidence and should be logged as structured events.
  • The loop needs a stop condition, budget, and failure state.
  • Tool results should be summarized before they enter the next prompt.

Remember this

ReAct turns one model call into a bounded evidence-gathering loop.

Tool Calls Need Contracts, Not Wishes

A ReAct loop is only as reliable as its tools. Each action needs an input schema, permission boundary, timeout, retry policy, and output shape. Without those contracts, the model can call the right-sounding tool with the wrong arguments or continue looping after a recoverable error.

For INV-8127, getInvoice(id) should return explicit states such as paid, void, or chargeback_pending. The agent should not infer billing state from raw prose when a typed field exists.

Operational flow for ReAct agent loop
Operational flow for ReAct agent loop

Quick reference

  • Keep tools narrow and named by capability.
  • Validate tool inputs before execution.
  • Return machine-readable errors such as NOT_FOUND or FORBIDDEN.
  • Record tool latency and result size in the trace.

Remember this

Tool schemas are the agent's real API surface; natural language is not enough.

Failure Story: The Agent Loops on a Missing Invoice

Trigger: INV-8127 was merged into a new invoice id, but the lookup tool returns NOT_FOUND without a redirect hint. Symptom: the agent retries the same lookup until the token budget is gone. Root mechanism: the loop has action freedom but no progress detector.

Recovery is to add a repeated-action guard and a fallback lookup by customer id. Prevention is to store loop state: last action, last observation, unresolved question, and remaining budget. A useful agent knows when more action will not create new evidence.

Failure and recovery detail for ReAct agent loop
Failure and recovery detail for ReAct agent loop

Quick reference

  • Detect repeated action plus same observation.
  • Add max tool calls per task and per tool.
  • Expose a graceful needs-human terminal state.
  • Let tools return recovery hints when safe.

Remember this

A loop without progress detection spends tokens instead of solving the task.

Practice: Build a Three-Step ReAct Trace

Mock two tools: getInvoice(id) and getCustomer(id). Give the agent an invoice id that fails once, then requires a customer lookup. Log each thought summary, action name, arguments, observation code, and stop reason.

Pass when the trace shows no duplicate useless call, produces a final answer only after evidence arrives, and stops with needs-human when both tools fail. The exercise is small, but it exposes the control surface every production agent needs.

Operational flow for ReAct agent loop
Operational flow for ReAct agent loop

Quick reference

  • Starter: use JSON tool results; no real billing API required.
  • Expected success: action count stays under a fixed budget.
  • Intentional break: make both tools return NOT_FOUND.
  • Recovery: stop cleanly and request a human lookup.

Remember this

A ReAct implementation is ready when its trace proves progress, evidence, and a bounded stop condition.

Key takeaway

Use the concept when it gives you a clearer boundary, measurement, or operating rule. Skip the label when it only makes the system sound more advanced.

Practice should leave behind an artifact: a table, eval set, trace, or checklist that another engineer can inspect. Pass when the artifact catches the intentional failure described above and gives a concrete recovery path.

Share:

Related Articles

LLM Serving Queues and Backpressure matters when a team has to turn an AI idea into a system other people can trust. The

Read

Jul 29, 2026 · 3 min read

LLM Open-Source Deployment Guide matters when a team has to turn an AI idea into a system other people can trust. The us

Read

Jul 29, 2026 · 3 min read

LLM Fine-Tuning Dataset Curation matters when a team has to turn an AI idea into a system other people can trust. The us

Read

Explore this topic

Keep learning

Follow a structured path or browse all courses to go deeper.