Basic

Run a basic agent against a local LlamaCpp server and print its markdown response.

Code

from agno.agent import Agent, RunOutput  # noqa
from agno.models.llama_cpp import LlamaCpp

agent = Agent(model=LlamaCpp(id="ggml-org/gpt-oss-20b-GGUF"), markdown=True)

# Get the response in a variable
# run: RunOutput = agent.run("Share a 2 sentence horror story")
# print(run.content)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Start the llama.cpp server

Follow the installation steps, then start the server:

In a dedicated terminal, start an installed llama.cpp server:

llama-server -hf ggml-org/gpt-oss-20b-GGUF --ctx-size 0 --jinja -ub 2048 -b 2048

For a source build, run ./build/bin/llama-server from the llama.cpp directory with the same arguments. The command downloads and loads the GGUF model and serves http://127.0.0.1:8080/v1. Keep it running. Use a second terminal in your example directory, activate your Python environment there, and run the client steps below.

Install dependencies

uv pip install -U openai agno

Run Agent

Save the code above as basic.py, then run:

python basic.py