Tool Use

Run an Agno agent with WebSearchTools against a local Ollama llama3.2:latest model to answer a web search query.

Code

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

agent = Agent(
    model=Ollama(host="http://localhost:11434", api_key=None, id="llama3.2:latest"),
    tools=[WebSearchTools()],
    markdown=True,
)
agent.print_response("Whats happening in France?")

Usage

Set up your virtual environment

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

Start the local Ollama service

Install Ollama and start its desktop app or service on http://localhost:11434. If you start it manually with ollama serve, keep that process running in a separate terminal.

In the terminal where you will pull models and run Python, select that server and clear the direct-cloud key. The native Ollama client also reads this key independently of Agno.

export OLLAMA_HOST=http://localhost:11434
unset OLLAMA_API_KEY

Pull the model

ollama pull llama3.2:latest

Install dependencies

uv pip install -U ddgs ollama agno

Run Agent

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

python tool_use.py