Ooollaamaa!: Creating a local agent with Agno
We are becoming more reliant on AI. Why? Becuase it can (most of the time) do a task faster, more efficiently, and more accurately than us. More and more the topic of “Agents” is becoming popular. But what exactly are they?
What are agents?
To put it simply: agents are LLM’s that are given “tools” to interact with the oustide world. For example, an LLM might have a knowledge cutoff at December 2024, but given a search “tool”, it will be able to provide the latest information.
This makes agents really useful.
That’s why I’m going to show you how to create one yourself.
Note: some python knowledge needed
What are we going to use
I have found Agno to be a very great library with a wide variety of uses.
Ollama is an application that helps you run models on your local hardware.
What we are going to make
An agent that gets the weather for us lazy people.
1. Installation
This is the easy part. What you will need installed is:
1. Python — the python interpreter. I will personally use Miniconda to manage envs, but for starts the normal interpreter will be great.
2. Ollama the thing that will actually run models on your local machine.
3. Agno package — can be installed with
pip install -U agno4. Requests package — to fetch weather data. To install:
pip install requestsThat’s all we’ll need.
2. Downloading models with ollama
Okay, so we got the perquisites, we now have to choose what model to use.
People say (and through I myself have found) that the Qwen 2.5 family works pretty well with agentic tools, so throughout the tutorial I will be using the qwen2.5:14b model, as that is the largest one my GPU (a 1060) can handle out of the series. If your GPU is even less powerful than mineyou might want to use the smaller models, such as the qwen2.5:7b. If you are using a laptop or don’t have a GPU at all, there is theqwen2.5:0.5b or, if that proves to be a too dumb LLM, try out the qwen3:0.6b , which is basically the upgraded version of qwen2.5:0.5b .
To download a model, run:
ollama pull [model]In my case, it will be:
ollama pull qwen2.5:14bNote: this might take some time, as some models can weigh up to >12 GB, so 1. You will need at least that much free space and 2. You will need a good internet connection and finally 3. (optional) a cup of coffee.
Get gleb’s stories in your inbox
Join Medium for free to get updates from this writer.
After the model download process ends, you can close the terminal and head over to your code editor.
3. Creating an agent with Agno
Okay, now that we are really done with the perquisites, let’s write some code!
First we will import the needed libraries:
import requests
from agno.agent import Agent
from agno.models.ollama import Ollama
from datetime import dateExplanation:
- We will need the
requestslibrary to fetch data from the weather API - The datetime library is imported to (later on) tell the agent what time it is.
- The other two imports are described here https://docs.agno.com/concepts/models/ollama#example
Now we create a function that fetches the weather:
def fetch_weather_data(city):
'''
Fetch weather data for a given location.
Args:
city (str): The location to fetch weather data for (based on context).
Returns:
dict: A dictionary containing weather information.
'''
try:
geoData = requests.get(f"https://geocoding-api.open-meteo.com/v1/search?name={city}&count=1&language=en&format=json").json()
if not geoData['results'] or len(geoData['results']) == 0:
return {'content': [
{
'type': "text",
'text': f'Sorry, I couldn\'t find a city named {city}. Please check the spelling and try again.'
}
]}
coords = geoData['results'][0]
weatherData = requests.get(f"https://api.open-meteo.com/v1/forecast?latitude={coords["latitude"]}&longitude={coords["longitude"]}¤t_weather=true").json()
if not weatherData.get('current_weather'):
return {'content': [
{
'type': "text",
'text': f'Sorry, I couldn\'t fetch the weather data for {city} at the moment. Please try again later.'
}
]}
return {
'content': [
{
'type': "text",
'text': weatherData
}
]
}
except Exception as e:
return {'content': [
{
'type': "text",
'text': f'Sorry, there was an error fetching the weather data: {str(e)}'
}
]}And finally create a Agno agent:
agent = Agent(
model=Ollama(id="qwen2.5:14b"),
tools=[fetch_weather_data],
show_tool_calls=True,
markdown=True,
)The agent isn’t currently tasked with anything, so let’s send it a prompt:
agent.print_response(f"Can you give me the weather for [city]?",
reasoning=True,
stream=True,
show_full_thoughts=True,
show_full_reasoning=True,
stream_intermediate_steps=True)Now run the .py file (replace [city] with whatever).
Note: this will kinda slow down your computer unless you have really good hardware, so I recommend closing all other applications just in case. Or just run a smaller model.
Note 2: remember to start ollama, or else your app will crash (learned from experience)
You will (after some time) receive an output like the following:
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Can you give me the weather for Washington? ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Tool Calls ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ • fetch_weather_data(city=Washington) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Response (31.9s) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ The current weather in Washington is as follows: ┃
┃ ┃
┃ • Time: 22:30 (UTC) ┃
┃ • Temperature: 19.1°C ┃
┃ • Wind Speed: 10.5 km/h ┃
┃ • Wind Direction: 31° (North of East) ┃
┃ • Daytime: Yes (The sun is up) ┃
┃ • Weather Code: 3 (Light Rain) ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛Great! Everything works as expected.
4. Now what?
Now that the agent is working, we can improve it. You will notice that the model can some times make mistakes while using the tool(S) you give it.
This is a common problem and there have been very wise people before us who have figured out a solution: system prompts.
A system prompt is basically instructions that the model receives before any other prompt has been sent to it. It’s kinda like when your teacher explains to how to do the test (whether to use pen or pencil; wear nice clothes or come in whatever; are snacks allowed; etc.) before you actually do it.
Agno allows use to add a system prompt in the initilaztion of the agent, like this:
agent = Agent(
model=Ollama(id="qwen2.5:14b"),
instructions="[something right here]",
tools=[fetch_weather_data],
show_tool_calls=True,
markdown=True,
)We can use that with our own application.
agent = Agent(
model=Ollama(id="qwen2.5:14b"),
instructions=(f"""You are a helpful weather assistant. The current date is {today.isoformat()}, {today.strftime("%B %d, %Y")}. Use the `fetch_weather_data` tool to get the weather for the user. Respond with a happy and optimistic tone.
The `fetch_weather_data` tool recieves a single param called `city` which is a string of the city the user currently is. For cities that have same names (e.g. Sacramento, California and Sacramento, New Mexico) determine the city from the context."""),
tools=[fetch_weather_data],
show_tool_calls=True,
markdown=True,
)Conclusion
You have created a local weather agent with python. A nice thing to put on your resume. Otherwise a waste of time :)







