AI Space

AI Models & Assistants / Knowledge library

ReAct: Reasoning and Acting Agents

Agents that alternate reasoning, tool actions, and observations

Language-agent reasoning and action pattern

Why learn ReAct: Reasoning and Acting Agents?

Useful for tasks where intermediate observations determine the next action. Tool results, stopping conditions, and action permissions remain application responsibilities.

The problem it solves

Lets a language agent adjust its plan using external observations during a task.

Where it came from

ReAct interleaves language-model reasoning with actions and observations from an environment. An agent can revise its next step after a search result or other tool response. This agent pattern is distinct from the React user-interface library.

Build your understanding

Work through these exercises in order. Try the task before opening a reference.

  1. Sketch a lookup task as alternating actions and observations.
  2. Build a mock search tool that returns a fixed set of facts.
  3. Show how an empty search result should change the next action.
  4. Set a maximum number of steps and handle repeated tool calls.
  5. Evaluate final answers against the facts returned by the mock tool.

Documentation and sources

Connect the ideas

Explore next

Chain-of-Thought (CoT) PromptingTool-Calling AgentsLangGraphLLM EvalsAgent2Agent (A2A) ProtocolReinforcement Learning (RL)Tool-Use Loop

Real World Example

Illustrative business scenario · AI-generated from linked documentation · Not a measured customer case study

Automated Logistics Compliance Auditor

Global logistics firms managing complex, multi-jurisdictional shipping regulations.

The business problem

Manual compliance checks are prone to error and slow, as agents often fail to synthesize dynamic regulatory updates with specific shipment manifests, leading to costly delays.

How this topic solves it

The ReAct framework enables agents to interleave reasoning traces with tool-based actions, allowing the system to query live regulatory databases and verify shipment data against those findings in a single, transparent workflow.

  1. Define the agent prompt structure to enforce a Thought-Action-Observation loop.
  2. Connect the agent to a secure, read-only API for real-time customs regulation lookups.
  3. Implement a reasoning module that decomposes complex compliance queries into sequential sub-tasks.
  4. Configure the observation parser to feed external API results back into the agent's context window.
  5. Establish a final response generation step that summarizes the reasoning path for human auditability.
ReAct Execution Loop · Process flow

The agent cycles through reasoning and acting until the compliance task is resolved.

Reasoning Trace

Model analyzes the current state

Action Generation

Model selects a tool to call

Tool Execution

External API fetches data

Observation

Result is fed back to model

  • Reasoning Trace → determines → Action Generation
  • Action Generation → triggers → Tool Execution
  • Tool Execution → returns → Observation
  • Observation → updates context → Reasoning Trace

Implementation example

This snippet illustrates the core ReAct loop where the model generates a thought, selects an action, and receives an observation to inform the next reasoning step.

python · Illustrative code; not executed or production-validated.

def react_step(query):
    thought = model.generate(f'Thought: {query}') # Reasoning trace
    action = model.generate(f'Action: {thought}') # Tool selection
    observation = api.call(action) # External data retrieval
    return f'Observation: {observation}' # Feedback loop

Expected business outcome

Improved accuracy in compliance verification and increased transparency, as human auditors can review the step-by-step reasoning trace that led to a specific shipping clearance decision.

Limitations and checks

The agent may enter infinite loops if the observation data is ambiguous or contradictory; check for this by monitoring the length of the reasoning trace and setting a maximum step threshold.

Sources

Generated 2026-10-18 with gemini-3.1-flash-lite. Your assessment includes two questions about this example.

Catalog source: technology-maxxing. This page reproduces the existing catalog’s learning material and source links.