LlamaIndex began as the go-to framework for RAG, but through its AgentWorkflow module it now also builds agents: programs that reason about a task, decide which tool to use and chain steps until it is solved. The appeal is that you can reuse everything you have already indexed (your documents, your vector store, your query engines) and turn it into tools an agent calls on its own. This guide covers what LlamaIndex is and what AgentWorkflow adds, how to move from a RAG pipeline to an agent with tools, how FunctionAgent and ReActAgent differ, an example that answers over your own files, and when to pick LlamaIndex over LangChain. The same explanation is available in Spanish.

Key takeaways

  • LlamaIndex is a Python framework, MIT-licensed, born in November 2022 (as "GPT Index") to connect private data with an LLM. The run-llama/llama_index repo has more than 50,900 stars on GitHub and version 0.14.23 shipped on 24 June 2026.
  • AgentWorkflow, released on 22 January 2025, is the system that orchestrates one or several agents: it keeps state, streams events in real time and lets agents hand off tasks to each other.
  • There are two main agents in llama_index.core.agent.workflow: FunctionAgent, for models with native function calling, and ReActAgent, which works with any model, even one you run on your own machine.
  • A tool is a Python function with its docstring and type hints; a RAG query engine becomes a tool with QueryEngineTool, so the agent searches your documents when it needs to.
  • LlamaIndex excels at retrieval: in one comparison it reached 92% accuracy and needs between 30% and 40% less code than LangChain for the same RAG.

What is LlamaIndex and what does AgentWorkflow add?

LlamaIndex is a Python framework for building applications over language models using your own data. Its historical specialty is retrieval-augmented generation (RAG): it ingests documents, chunks them, computes embeddings, stores them in an index and answers questions by retrieving the most relevant fragments. To understand the storage layer underneath, it helps to first review what a vector database is.

On top of that, LlamaIndex added an agent layer. The official documentation defines an agent as "a semi-autonomous piece of software powered by an LLM that is given a task and executes a series of steps towards solving that task". The difference from a plain RAG query is that the agent decides: it picks which tool to call, with which arguments and when it is done.

The component that coordinates all this is AgentWorkflow, released in January 2025 and built on the Workflow abstractions. It keeps state and context across steps, streams events in real time so you can see what the agent does, and manages task handoff when you have several specialised agents. You can use it with a single agent or set up a team that splits the work.

How do you move from RAG to an agent with tools?

A classic RAG flow is linear: question, retrieval, answer. It works when the answer sits in the documents, but falls short as soon as the task needs several steps, calculations or different sources. That is where the agent comes in, treating each capability as a tool and deciding on its own which ones to use and in what order.

Installing LlamaIndex is one command, either the meta package or just the components you need:

pip install llama-index-core llama-index-llms-openai

A tool can simply be a Python function with a docstring and type annotations; LlamaIndex reads that signature to know what it does and how to call it. Here is the minimal agent, a FunctionAgent with one tool and an async call:

from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

def multiply(a: float, b: float) -> float:
    """Multiply two numbers and return the result."""
    return a * b

agent = FunctionAgent(
    tools=[multiply],
    llm=OpenAI(model="gpt-4o-mini"),
    system_prompt="You are an agent that solves calculations with tools.",
)

response = await agent.run(user_msg="What is 5 times 3?")
print(response)

The agent takes the question, understands that it needs to multiply, calls the function with the right arguments and writes the final answer with the result. That loop of reason, act and observe is the heart of any agent.

How do FunctionAgent and ReActAgent differ?

Both live in llama_index.core.agent.workflow and inherit from the same base class, but they pick tools differently.

  • FunctionAgent relies on the model’s native function calling. The provider (OpenAI, Anthropic or Google) returns which tool to invoke and with which arguments directly in a structured field. It is the recommended option when your model supports function calling, because it is more reliable and uses fewer tokens.
  • ReActAgent implements the ReAct pattern (reasoning and acting): instead of a structured field, the model writes out its reasoning ("I need to look up X"), the action and the observation in text, and repeats the cycle. Its advantage is that it works with any model, even without a function API, including an open model you run locally with Ollama (a tool that serves open-weight language models on your own hardware, no cloud API required).

In practice, if you work with a commercial frontier model, use FunctionAgent. If you want an agent that runs on an open model on your own hardware, or you want to see the reasoning step by step, ReActAgent fits better. Switching between them is as easy as swapping the class, because they share the same tool and execution interface.

How do you build an agent over your documents?

This is where LlamaIndex shines: turning your existing RAG into an agent tool. You do it with QueryEngineTool, which wraps a query engine and gives it a name and description so the agent knows when to use it. The example below indexes a folder of documents and lets a FunctionAgent answer from them:

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.core.tools import QueryEngineTool
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

documents = SimpleDirectoryReader("./docs").load_data()
index = VectorStoreIndex.from_documents(documents)
engine = index.as_query_engine()

tool = QueryEngineTool.from_defaults(
    query_engine=engine,
    name="docs_search",
    description="Answers questions about the internal documentation.",
)

agent = FunctionAgent(
    tools=[tool],
    llm=OpenAI(model="gpt-4o-mini"),
    system_prompt="Answer only from the available documentation.",
)

response = await agent.run(user_msg="How do I configure backups?")
print(response)

The tool description is key, because it is what the model reads to decide whether this query is worth searching the documents or answering another way. With the same pattern you can add several tools (one per data source) and let the agent choose. And to coordinate several specialised agents, you define each one with its name and can_handoff_to parameters and group them in an AgentWorkflow with a root_agent acting as the entry point.

LlamaIndex or LangChain?

It is the inevitable comparison, and the short answer is that they solve problems with a different center of gravity. LlamaIndex is built around data: ingestion, indexing, retrieval and synthesis. According to IBM and several independent comparisons, it offers better out-of-the-box retrieval quality (up to 92% accuracy in a benchmark) and needs between 30% and 40% less code for an equivalent RAG.

LangChain, with its LangGraph layer, is designed for orchestrating complex agents: cyclical loops, state machines and coordination between sub-agents. LlamaIndex’s Workflow covers much of that, but orchestration remains its secondary goal, not its first.

That is why the most common production pattern is not to pick one but to combine them: LlamaIndex for the retrieval layer over your documents, inside an agent orchestrated with LangGraph. If your product is retrieval quality, start with LlamaIndex; if it is the decision logic across many tools and agents, lean on LangGraph. For a strict-typing approach to agent outputs, Pydantic AI is also worth a look.

Frequently asked questions

Is LlamaIndex free and open source?

Yes. LlamaIndex is an open-source project under the MIT license, so you can use, read and modify it at no cost. What does cost money is the language model you connect: if you use a commercial provider like OpenAI, you pay for the tokens the agent’s queries consume. With an open model you run on your own machine, that expense disappears and you only pay for hardware.

Do I need a vector database to use LlamaIndex?

Not to get started. VectorStoreIndex keeps embeddings in memory, which is enough for prototypes and small collections. When volume grows or you want persistence, you connect an external vector store (such as Chroma, Qdrant or pgvector) without changing the rest of the code. The abstraction is the same; only where the vectors live changes.

Can I use LlamaIndex with a local model instead of OpenAI?

Yes. LlamaIndex supports many providers, including Ollama for open models that run on your own hardware. For agents, keep in mind that FunctionAgent needs a model with solid function calling; if your local model does not support it well, use ReActAgent, which works with any model even if it reasons a bit worse on long tasks.

Conclusion

LlamaIndex lets you reuse all the indexing and retrieval work you already have and lift it into an agent that decides and acts. The path is clear: install the package, wrap your query engine in a QueryEngineTool, pick FunctionAgent or ReActAgent depending on your model and, if the task calls for it, coordinate several agents with AgentWorkflow. If your priority is retrieval quality over your own documents, it is one of the strongest options in 2026. The natural next step is to build the example over a real folder and compare FunctionAgent and ReActAgent with your own model.

Sources: [1] Official LlamaIndex documentation, agents[1], [2] llama_index on GitHub[2], [3] Introducing AgentWorkflow[3], [4] LlamaIndex vs LangChain, IBM[4].

Sources

  1. Official LlamaIndex documentation, agents
  2. llama_index on GitHub
  3. Introducing AgentWorkflow
  4. LlamaIndex vs LangChain, IBM

Route: Frameworks to Build AI Agents