← BACK TO BLOG
6 min read

AI Agents: From ReAct to Multi-Agent Systems

An agent is what happens when an LLM stops answering once and starts acting repeatedly in the world. This guide traces the control loops, tool use, and guardrails that separate a demo agent from a dependable one.

Defining the paradigm

An agent = LLM + memory + tools + a control loop

A language model answers a single question in a single forward pass. An agent runs a loop: it perceives the current state (via context), reasons about the next action, executes that action through a tool, observes the result, and iterates until the task is complete or a stopping condition is met. The agent's power comes from composing LLM reasoning with deterministic tool execution — each component doing what it does best. Visualize , with the LLM at the center and tools ), external (vector store of past interactions), episodic (structured log of prior actions and results), and semantic (knowledge graph of learned facts).

  • Tools Action space: Deterministic functions the agent can invoke: search APIs, code executors, database queries, web browsers, file systems, calculators. Each tool h), a state machine (LangGraph), or a message-passing event bus (AutoGen). Choice affects debuggability and reliability.
MetricValueNotes
Single-agent1 LLM + toolsReAct, CoAct, FLARE — one model reasons and acts
Multi-agentN LLMs + rolesEach agent specializes; an orchestrator delegates subtasks

The foundational pattern

ReAct: interleaved reasoning and acting

ReAct (Yao et al., 2022) is the simplest complete agent pattern: at each step, the model generates a Thought (free-form reasoning about what to do next), an Action (a tool call with arguments), and an Observation (the tool's return value). This interleaving prevents the model from acting without reasoning and keeps the entire decision trace visible for debugging. ReAct is the default agent pattern in LangChain and most frameworks.

$$ \text{Trajectory} = (o_1, a_1, r_1,; o_2, a_2, r_2,; \ldots,; o_T) $$

An agent trajectory is a sequence of observations o_t, actions a_t, and rewards r_t. The policy π(a_t | o_1...o_t) maps the full history to the next action — implemented by the LLM over its context window.

  • Thought Reasoning: Free-form natural language reasoning. "I need to check the current price before placing the order. I should call the pricing API." The thought is never executed — it just improves action selection by making the model reason explicitly before committing.
  • Action Execution: A structured tool call: search("Q3 earnings Apple"), python_repl(" df.describe()"), or file_read("/reports/q3.csv"). The LLM generates JSON matching the tool's schema. The framework executes it deterministically.
  • Observation Feedback: The tool's return value, injected back into context. The model now h, web page content) before injection — they can overflow the context window.

Scaling with specialization

Multi-agent systems: orchestrator + specialized workers

A single LLM h, coding, critique, summarization). Each agent can have its own tools, memory, and even a different underlying model. The orchestrator aggregates results and decides what to do next. Visualize , with results flowing back , edges = conditional transitions, state = shared typed dict. Explicit state machine with cycle detection and streaming makes it debuggable. The current production-grade standard for complex agentic workflows.

  • AutoGen / CrewAI pattern Framework: Agents communicate via natural language messages in a shared conversation thread. Easier to prototype; harder to reason about state deterministically. Good for creative or open-ended tasks where rigid state machines limit emergent behavior.
  1. Task Decomposition (Step 1): Orchestrator receives a complex user request and breaks it into a dependency graph of subtasks. Tasks with no dependencies run in parallel; dependent tasks wait. Reduces total latency from serial to parallel execution.
  2. Agent Dispatch (Step 2): Each subtask is routed to the best-suited worker agent. Worker agents are specialized: a researcher agent h): Worker agents run their ReAct loops independently. Long-running tasks execute concurrently while the orchestrator monitors progress and handles failures. Each worker maintains its own short-term context; shared state goes to a message bus.
  3. Aggregation & Verification (Step 4): Orchestrator collects worker outputs and evaluates consistency. A dedicated critic agent checks factual consistency across workers. Human-in-the-loop gates (approval checkpoints) can be inserted before high-stakes actions.

Production engineering

Making agents reliable: the four failure modes

Agents fail in ways that single-inference systems never do. A failed tool call partway through a 20-step task can be catastrophic — unlike a bad single response that the user can retry. Production agents need explicit failure handling, cost control, and observability at every step.

  • Planning failures Hallucination risk: Agent pursues a wrong plan for many steps before realizing it. Fix: require explicit plan generation before execution, then validate the plan against task requirements. Add reflection steps: "Check if the current trajectory is still on track."
  • Tool call failures Execution risk: Tool returns an error or unexpected format; agent ignores it and hallucinates a plausible result. Fix: typed tool schem, output, and latency.
  • Infinite loops Control risk: Agent gets stuck in a retry loop — tool fails, agent retries with same arguments indefinitely. Fix: max_iterations hard limit, exponential backoff, circuit breaker pattern. Log loop detection signals (repeated identical tool calls).
  • Cost explosion Cost risk: A 20-step agent using GPT-4o at each step with large contexts costs $1+ per run. Unexpected loops multiply this 10x. Fix: token budget per run, model routing (use GPT-4o-mini for simple tool calls, GPT-4o for complex reasoning), cost alarms.
MetricValueNotes
Max iterations10–30 stepsMost tasks complete in <15 steps; hard-cap prevents runaway agents
Avg. agent cost$0.05 – $2 / runDepends on model selection and trajectory length
  • Instrument every agent run with a full trace: step index, thought, action, tool name, token count, latency, cost.
  • Set max_iterations (20 default) and max_cost_per_run budgets and handle graceful degradation.
  • Require human approval before any irreversible action: sending emails, writing to databases, making purchases.
  • Test agent robustness with adversarial inputs: missing tool responses, contradictory search results, malformed JSON returns.
  • Version your tool schem](/blog/rag-systems-deep-dive)
  • owasp-llm-top10-concrete-guide
  • ai-security-compliance-standards
SHARELINKEDINX

RELATED READING