LlamaIndex Agents
What it is
LlamaIndex is a framework for building applications that use a language model with your own data. Its agents are systems that use an LLM, memory, and tools to handle inputs from outside users. The docs define an agent as a specific system that uses those three things together, and the current way to build one is with FunctionAgent and AgentWorkflow.
LlamaIndex is best known for retrieval-augmented generation (RAG): indexing documents, searching them, and grounding answers in what was found. Its agents build on that strength. An agent can search your documents, call a tool, and answer from the results, rather than only from what the model already knows. That makes it a natural choice when the agent’s job is to answer questions about your own content.
Who made it
LlamaIndex is made by LlamaIndex, Inc. The documentation is at developers.llamaindex.ai, and the source is on GitHub under the run-llama organisation.
- Official docs: https://developers.llamaindex.ai/python/framework/module_guides/deploying/agents/
- GitHub: https://github.com/run-llama/llama_index
What it does
LlamaIndex agents can search the web, query a database, calculate, read files, and retrieve from a document index. Tools can be defined simply as Python functions, or customised with classes such as FunctionTool and QueryEngineTool. LlamaIndex also provides pre-defined tools for common APIs through Tool Specs, and a large hub of integrations called LlamaHub for models, data loaders, and tools.
Agents support memory through ChatMemoryBuffer, which you can configure with a token limit, and streaming, so you can show the answer as it is generated. You can combine agents into a multi-agent system, where each agent can hand off control to another agent. There are different agent types for different prompting strategies: FunctionAgent uses the model’s function-calling ability, while ReActAgent and CodeActAgent use different prompting approaches to execute tools.
How it works
You create a FunctionAgent with tools, a language model, and a system prompt, then run it with agent.run("Your question"). Calling the agent starts a loop: the agent gets the latest message and chat history, the tool schemas and history are sent to the model, and the model either responds directly or returns a list of tool calls. Every tool call is executed, the results are added to the history, and the agent is invoked again with the updated history until it can answer.
For multi-agent work, you create an AgentWorkflow with a list of agents. Each agent can hand off to another, and the workflow coordinates the handoff. By default, a FunctionAgent is stateless between runs, so it does not remember earlier runs. To keep state, you pass a Context object between runs; the context is serialisable, so it can be saved to a database or a file and loaded later. In TypeScript, the equivalent is the agent and multiAgent functions from @llamaindex/workflow.
How to start
- Install LlamaIndex with
pip install llama-indexin Python. Check the official docs for the current install command and for the TypeScript package if you use JavaScript. - Set your model API key as an environment variable, for example
OPENAI_API_KEYfor OpenAI. - Define a tool as a Python function with a clear name, docstring, and typed arguments. The docs stress that the name, description, and types matter, because the model uses them to decide when to use the tool.
- Create an agent with
FunctionAgent(tools=[your_tool], llm=OpenAI(model="gpt-4o"))— use the model name from the current docs — and run it withawait agent.run("Your question"). - Add memory with
ChatMemoryBufferwhen the agent needs to remember earlier turns, and add a second agent in anAgentWorkflowwhen a task needs a handoff. - When the agent needs your documents, read the RAG guides in the docs and index a small set of documents first.
Follow the Agents guide in the official docs for your language, because the Python and TypeScript APIs differ.
Who it is for
LlamaIndex Agents are for Python and TypeScript developers who want an agent that answers from their own data. It suits support agents over documentation, research assistants over a document set, and internal tools that need to search files before answering. It is a code framework, not a no-code builder, and it is a good fit if you already use LlamaIndex for RAG and want agents on top of the same indexes and tools.
Watch out for
LlamaIndex has changed its agent API over time: older examples use AgentRunner and older agent classes, while the current docs use FunctionAgent and AgentWorkflow. Check the version you installed and follow the current docs. Agents are stateless by default, so do not assume an agent remembers earlier runs unless you pass a Context. Tool quality matters: a vague docstring or missing type annotation leads to wrong tool calls. Costs depend on the model and how many retrieval and tool calls the agent makes, so test with a small document set and a small task first. Finally, an agent is only as good as its index — if your documents are out of date, the agent’s answers will be too.