
llama-cpp-agent
Python framework for function calling, structured output and RAG with local LLMs
llama-cpp-agent is an open-source agent framework for developer tools. It is available on API, Self-hosted, Linux, macOS and Windows.
- Pricing
- Open source
- Platforms
- API, Self-hosted, Linux
- GitHub stars
- 669
- Last commit
- Language
- Python
- Built with
- llama-cpp-python
Similar agents
About llama-cpp-agent
Rather than requiring models fine-tuned for tool use, this Python library constrains generation with grammars and JSON schemas, so many smaller open-weight models can call functions and return typed objects. It wraps chat, function calling, structured output, retrieval augmented generation with ColBERT reranking, and multi-step agent chains behind a single set of classes.
Tools can be plain Python functions, Pydantic models, llama-index tools or OpenAI-style tool schemas. Prompts are formatted through a built-in set of chat templates for common open models, and custom templates can be defined with prompt markers. It connects to llama-cpp-python, the llama.cpp server, and TGI or vLLM servers.
The project is aimed at Python developers who run their own inference backends and want agent behaviour without a hosted API. The maintainer notes that the project is no longer maintained and points users to ToolAgents or other Python agent frameworks for new work.
What it does
- Guided function calling
- Constrains model output to user-defined schemas so models not tuned for tool use can call functions.
- Structured output
- Generates typed objects from unstructured text using Pydantic-style definitions.
- Parallel function execution
- Runs several function calls from a single model turn concurrently.
- Retrieval augmented generation
- Adds document retrieval with ColBERT reranking via an optional dependency.
- Sequential and mapping chains
- Chains agents together for multi-step text processing, including per-item mapping.
- Multiple inference backends
- Works with llama-cpp-python, the llama.cpp server, TGI and vLLM servers.
Good for
- Adding tool calling to a local open-weight model without fine-tuning
- Extracting structured records such as book entries from raw text
- Summarising several articles into one result with a mapping chain
- Building a retrieval pipeline over local documents with reranking
- Generating multi-step campaign content through a sequential chain
Pricing
Open source
Free and open source under the MIT License; self-hosted.
llama-cpp-agent FAQ
How do I install the optional RAG dependencies?
Run pip install llama-cpp-agent[rag], which adds the ragatouille dependency needed for the RAG reranker.
Which inference servers does llama-cpp-agent work with?
It works with llama-cpp-python and its server, the llama.cpp server, and TGI and vLLM servers.
Is the project still maintained?
No. The maintainer says it is no longer maintained and recommends ToolAgents or other Python agentic frameworks.
Is llama-cpp-agent free?
Yes. llama-cpp-agent is open source, so you can use and self-host it for free.
What are the best alternatives to llama-cpp-agent?
The closest alternatives to llama-cpp-agent are smolagents, llama-agents, DemoGPT, pydantic-ai and agentic-context-engine.
Where this comes from
- Description: written from the project's README.



