Tools are functions that an Agent can call to interact with the external world.

Tools make agents - “agentic” by enabling them to interact with external systems like searching the web, running SQL, sending an email or calling APIs.

Agno comes with 80+ pre-built toolkits, but in most cases, you will write your own tools. The general syntax is:

import random

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools import tool


@tool(show_result=True, stop_after_tool_call=True)
def get_weather(city: str) -> str:
    """Get the weather for a city."""
    # In a real implementation, this would call a weather API
    weather_conditions = ["sunny", "cloudy", "rainy", "snowy", "windy"]
    random_weather = random.choice(weather_conditions)

    return f"The weather in {city} is {random_weather}."


agent = Agent(
    model=OpenAIChat(model="gpt-4o-mini"),
    tools=[get_weather],
    markdown=True,
)
agent.print_response("What is the weather in San Francisco?", stream=True)

In the example above, the get_weather function is a tool. When it is called, the tool result will be shown in the output because we set show_result=True.

Then, the Agent will stop after the tool call because we set stop_after_tool_call=True.

Read more about: