Skip to main content

What are Agents?

Agents are autonomous systems that can:
  • Reason about complex tasks
  • Use tools to perform actions
  • Make decisions based on context
  • Iterate until reaching a goal
Unlike simple query engines, agents can break down problems, call multiple tools, and chain operations together.
The legacy ReAct agent APIs (ReActAgent, LLMAgent) are deprecated. Use the modern @llamaindex/workflow package for building agents.

Modern Workflow-Based Agents

LlamaIndex.TS now uses an event-driven workflow architecture for agents. This provides:
  • Better control flow
  • Easier debugging
  • More flexible agent patterns
  • Multi-agent orchestration

Installing the Workflow Package

Building Your First Agent

1

Define Your Tools

Tools are functions that agents can call:
2

Create the Agent

Use the agent() helper to create a workflow-based agent:
3

Run the Agent

Execute tasks and get results:

Complete Working Example

Here’s a full agent with tool usage:

Multi-Agent Orchestration

Build systems with multiple specialized agents:

Agent Configuration

System Prompts

Customize agent behavior:

Verbose Mode

Enable detailed logging:

Agent Handoffs

Define which agents can delegate to others:

Creating Custom Tools

Tools use Zod schemas for type-safe parameters:

Migrating from Legacy Agents

If you’re using the old ReActAgent or LLMAgent:
Before (Deprecated):
After (Recommended):

Next Steps