Skip to content

Instantly share code, notes, and snippets.

@svngoku
Created May 12, 2025 18:19
Show Gist options
  • Select an option

  • Save svngoku/ac729a3866a108be7046705efb180d8e to your computer and use it in GitHub Desktop.

Select an option

Save svngoku/ac729a3866a108be7046705efb180d8e to your computer and use it in GitHub Desktop.
agno

Agno Agent Library

Agno home pagelight logodark logo

Search or ask...

Ctrl K

Search...

Navigation

Introduction

What is Agno

User Guide Examples Workspaces FAQs API reference Changelog

Agno is a lightweight library for building Agents with memory, knowledge, tools and reasoning.

Developers use Agno to build Reasoning Agents, Multimodal Agents, Teams of Agents and Agentic Workflows. Agno also provides a beautiful UI to chat with your Agents, pre-built FastAPI routes to serve your Agents and tools to monitor and evaluate their performance.

Here’s an Agent that writes a report on a stock, reasoning through each step:

reasoning_finance_agent.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    tools=[\
        ReasoningTools(add_instructions=True),\
        YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True),\
    ],
    instructions=[\
        "Use tables to display data",\
        "Only output the report, no other text",\
    ],
    markdown=True,
)
agent.print_response("Write a report on NVDA", stream=True, show_full_reasoning=True, stream_intermediate_steps=True)

Here's the Reasoning Agent in action

Key features

Agno is simple, fast and model-agnostic. Here are some key features:

  • Model Agnostic: Agno Agents can connect to 23+ model providers, no lock-in.
  • Lightning Fast: Agents instantiate in ~3μs and use ~5Kib memory on average (see performance for more details).
  • Reasoning is a first class citizen: Make your Agents “think” and “analyze” using Reasoning Models, ReasoningTools or our custom chain-of-thought approach.
  • Natively Multi-Modal: Agno Agents are natively multi-modal, they can take in text, image, audio and video and generate text, image, audio and video as output.
  • Advanced Multi-Agent Architecture: Agno provides an industry leading multi-agent architecture ( Agent Teams) with 3 different modes: route, collaborate and coordinate.
  • Agentic Search built-in: Give your Agents the ability to search for information at runtime using one of 20+ vector databases. Get access to state-of-the-art Agentic RAG that uses hybrid search with re-ranking. Fully async and highly performant.
  • Long-term Memory & Session Storage: Agno provides plug-n-play Storage & Memory drivers that give your Agents long-term memory and session storage.
  • Structured Outputs: Agno Agents can return fully-typed responses using model provided structured outputs or json_mode.
  • Pre-built FastAPI Routes: Agno provides pre-built FastAPI routes to serve your Agents, Teams and Workflows.
  • Monitoring: Monitor agent sessions and performance in real-time on agno.com.

Getting Started

If you’re new to Agno, start by building your first Agent, chat with it on the playground and finally, monitor it on app.agno.com using this guide.

Build your first Agents \ \ Learn how to build Agents with Agno Agent Playground \ \ Chat with your Agents using a beautiful Agent UI

Agent Monitoring

Monitor your Agents on agno.com

After that, checkout the Examples Gallery and build real-world applications with Agno.

Dive deeper

Agno is a battle-tested framework with a state-of-the-art reasoning and multi-agent architecture, checkout the following guides to dive-in:

Agents \ \ Learn how to build lightning fast Agents. Teams \ \ Build autonomous multi-agent teams. Models \ \ Use any model, any provider, no lock-in. Tools \ \ 100s of tools to extend your Agents. Reasoning \ \ Make Agents “think” and “analyze”. Knowledge \ \ Give Agents domain-specific knowledge. Vector Databases \ \ Store and search your knowledge base. Storage \ \ Persist Agent session and state in a database. Memory \ \ Remember user details and session summaries. Embeddings \ \ Generate embeddings for your knowledge base. Workflows \ \ Deterministic, stateful, multi-agent workflows. Evals \ \ Evaluate, monitor and improve your Agents.

Your first Agents

On this page

Agent Playground Overview

Agno home pagelight logodark logo

Search or ask...

Ctrl K

Search...

Navigation

Introduction

Agent Playground

User Guide Examples Workspaces FAQs API reference Changelog

Agent Playground

No data is sent to agno.com, all agent data is stored locally in your sqlite database.

Running Playground Locally

Let’s run the playground application locally so we can chat with our Agents using the Agent UI. Create a file playground.py

playground.py

Copy

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.playground import Playground, serve_playground_app
from agno.storage.sqlite import SqliteStorage
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

agent_storage: str = "tmp/agents.db"

web_agent = Agent(
    name="Web Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[DuckDuckGoTools()],
    instructions=["Always include sources"],
    # Store the agent sessions in a sqlite database
    storage=SqliteStorage(table_name="web_agent", db_file=agent_storage),
    # Adds the current date and time to the instructions
    add_datetime_to_instructions=True,
    # Adds the history of the conversation to the messages
    add_history_to_messages=True,
    # Number of history responses to add to the messages
    num_history_responses=5,
    # Adds markdown formatting to the messages
    markdown=True,
)

finance_agent = Agent(
    name="Finance Agent",
    model=OpenAIChat(id="gpt-4o"),
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
    instructions=["Always use tables to display data"],
    storage=SqliteStorage(table_name="finance_agent", db_file=agent_storage),
    add_datetime_to_instructions=True,
    add_history_to_messages=True,
    num_history_responses=5,
    markdown=True,
)

app = Playground(agents=[web_agent, finance_agent]).get_app()

if __name__ == "__main__":
    serve_playground_app("playground:app", reload=True)

Remember to export your OPENAI_API_KEY before running the playground application.

Make sure the serve_playground_app() points to the file that contains your Playground app.

Authenticate with Agno

Authenticate with agno.com so your local application can let agno know which port you are running the playground on. Run:

No data is sent to agno.com, only that you’re running a playground application at port 7777.

Copy

ag setup

[or] export your AGNO_API_KEY from app.agno.com

Mac

Windows

Copy

export AGNO_API_KEY=ag-***

Run the playground app

Install dependencies and run your playground application:

Copy

pip install openai duckduckgo-search yfinance sqlalchemy 'fastapi[standard]' agno

python playground.py

View the playground

  • Open the link provided or navigate to http://app.agno.com/playground (login required)
  • Select the localhost:7777 endpoint and start chatting with your agents!

Open Source Agent UI

Looking for a self-hosted alternative? Check out our Open Source Agent UI - A modern Agent interface built with Next.js and TypeScript that works exactly like the Agent Playground.

agent-ui

Agent UI Interface

Get Started with Agent UI

Copy

# Create a new Agent UI project
npx create-agent-ui@latest

# Or clone and run manually
git clone https://github.com/agno-agi/agent-ui.git
cd agent-ui && pnpm install && pnpm dev

The UI will connect to localhost:7777 by default, matching the Playground setup above. Visit GitHub for more details.

Troubleshooting

We have identified that certain browsers may experience compatibility issues with the Agent Playground, potentially resulting in connection errors.

Brave Browser

Users may encounter difficulties connecting to localhost endpoints when using Brave, and the ag setup command might not work as expected. To resolve this issue, please try disabling Brave Shields in your browser settings.

Safari Browser

Similar connection issues have been reported with Safari when attempting to connect to localhost endpoints and running ag setup. While we are actively working on a solution, we kindly recommend using alternative browsers such as Chrome, Firefox, or Edge for the best experience.

Your first Agents Agent Monitoring

On this page

agent-ui

Agno Agents Overview

Agno home pagelight logodark logo

Search or ask...

Ctrl K

Search...

Navigation

Introduction

Your first Agents

User Guide Examples Workspaces FAQs API reference Changelog

What are Agents?

Agents are AI programs that operate autonomously.

The core of an Agent is the model, tools and instructions:

  • Model: is the brain of an Agent, helping it reason, act, and respond to the user.
  • Tools: are the body of an Agent, enabling it to interact with the real world.
  • Instructions: guide the Agent’s behavior. Better the model, better it is at following instructions.

Agents also have memory, knowledge, storage and the ability to reason:

  • Reasoning: enables Agents to “think” before responding and “analyze” the results of their actions (i.e. tool calls), this improves the Agents’ ability to solve problems that require sequential tool calls.
  • Knowledge: is domain-specific information that the Agent can search on demand to make better decisions and provide accurate responses. Knowledge is stored in a vector database and this search on demand pattern is known as Agentic RAG.
  • Storage: is used by Agents to save session history and state in a database. Model APIs are stateless and storage enables us to continue conversations from where they left off. This makes Agents stateful, enabling multi-turn conversations.
  • Memory: gives Agents the ability to store and recall information from previous interactions, allowing them to learn user preferences and personalize their responses.

Let’s build a few Agents to see how they work.

Basic Agent

The simplest Agent only contains a model and calls the model API to generate a response.

Agno provides a unified interface to 23+ model providers, so you can test different providers and switch models as needed.

basic_agent.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude

agent = Agent(model=Claude(id="claude-3-7-sonnet-latest"), markdown=True)
agent.print_response("What is the stock price of Apple?", stream=True)

To run the agent, install dependencies and export your ANTHROPIC_API_KEY.

1

Setup your virtual environment

Mac

Windows

Copy

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

2

Install dependencies

Mac

Windows

Copy

uv pip install -U agno anthropic

3

Export your Anthropic key

Mac

Windows

Copy

export ANTHROPIC_API_KEY=sk-***

4

Run the agent

Copy

python basic_agent.py

This Agent will not be able to give you the latest stock price because it doesn’t have access to it.

Agent with tools

Lets give the Agent a tool to fetch the latest stock price using the yfinance library.

agent_with_tools.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    tools=[YFinanceTools(stock_price=True)],
    markdown=True,
)
agent.print_response("What is the stock price of Apple?", stream=True)

Install dependencies and run the Agent

1

Install new dependencies

Mac

Windows

Copy

uv pip install -U yfinance

2

Run the agent

Copy

python agent_with_tools.py

Now the Agent will be able to give you the latest stock price.

Agent with instructions

The Agent will give you the latest stock price, but it will also yap along with it. To control the Agent’s output, we can and should add instructions.

agent_with_instructions.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    tools=[YFinanceTools(stock_price=True)],
    instructions=[\
        "Use tables to display data.",\
        "Only include the table in your response. No other text.",\
    ],
    markdown=True,
)
agent.print_response("What is the stock price of Apple?", stream=True)

Run the Agent

Copy

python agent_with_instructions.py

This will give you a much more concise response.

Set debug_mode=True or export AGNO_DEBUG=true to see the system prompt, user messages and tool calls.

Agent with reasoning

Agents can also “think” & “analyze” to solve problems that require more than one step. The ReasoningTools is one of the best “hacks” to improve the Agents’s response quality.

agent_with_reasoning.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    tools=[\
        ReasoningTools(add_instructions=True),\
        YFinanceTools(\
            stock_price=True,\
            analyst_recommendations=True,\
            company_info=True,\
            company_news=True,\
        ),\
    ],
    instructions=[\
        "Use tables to display data.",\
        "Include sources in your response.",\
        "Only include the report in your response. No other text.",\
    ],
    markdown=True,
)
agent.print_response(
    "Write a report on NVDA",
    stream=True,
    show_full_reasoning=True,
    stream_intermediate_steps=True,
)

Run the Agent

Copy

python agent_with_reasoning.py

Agent with knowledge

While models have a large amount of training data, we almost always need to give them domain-specific information to help them achieve their task. This knowledge isn’t just used for RAG, an emerging use case is to dynamically provide few-shot examples to the model.

Dynamic Few-Shot Learning: Text2Sql Agent

Example: You’re building a Text2Sql Agent and for best results, you’ll need to give the Agent table schemas, column names, data types, example queries, common “gotchas”, etc.

You’re not going to put this all in the system prompt, instead you’ll store this information in a vector database and let the Agent query it at runtime, based on the user’s question.

Using this information, the Agent can then generate the best-possible SQL query. This is called dynamic few-shot learning.

Agno Agents use Agentic RAG by default, which means they will search their knowledge base, at runtime, for the specific information they need to achieve their task.

Here’s how the following example works:

  • The UrlKnowledge will download the Agno documentation and load it into a LanceDB vector database, using OpenAI for embeddings
  • At runtime, the Agent will search the knowledge base for the most relevant information and use the ReasoningTools to reason about the user’s question.

agent_with_knowledge.py

Copy

from agno.agent import Agent
from agno.embedder.openai import OpenAIEmbedder
from agno.knowledge.url import UrlKnowledge
from agno.models.anthropic import Claude
from agno.tools.reasoning import ReasoningTools
from agno.vectordb.lancedb import LanceDb, SearchType

# Load Agno documentation in a knowledge base
knowledge = UrlKnowledge(
    urls=["https://docs.agno.com/introduction/agents.md"],
    vector_db=LanceDb(
        uri="tmp/lancedb",
        table_name="agno_docs",
        search_type=SearchType.hybrid,
        # Use OpenAI for embeddings
        embedder=OpenAIEmbedder(id="text-embedding-3-small", dimensions=1536),
    ),
)

agent = Agent(
    name="Agno Assist",
    model=Claude(id="claude-3-7-sonnet-latest"),
    instructions=[\
        "Use tables to display data.",\
        "Include sources in your response.",\
        "Search your knowledge before answering the question.",\
        "Only include the output in your response. No other text.",\
    ],
    knowledge=knowledge,
    tools=[ReasoningTools(add_instructions=True)],
    add_datetime_to_instructions=True,
    markdown=True,
)

if __name__ == "__main__":
    # Load the knowledge base, comment out after first run
    # Set recreate to True to recreate the knowledge base if needed
    agent.knowledge.load(recreate=False)
    agent.print_response(
        "What are Agents?",
        stream=True,
        show_full_reasoning=True,
        stream_intermediate_steps=True,
    )

Install dependencies, export your OPENAI_API_KEY and run the Agent

1

Install new dependencies

Mac

Windows

Copy

uv pip install -U lancedb tantivy openai

2

Run the agent

Copy

python agent_with_knowledge.py

Agent with storage

Storage drivers will help you save Agent sessions and state in a database. Model APIs are stateless and storage enables us to continue conversations from where they left off, by storing chat history and state in a database.

In this example, we’ll use the SqliteStorage driver to save the Agent’s session history and state in a database.

We’ll also set the session_id to a fixed value to demo persistence. Run this example multiple times to see the conversation continue from where it left off.

agent_with_storage.py

Copy

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.storage.sqlite import SqliteStorage
from agno.tools.duckduckgo import DuckDuckGoTools
from rich.pretty import pprint

agent = Agent(
    # This session_id is usually auto-generated
    # But for this example, we can set it to a fixed value
    # This session will now forever continue as a very long chat
    session_id="agent_session_which_is_autogenerated_if_not_set",
    model=Claude(id="claude-3-7-sonnet-latest"),
    storage=SqliteStorage(table_name="agent_sessions", db_file="tmp/agents.db"),
    tools=[DuckDuckGoTools()],
    add_history_to_messages=True,
    num_history_runs=3,
    add_datetime_to_instructions=True,
    markdown=True,
)

if __name__ == "__main__":
    print(f"Session id: {agent.session_id}")
    agent.print_response("How many people live in Canada?")
    agent.print_response("What is their national anthem?")
    agent.print_response("List my messages one by one")

    # Print all messages in this session
    messages_in_session = agent.get_messages_for_session()
    pprint(messages_in_session)

Install dependencies and run the Agent

1

Install new dependencies

Mac

Windows

Copy

uv pip install -U sqlalchemy duckduckgo-search

2

Run the agent

Copy

python agent_with_storage.py

Agent with memory

Memory drivers enable Agents to store and recall information about users from previous interactions, allowing them to learn user preferences and personalize their responses.

In this example, we’ll use the v2 Memory driver to store user memories in a Sqlite database.

Because memories are tied to a user, we’ll set the user_id to a fixed value to build a persona for the user.

agent_with_memory.py

Copy

from agno.agent import Agent
from agno.memory.v2.db.sqlite import SqliteMemoryDb
from agno.memory.v2.manager import MemoryManager
from agno.memory.v2.memory import Memory
from agno.models.anthropic import Claude
from agno.models.openai import OpenAIChat
from rich.pretty import pprint

user_id = "peter_rabbit"
memory = Memory(
    db=SqliteMemoryDb(table_name="memory", db_file="tmp/memory.db"),
    model=OpenAIChat(id="gpt-4o-mini"),
)
memory.clear()

agent = Agent(
    model=Claude(id="claude-3-7-sonnet-latest"),
    user_id=user_id,
    memory=memory,
    # Enable the Agent to dynamically create and manage user memories
    enable_agentic_memory=True,
    add_datetime_to_instructions=True,
    markdown=True,
)

if __name__ == "__main__":
    agent.print_response("My name is Peter Rabbit and I like to eat carrots.")
    memories = memory.get_user_memories(user_id=user_id)
    print(f"Memories about {user_id}:")
    pprint(memories)
    agent.print_response("What is my favorite food?")
    agent.print_response("My best friend is Jemima Puddleduck.")
    print(f"Memories about {user_id}:")
    pprint(memories)
    agent.print_response("Recommend a good lunch meal, who should i invite?")

Run the Agent

Copy

python agent_with_memory.py

Multi Agent Teams

Agents work best when they have a singular purpose, a narrow scope and a small number of tools. When the number of tools grows beyond what the language model can handle or the tools belong to different categories, use a team of agents to spread the load.

Agno provides an industry leading multi-agent Architecture that allows you to build Reasoning Agent Teams. You can run the team in 3 modes: route, coordinate and collaborate.

In this example, we’ll build a team of 2 agents to analyze the semiconductor market performance, reasoning step by step.

agent_team.py

Copy

from textwrap import dedent

from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.models.openai import OpenAIChat
from agno.team.team import Team
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

web_agent = Agent(
    name="Web Search Agent",
    role="Handle web search requests",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[DuckDuckGoTools()],
    instructions="Always include sources.",
    add_datetime_to_instructions=True,
)

finance_agent = Agent(
    name="Finance Agent",
    role="Handle financial data requests",
    model=OpenAIChat(id="gpt-4o-mini"),
    tools=[\
        YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)\
    ],
    instructions="Use tables to display data.",
    add_datetime_to_instructions=True,
)

team_leader = Team(
    name="Reasoning Finance Team Leader",
    mode="coordinate",
    model=Claude(id="claude-3-7-sonnet-latest"),
    members=[web_agent, finance_agent],
    tools=[ReasoningTools(add_instructions=True)],
    instructions=[\
        "Use tables to display data.",\
        "Only respond with the final answer, no other text.",\
    ],
    markdown=True,
    show_members_responses=True,
    enable_agentic_context=True,
    add_datetime_to_instructions=True,
    success_criteria="The team has successfully completed the task.",
)

task = """\
Analyze the semiconductor market performance focusing on:
- NVIDIA (NVDA)
- AMD (AMD)
- Intel (INTC)
- Taiwan Semiconductor (TSM)
Compare their market positions, growth metrics, and future outlook."""

team_leader.print_response(
    task,
    stream=True,
    stream_intermediate_steps=True,
    show_full_reasoning=True,
)

Install dependencies and run the Agent team

1

Install dependencies

Mac

Windows

Copy

uv pip install -U duckduckgo-search yfinance

2

Run the agent

Copy

python agent_team.py

Debugging

Want to see the system prompt, user messages and tool calls?

Agno includes a built-in debugger that will print debug logs in the terminal. Set debug_mode=True on any agent or set AGNO_DEBUG=true in your environment.

debugging.py

Copy

from agno.agent import Agent

agent = Agent(markdown=True, debug_mode=True)
agent.print_response("Share a 2 sentence horror story")

Run the agent to view debug logs in the terminal:

Copy

python debugging.py

What is Agno Agent Playground

On this page

Agent Monitoring Guide

Agno home pagelight logodark logo

Search or ask...

Ctrl K

Search...

Navigation

Introduction

Agent Monitoring

User Guide Examples Workspaces FAQs API reference Changelog

Monitor Your Agents

You can track your agents sessions and performance to ensure everything is working as expected. Agno provides built-in monitoring that you can access at app.agno.com.

Authenticate & Enable Monitoring

Step 1: Authenticate using cli or api key

To log agent sessions, you need to authenticate using one of these methods:

Method A: Log in using your command line interface

Copy

ag setup

Method B: Log using an API key

Get your API key from Agno App and use it to log agent sessions to your workspace.

Copy

export AGNO_API_KEY=your_api_key_here

Step 2: Enable Monitoring

After authentication, enable monitoring for a particular agent or globally for all agents.

Method A: For a Specific Agent

Copy

agent = Agent(markdown=True, monitoring=True)

Method B: Globally via Environment Variable

Copy

export AGNO_MONITOR=true

Step 3: Track Your Agent Sessions

Once monitoring is enabled, you can run your agent and view its session data:

  1. Create a file monitoring.py with this sample code:

Copy

from agno.agent import Agent

agent = Agent(markdown=True, monitoring=True)
agent.print_response("Share a 2 sentence horror story")
  1. Run your code locally

  2. View your sessions at app.agno.com/sessions

Facing issues? Check out our troubleshooting guide

Agent Playground Agno Community

On this page

Agno Community Support

Agno home pagelight logodark logo

Search or ask...

Ctrl K

Search...

Navigation

Introduction

Agno Community

User Guide Examples Workspaces FAQs API reference Changelog

Building something amazing with Agno?

Share what you’re building on X or join our Discord to connect with other builders and explore new ideas together.

Got questions?

Head over to our community forum for help and insights from the team.

Looking for dedicated support?

We’ve helped many companies turn ideas into production-grade AI products. Here’s how we can help you:

  1. Build agents tailored to your needs.
  2. Integrate your agents with your products.
  3. Monitor, improve and scale your AI systems.

Book a call to get started. Our prices start at $16k/month and we specialize in taking companies from idea to production in 3 months.

Agent Monitoring Introduction

On this page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment