How to Build a Local AI Agent with Agno and Ollama

Agno is a Python framework for building AI agents, and version 3 turned it into a platform for serving them. Pair it with Ollama and you get an agent that runs on your own machine: no API key, no per-token bill, and your prompts never leave your network. This guide builds that setup: install Agno 3 and Ollama, give a local model web search, add a custom tool, and finish with a two-agent team.

Agno started as Phidata and took its current name in January 2025. It is open source under the Apache-2.0 licence, has 42,000+ GitHub stars, and the current release is 3.0.10. Version 3.0 (24 August 2026) changed run storage and removed some 2.x options, so Agno 2 tutorials can fail on a fresh install. Everything below follows the Agno 3 docs.



Agno's AgentOS dashboard, where local agents become a served platform.

What you need

  • Python 3.9 or newer (the minimum in Agno's package metadata).
  • Ollama, installed and running. On macOS: brew install ollama. On Linux: curl -fsSL https://ollama.com/install.sh | sh. On Windows, download the installer from ollama.com/download.
  • About 4 GB of free disk, and 8 GB of RAM for usable speed.

Step 1: Pull a model that can call tools

An agent is only as good as its model's tool calling, and small models often skip the tool call and answer from memory. Qwen3.5 fits here: sizes run from 0.8B to 122B, it supports vision and tool use, and the flagship 397B scores 72.9 on BFCL V4, the standard tool-calling benchmark. The 4B version is the same design, sized for a laptop.



Qwen3.5 benchmark scores from the Ollama library page. The 397B flagship is shown; the 4B model in this guide is the same family, sized for a laptop.

Download it with:

ollama pull qwen3.5:4b
ollama run qwen3.5:4b

The download is about 3.4 GB. The second command opens a chat prompt; ask something, then type /bye to exit. Ollama keeps serving at localhost:11434 in the background, which is where Agno will find it.

Step 2: Install Agno

Create a virtual environment first, then install Agno plus the three helper packages the examples need:

python3 -m venv .venv
source .venv/bin/activate
pip install -U agno openai ollama ddgs

The openai package looks out of place in a local-only setup, but install it anyway: in Agno 3.0.10, importing the Ollama model fails with an ImportError when openai is missing, because the Ollama module imports the OpenAI one. The ddgs package backs the web search tool used later.

Step 3: Your first local agent

Save this as agent.py:

from agno.agent import Agent
from agno.models.ollama import Ollama
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=Ollama(id="qwen3.5:4b"),
    tools=[WebSearchTools()],
    instructions="Always cite your sources.",
    markdown=True,
)

agent.print_response(
    "Search what the Agno framework is and sum it up in two sentences",
    stream=True,
)

Run it with python agent.py. The agent decides when to search, calls the tool, then writes the summary. On a CPU-only machine with a 4B model, expect roughly 15 to 35 seconds: that is model inference time, not framework overhead. Independent tests measured about 4 microseconds and 5.5 KiB of memory to create an agent.

Two details matter here. Agno connects to Ollama at localhost:11434 by default, or at the address in the OLLAMA_HOST variable if Ollama runs on another machine. And if you swap providers later, only the model line changes: replace Ollama(...) with a cloud model, or use the short form model="ollama:qwen3.5:4b".

Step 4: Add a custom tool

Built-in toolkits cover search, finance, files, and over a hundred other integrations. Anything missing becomes a tool with a plain Python function: the docstring tells the agent when and how to use it.

def get_file_size(path: str) -> str:
    """Return the size of a file in bytes, or an error message."""
    import os
    if not os.path.exists(path):
        return f"File not found: {path}"
    return f"{path} is {os.path.getsize(path)} bytes."

Add it to the agent's tool list:

agent = Agent(
    model=Ollama(id="qwen3.5:4b"),
    tools=[WebSearchTools(), get_file_size],
    instructions="Always cite your sources.",
    markdown=True,
)

Ask the agent to check a real file and it will call the function, read the result, and answer with the number. Keep tools narrow: one function, one job, a docstring that states exactly what it returns.

Step 5: Scale to a two-agent team

One agent handles one job well. When a task splits into research and writing, give each half to a specialist and let a team leader coordinate them. Agno's Team does that with the same model behind both members:

from agno.agent import Agent
from agno.models.ollama import Ollama
from agno.team import Team
from agno.tools.websearch import WebSearchTools

model = Ollama(id="qwen3.5:4b")

researcher = Agent(
    name="Researcher",
    role="Find current facts and sources on the web",
    tools=[WebSearchTools()],
)

writer = Agent(
    name="Writer",
    role="Turn research notes into a short, clear summary",
)

team = Team(
    name="Research Team",
    model=model,
    members=[researcher, writer],
    instructions="Research the topic, then write a summary with sources.",
    markdown=True,
)

team.print_response(
    "What is the Agno framework, and why do developers use it?",
    stream=True,
)

Members inherit the team's model when they do not set their own, so one model line covers the whole team. The leader works in coordinate mode by default: it hands sub-tasks to members, then writes the final answer itself. Each member needs a name and a role, which the leader uses to decide who handles what.

This is close to what CrewAI calls a crew. The difference is emphasis: CrewAI guides you through roles and tasks, while Agno keeps the framework thin and adds a runtime for serving what you built. Our CrewAI and Ollama crew tutorial covers the other side of that choice, and our LangGraph vs CrewAI vs AutoGen comparison puts the three frameworks head to head.

Step 6 (optional): Serve the agent with AgentOS

An agent in a script is a demo. Agno 3 ships AgentOS, a runtime that serves agents, teams, and workflows through a REST API and an MCP server, with a web interface for sessions, traces, and model usage. Install it with pip install -U "agno[os]" and wrap your agent in AgentOS. If you later want the agent to remember past sessions, our Mem0 and Ollama memory guide shows how to add that piece.

Troubleshooting

  • ImportError when importing the Ollama model: install the openai package. Agno 3.0.10 needs it even for local-only use.
  • model 'qwen3.5:4b' not found: run ollama pull qwen3.5:4b first, then check with ollama list.
  • Answers crawl on a shared CPU: pass options={"num_thread": 6} to the Ollama model. The default takes every core, which can backfire on a busy machine.
  • Web search returns nothing: use WebSearchTools, not the older DuckDuckGoTools. In Agno 3 the DuckDuckGo toolkit wraps WebSearchTools, and its backend has been seen returning no results.
  • The agent answers without searching: small models sometimes skip tools. Restate the instruction as a direct order, for example "Search the web first, then answer", or move up to qwen3.5:9b if your machine has the RAM.

What you have now

That is the full stack: Ollama serving a local model, Agno wiring it to tools, and a team pattern you can extend with more specialists. It runs offline except for the web searches you ask for, and costs nothing per request. Next moves: add memory, connect a knowledge base of your own documents, or serve the agent through AgentOS so other apps can call it.

Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes