LlamaIndex, indexes, workflows and agents
LlamaIndex started as "the RAG framework" and that is still where it shines: loading messy documents, chunking them, indexing them and retrieving the right pieces. Over the last two years it grew an event driven Workflows engine and agent classes built on it, and the company around it offers hosted parsing (LlamaParse) and indexing (LlamaCloud). As of October 2026 llama-index-core is on the 0.14 line. If your hard problem is "get the model to answer from our documents", this is the first framework I would look at.
Why it matters
Most enterprise LLM projects are data projects in disguise. The model is fine; the PDFs are not. Tables, scanned pages, slide decks and nested headings all break naive chunking. LlamaIndex gives you:
- Readers for hundreds of sources (files, Notion, Slack, databases) via LlamaHub.
- Node parsers that split documents into chunks ("nodes") with metadata and relationships.
- Indexes, most commonly
VectorStoreIndex, backed by an in memory store or any of dozens of vector databases. - Retrievers and query engines with reranking, metadata filtering, sub question decomposition and more.
- Workflows, an async, event driven way to compose steps, used both for custom pipelines and for the built-in agents.
- Agents such as
FunctionAgentthat use your query engines as tools.
How it works
The data side is a pipeline from raw documents to a query engine.
Rendering diagram…
Workflows are the control side. A workflow is a class whose methods are decorated with @step. Each step takes an event and returns another event; the type annotations decide what runs next. A StartEvent carries the arguments you pass to run(), and returning a StopEvent ends the run. Because routing is driven by event types, you get branching, loops and parallel steps without drawing a graph by hand, and everything is async by default.
Reference architecture
A typical "chat with your documents" service splits offline ingestion from online querying.
Rendering diagram…
Keeping ingestion offline lets you re-chunk or re-embed without touching the serving path, and lets you evaluate retrieval quality separately from generation quality.
Code
First the classic five line RAG, then an agent that uses it as a tool. The agent code follows the current LlamaIndex agent tutorial.
import asyncio
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
# Index a folder of documents (uses OpenAI embeddings by default)
documents = SimpleDirectoryReader("./policies").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine(similarity_top_k=4)
async def search_policies(question: str) -> str:
"""Answer questions about company travel and expense policies."""
response = await query_engine.aquery(question)
return str(response)
def multiply(a: float, b: float) -> float:
"""Multiply two numbers and return the product."""
return a * b
agent = FunctionAgent(
tools=[search_policies, multiply],
llm=OpenAI(model="gpt-4o-mini"),
system_prompt="You answer expense questions using the policy tool. Cite the policy.",
)
async def main():
response = await agent.run(user_msg="What is the hotel cap for 3 nights in London?")
print(response)
asyncio.run(main())
And a custom workflow, using the standalone llama-index-workflows package (the same classes are also available under llama_index.core.workflow):
import asyncio
from workflows import Workflow, step
from workflows.events import Event, StartEvent, StopEvent
class DraftEvent(Event):
draft: str
class ReviewFlow(Workflow):
@step
async def write(self, ev: StartEvent) -> DraftEvent:
return DraftEvent(draft=f"Summary of {ev.topic}")
@step
async def review(self, ev: DraftEvent) -> StopEvent:
return StopEvent(result=ev.draft + " (reviewed)")
async def main():
result = await ReviewFlow(timeout=60).run(topic="Q3 incidents")
print(result)
asyncio.run(main())
In real code the write and review steps would call an LLM; the structure stays identical.
Trade-offs and pitfalls
- Defaults are for demos. The default chunk size, embedding model and top-k are reasonable starting points, not production settings. Evaluate retrieval with your own questions.
- Parsing is where quality is won. Complex PDFs often need a layout aware parser (LlamaParse or another). Budget time for it.
- Many packages. Integrations live in separate
llama-index-*packages. Pin them together, and check that a blog post's import paths match your version. - Async everywhere. Workflows and agents are async. In scripts, wrap calls in one
asyncio.runentry point; in notebooks you canawaitdirectly. - Overlap with LangChain. Both can do RAG and agents. Using LlamaIndex for retrieval and another framework for orchestration is common and fine; just keep one owner for the agent loop.
When to pick it: document heavy apps, complex ingestion, advanced retrieval (hierarchical, sub question, metadata filtering), or when you want hosted parsing and indexing from the same vendor.
When not to: your app has little or no retrieval, you need fine grained durable human in the loop control (LangGraph or a workflow engine fits better), or your stack is TypeScript first (LlamaIndex has a TS version, but the Python one leads).
Checklist
- Separate ingestion jobs from the online query path.
- Inspect parsed nodes for a sample of documents before indexing everything.
- Set chunk size, overlap, embedding model and top-k deliberately, and measure.
- Attach metadata (source, section, date) so you can filter and cite.
- Wrap query engines as tools rather than letting the agent query the vector store directly.
- Pin
llama-index-coreand integration packages to compatible versions. - Evaluate retrieval and generation separately.