AI / Machine Learning · 7 November 2026 · 12 min read
Building AI Agents with Agno: Models, Tools, Teams, Workflows and AgentOS
A practical guide to building AI agents with Agno using OpenAI, Ollama and custom model endpoints. Learn how to equip agents with tools, create custom functions, coordinate multi-agent teams, orchestrate workflows, and add memory and knowledge using AgentOS.
- Agno
- AI Agents
- Python
- Agentic AI
- LLM
- Multi-Agent Systems

Building AI Agents with Agno: Models, Tools, Teams, Workflows and AgentOS
Building an application around an LLM is relatively straightforward. You send a prompt, receive a response, and display it to the user.
But what happens when you want your application to do more?
Imagine building an assistant that can search the internet, query a database, execute Python functions, remember user preferences, retrieve information from documents, and delegate complex tasks to other specialized agents.
A simple LLM request-response architecture is no longer sufficient.
This is where agent frameworks become useful.
Agno is a Python SDK and agent platform for building AI agents, multi-agent teams, and workflows. It provides abstractions for connecting language models with tools, memory, knowledge bases, and external services.
In this tutorial, we'll explore Agno by building agents with different model providers, connecting tools, creating custom functions, and understanding how its larger components fit together.
By the end, you'll have a foundation for designing more capable AI applications.
1. What is Agno?
Agno is a framework for building and running AI agent systems.
Instead of manually implementing model interactions, tool execution, conversation history, and orchestration, Agno provides reusable components for these responsibilities.
Its core building blocks are:
| Component | Responsibility |
|---|---|
| Agent | Executes tasks using an LLM, instructions and tools |
| Team | Coordinates multiple specialized agents |
| Workflow | Orchestrates agents, teams and functions through defined steps |
| AgentOS | Serves and manages agents as an application runtime |
| Memory | Stores and retrieves user-specific information |
| Knowledge | Provides access to external documents and information |
One useful way to understand Agno is to separate the development and runtime layers.
- Agno SDK: Build agents, teams and workflows.
- AgentOS: Serve and operate those components.
- Control Plane: Inspect and manage your running agent platform.
Official documentation: Agno Documentation
2. Setting up the development environment
We'll use Python and uv for dependency management.
First, create a project:
mkdir agno-tutorial
cd agno-tutorial
uv init
uv venvActivate the virtual environment.
Windows PowerShell:
.venv\Scripts\Activate.ps1Linux/macOS:
source .venv/bin/activateInstall Agno and the model integrations:
uv pip install -U agno openai ollamaWe'll use the following project structure:
agno-tutorial/
│
├── agents/
│ ├── openai_agent.py
│ ├── ollama_agent.py
│ └── custom_model_agent.py
│
├── tools/
│ └── custom_tools.py
│
├── main.py
├── .env
└── pyproject.tomlFor API credentials, create a .env file or configure environment variables in your operating system.
Never commit API keys to GitHub.
3. Creating your first AI agent
An Agno agent typically consists of a model, instructions, optional tools, and other capabilities such as memory or knowledge.
Let's start with a basic agent.
from agno.agent import Agent
agent = Agent(
name="My First Agent",
instructions=[
"You are a helpful Python programming assistant.",
"Explain technical concepts using practical examples.",
"Keep responses clear and structured."
],
markdown=True
)
agent.print_response(
"Explain how Python decorators work."
)Here, we haven't explicitly configured a model. Agno supports model configuration through provider-specific integrations and model references.
For actual projects, explicitly selecting a model is preferable because it makes your model dependency clear.
Let's explore three approaches.
4. Using different model providers
One of the useful aspects of Agno is that you don't have to design your entire agent architecture around a single LLM provider.
You can use hosted models, locally running models, or compatible external inference endpoints.
4.1 OpenAI models
OpenAI provides hosted language models that can be integrated into Agno.
Install the required dependencies:
uv pip install -U agno openaiSet your API key:
export OPENAI_API_KEY="your-api-key"For Windows PowerShell:
$env:OPENAI_API_KEY="your-api-key"Create an agent:
from agno.agent import Agent
from agno.models.openai import OpenAIChat
agent = Agent(
name="OpenAI Assistant",
model=OpenAIChat(
id="gpt-5.4-mini"
),
instructions=[
"You are a technical assistant.",
"Provide accurate and practical explanations."
],
markdown=True
)
agent.print_response(
"Explain the architecture of an AI agent."
)The important part is:
model=OpenAIChat(id="gpt-5.4-mini")This tells Agno which model integration and model ID to use.
You can change the model ID according to your requirements and the models available to your account.
When should you use OpenAI?
- Applications requiring hosted inference.
- Complex reasoning and tool-use tasks.
- Applications where managing local model infrastructure isn't desirable.
- Prototypes that need a quick development setup.
Official guide: Agno OpenAI Models
4.2 Running local models with Ollama
Not every application needs to send its prompts to a hosted API.
Sometimes you want to experiment with open-weight models locally, reduce dependence on external inference services, or keep certain data within your development environment.
Ollama makes it possible to run supported language models locally.
First, install Ollama and download a model.
For this example, we'll use Llama 3.1 8B:
ollama pull llama3.1:8bMake sure the Ollama server is running.
Install the Python integration:
uv pip install -U agno ollamaNow create an agent:
from agno.agent import Agent
from agno.models.ollama import Ollama
agent = Agent(
name="Local AI Assistant",
model=Ollama(
id="llama3.1:8b"
),
instructions=[
"You are a helpful programming assistant.",
"Explain concepts with Python examples."
],
markdown=True
)
agent.print_response(
"Explain the difference between an AI agent and an LLM."
)That's it. The agent now uses your locally running Ollama model.
You can experiment with other models available through Ollama by changing the model ID.
For example:
- Llama
- Qwen
- Gemma
- DeepSeek
Actual tool-calling and structured-output support depends on the selected model and its compatibility with the Ollama integration.
When should you use Ollama?
- Local experimentation.
- Prototyping without a hosted inference API.
- Applications with local inference requirements.
- Comparing different open-weight models.
Keep in mind that local inference still requires sufficient hardware resources. Model size, quantization, context length and available memory all influence performance.
Official guide: Agno Ollama Models
4.3 Using custom models and endpoints
What if you want to use a model that isn't directly available through Agno's dedicated provider integrations?
For example, you might have:
- A model hosted on your own inference server.
- An OpenAI-compatible API from another provider.
- A self-hosted model endpoint.
- An inference service with a custom base URL.
Agno provides OpenAILike for providers exposing an OpenAI-compatible Chat Completions API.
Let's see how it works.
import os
from agno.agent import Agent
from agno.models.openai.like import OpenAILike
agent = Agent(
name="Custom Model Agent",
model=OpenAILike(
id="your-model-id",
api_key=os.environ["CUSTOM_MODEL_API_KEY"],
base_url="https://your-provider.com/v1"
),
instructions=[
"You are a helpful AI assistant.",
"Provide clear and structured responses."
],
markdown=True
)
agent.print_response(
"Explain retrieval augmented generation."
)Here are the important parameters:
| Parameter | Purpose |
|---|---|
id |
Model identifier provided by the inference service |
api_key |
Authentication credential |
base_url |
API endpoint |
instructions |
Agent behavior and task definition |
The model endpoint must support the API protocol expected by the selected integration.
Don't assume that every OpenAI-compatible endpoint supports every feature. Tool calling, structured outputs, streaming and other capabilities depend on the provider and model.
What if you have implemented an entirely custom model provider?
That's a different integration problem. You may need to implement an adapter compatible with Agno's model interface rather than simply changing the base URL.
Official guide: OpenAI-Compatible Models
Comparing the three approaches
| Feature | OpenAI | Ollama | Custom endpoint |
|---|---|---|---|
| Hosting | Managed API | Local or cloud | Provider-dependent |
| API key | Required | Local setup can work without one | Usually required |
| Infrastructure | Provider-managed | Your responsibility for local inference | Provider-dependent |
| Flexibility | Provider model catalog | Supported Ollama models | Compatible endpoints |
| Best use | Hosted applications | Local experimentation | Custom infrastructure |
The model provider is only one part of an agent. The next step is giving it the ability to interact with the outside world.
5. Giving agents tools
An LLM can generate text, but an agent becomes considerably more useful when it can execute functions and interact with external systems.
Tools are functions that an agent can call when needed.
For example, an agent might need to:
- Search the internet.
- Calculate mathematical expressions.
- Retrieve stock information.
- Query a PostgreSQL database.
- Read and write files.
- Execute Python code.
- Interact with external APIs.
Agno supports Python functions and pre-built toolkits.
5.1 Some useful built-in toolkits
Agno has a large collection of integrations.
Here are some useful examples:
| Toolkit | Purpose |
|---|---|
| DuckDuckGoTools | Search the web |
| HackerNewsTools | Retrieve Hacker News stories |
| YFinanceTools | Retrieve financial market data |
| CalculatorTools | Perform calculations |
| PythonTools | Execute Python code |
| FileTools | Work with files |
| SQLTools | Interact with SQL databases |
| PostgresTools | Work with PostgreSQL |
| ShellTools | Execute shell commands |
| DockerTools | Interact with Docker |
You can explore the available integrations in the Agno Toolkit Index.
5.2 Adding tools to an agent
Let's create a research assistant that can search the web.
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
agent = Agent(
name="Research Assistant",
model=OpenAIChat(id="gpt-5.4-mini"),
tools=[
DuckDuckGoTools()
],
instructions=[
"You are a research assistant.",
"Use web search when current information is required.",
"Summarize relevant findings clearly."
],
markdown=True
)
agent.print_response(
"Find recent developments in AI agents."
)Notice that we didn't manually call the search function.
The model can decide when a tool is necessary, request its execution, and use the returned information to formulate a response.
This is one of the fundamental ideas behind tool-using agents.
5.3 Creating custom tools
Built-in integrations are useful, but real applications often need custom functionality.
Suppose you're building an order management assistant. It should be able to retrieve order information from your own database or backend.
You can expose a regular Python function as an agent tool.
def get_order_status(order_id: str) -> dict:
"""
Retrieve the status of an order.
Args:
order_id: Unique order identifier.
"""
# Example data.
# Replace this with a database or API query.
orders = {
"ORD101": {
"status": "Shipped",
"delivery": "2026-11-10"
},
"ORD102": {
"status": "Processing",
"delivery": "Pending"
}
}
return orders.get(
order_id,
{"error": "Order not found"}
)Attach the function to an agent:
from agno.agent import Agent
from agno.models.openai import OpenAIChat
agent = Agent(
name="Order Assistant",
model=OpenAIChat(id="gpt-5.4-mini"),
tools=[
get_order_status
],
instructions=[
"Help customers retrieve their order information.",
"Use get_order_status when an order ID is provided.",
"Never invent order information."
],
markdown=True
)
agent.print_response(
"Can you check the status of ORD101?"
)Agno uses the function name, docstring, parameter information and type hints to expose the function to the model.
This means you can integrate existing Python business logic into your agent applications without rewriting everything as an LLM-specific tool.
A practical recommendation: Keep your custom tools small, focused and predictable. Validate inputs, handle exceptions and enforce permissions inside the function itself.
5.4 Organizing custom tools with Toolkits
As applications grow, putting every function directly into an agent can become difficult to maintain.
Agno also provides the Toolkit class for grouping related functions.
from agno.tools import Toolkit
class OrderTools(Toolkit):
def __init__(self, **kwargs):
super().__init__(
name="order_tools",
tools=[
self.get_order_status,
self.get_order_details
],
**kwargs
)
def get_order_status(self, order_id: str) -> str:
"""Get the current status of an order."""
return f"Order {order_id} is processing."
def get_order_details(self, order_id: str) -> dict:
"""Retrieve order details."""
return {
"order_id": order_id,
"total": 1200,
"currency": "INR"
}Now attach the toolkit:
agent = Agent(
name="Order Assistant",
model=OpenAIChat(id="gpt-5.4-mini"),
tools=[OrderTools()]
)Toolkits are particularly useful when several related functions share state or belong to the same business domain.
Documentation:
6. Understanding multi-agent teams
A single agent can handle many tasks, but some problems benefit from multiple specialized agents.
Consider a research application.
Instead of asking one agent to search for information, analyze it, verify sources and prepare a report, you could create three specialized agents:
- Research Agent – gathers information.
- Analysis Agent – evaluates the findings.
- Writing Agent – prepares the final report.
Agno provides the Team abstraction to coordinate multiple agents.
Here's a basic example:
from agno.agent import Agent
from agno.team import Team
from agno.models.openai import OpenAIChat
researcher = Agent(
name="Researcher",
model=OpenAIChat(id="gpt-5.4-mini"),
instructions="Research the given topic."
)
analyst = Agent(
name="Analyst",
model=OpenAIChat(id="gpt-5.4-mini"),
instructions="Analyze information and identify important findings."
)
writer = Agent(
name="Writer",
model=OpenAIChat(id="gpt-5.4-mini"),
instructions="Write a structured report based on research findings."
)
team = Team(
name="Research Team",
model=OpenAIChat(id="gpt-5.4-mini"),
members=[
researcher,
analyst,
writer
],
instructions=[
"Coordinate the members to complete the research task.",
"Combine their findings into a useful final report."
],
markdown=True
)
team.print_response(
"Research the current applications of computer vision."
)The team leader coordinates the members and synthesizes their outputs.
Team execution modes
Agno supports different coordination strategies:
| Mode | Description |
|---|---|
| Coordinate | Leader decides how to delegate and combine work |
| Route | Directs a task to the appropriate member |
| Broadcast | Sends a task to multiple members |
| Tasks | Organizes work into delegated tasks |
You should choose a mode based on the actual requirements of your application.
A team is not automatically better than a single agent. Each additional agent can introduce more model calls, latency, token consumption and coordination complexity.
Use teams when specialization and collaboration provide measurable value.
Documentation: Building Teams with Agno
7. Workflows: Orchestrating agents and functions
Teams are useful when an LLM should coordinate other agents.
But what if you already know the exact sequence of operations?
For example, consider a document-processing pipeline:
- Receive a document.
- Extract its content.
- Analyze the extracted information.
- Generate a structured report.
This is a workflow.
Agno Workflows let you orchestrate agents, teams and Python functions through defined execution steps.
A workflow can include:
- Sequential execution.
- Parallel execution.
- Conditional branches.
- Loops.
- Nested workflows.
Here's a simple example:
from agno.agent import Agent
from agno.workflow import Workflow
from agno.models.openai import OpenAIChat
researcher = Agent(
name="Researcher",
model=OpenAIChat(id="gpt-5.4-mini"),
instructions="Research the given topic."
)
writer = Agent(
name="Writer",
model=OpenAIChat(id="gpt-5.4-mini"),
instructions="Write an article based on the research."
)
content_workflow = Workflow(
name="Content Creation",
steps=[
researcher,
writer
]
)
content_workflow.print_response(
"Write an article about the applications of AI in healthcare."
)The researcher runs first, and the writer receives the previous step's output.
This creates a repeatable process without requiring one agent to dynamically decide every operation.
Team vs Workflow
| Requirement | Recommended abstraction |
|---|---|
| One agent can complete the task | Agent |
| Multiple specialized agents need to collaborate | Team |
| Fixed sequence of operations | Workflow |
| Conditional execution and branching | Workflow |
| Dynamic delegation | Team |
A useful design principle is to use the simplest abstraction that solves your problem.
Documentation: Agno Workflows
8. Memory: Making agents remember users
An agent without persistent memory generally has limited knowledge of previous interactions.
Imagine a personal assistant that forgets your preferences every time you start a new conversation.
Memory helps solve this problem.
Agno supports storing user-specific information that can be recalled in subsequent conversations.
Examples include:
- User preferences.
- Frequently discussed projects.
- Communication preferences.
- Recurring goals.
- Useful information shared in previous sessions.
Let's create an agent with persistent memory.
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
db = SqliteDb(
db_file="tmp/agent_memory.db"
)
agent = Agent(
name="Personal Assistant",
model=OpenAIChat(id="gpt-5.4-mini"),
db=db,
enable_agentic_memory=True,
instructions=[
"You are a personal assistant.",
"Remember useful user preferences and recurring goals."
],
markdown=True
)
agent.print_response(
"I prefer Python for my AI projects.",
user_id="user-001",
session_id="session-001"
)Here, enable_agentic_memory=True allows the agent to decide when to create or update user memories through its memory tools.
Agno also supports automatic memory updates using update_memory_on_run=True.
These are different memory modes, and you should choose the one that fits your application's requirements.
Memory vs Chat History vs Session State
These concepts are related but serve different purposes.
| Concept | What it stores |
|---|---|
| Memory | Useful facts about a user across sessions |
| Chat History | Previous messages and tool interactions |
| Session State | Application data associated with a session |
For example:
- Memory: The user prefers Python.
- Chat history: The previous conversation about building an OCR pipeline.
- Session state: The current document-processing task is awaiting review.
Memory is especially useful for personal assistants and applications where users return frequently.
Documentation: Agno Memory
9. Knowledge: Connecting agents to your documents
Memory and knowledge are not the same thing.
Memory focuses on information about users and their interactions.
Knowledge provides agents with access to external information such as documents, URLs, and domain-specific content.
This is particularly useful when building Retrieval-Augmented Generation (RAG) applications.
Imagine building an assistant for a company that needs to answer questions using internal documentation.
Instead of relying entirely on the model's training data, you can create a knowledge base and retrieve relevant information when answering questions.
Agno supports knowledge integrations with vector databases.
Here's a basic example using ChromaDB:
from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.vectordb.chroma import ChromaDb
knowledge = Knowledge(
vector_db=ChromaDb(
collection="company_docs",
path="tmp/chromadb",
persistent_client=True
)
)
# Insert documentation into the knowledge base
knowledge.insert(
url="https://docs.agno.com/introduction.md"
)
agent = Agent(
name="Documentation Assistant",
knowledge=knowledge,
search_knowledge=True,
instructions=[
"Answer questions using the available documentation.",
"Do not invent information that is not supported by the sources."
],
markdown=True
)
agent.print_response(
"What is Agno?"
)The general knowledge retrieval process looks like this:
- Load documents into the knowledge base.
- Split content into smaller chunks.
- Generate embeddings.
- Store the embeddings in a vector database.
- Retrieve relevant content when a user asks a question.
- Provide the retrieved information to the model as context.
Depending on the vector database and configuration, you can also use hybrid search to combine semantic and keyword retrieval.
For production applications, retrieval quality, chunking, embedding selection and source attribution all deserve careful evaluation.
Documentation: Agno Knowledge
10. AgentOS: Running agents as services
So far, we've created agents that execute through Python scripts.
But how do we expose these agents to a frontend application?
For example, suppose you want to build a Next.js application where users can interact with an AI assistant.
You need an API layer, session management, persistence, authentication and a way to monitor agent execution.
This is where AgentOS comes in.
AgentOS is Agno's runtime for serving agents, teams and workflows through a FastAPI application.
It provides capabilities such as:
- REST APIs for agents, teams and workflows.
- Session and state persistence.
- Authentication and role-based access control.
- Tracing and execution monitoring.
- Streaming responses.
- Background execution.
- Human approval flows.
- MCP and other interfaces.
Creating an AgentOS application
Let's expose an agent through AgentOS.
Install the required packages:
uv pip install -U "agno[os,sqlite]" openaiCreate agent_os.py:
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIResponses
from agno.os import AgentOS
db = SqliteDb(
db_file="tmp/agentos.db"
)
assistant = Agent(
id="assistant",
name="AI Assistant",
model=OpenAIResponses(
id="gpt-5.4"
),
db=db,
instructions=[
"You are a helpful AI assistant."
]
)
agent_os = AgentOS(
id="my-agent-platform",
agents=[assistant],
db=db,
tracing=True
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(
app="agent_os:app",
reload=True
)Run the application:
python agent_os.pyYour local AgentOS runtime will be available at:
http://localhost:7777You can explore the available endpoints:
| Endpoint | Purpose |
|---|---|
/health |
Runtime health check |
/info |
Runtime information |
/config |
Runtime configuration |
/docs |
Interactive API documentation |
The runtime also exposes endpoints for executing registered agents, teams and workflows.
Your frontend can communicate with these APIs instead of implementing model interactions directly.
How does AgentOS fit into an application?
A simplified architecture might look like this:
Next.js Frontend
|
|
HTTP / SSE
|
v
AgentOS Runtime
|
+-------+-------+
| | |
v v v
Agent Team Workflow
| | |
+-------+-------+
|
+-------+-------+
| | |
v v v
Models Tools Knowledge
|
v
DatabaseThe frontend handles the user interface, while AgentOS provides the runtime and API layer for your agent system.
For a production application, configure authentication, CORS, user isolation, database persistence and appropriate authorization before exposing the runtime publicly.
Documentation: AgentOS Runtime
11. Putting everything together: What can you build?
Now that we've explored the individual components, let's think about practical applications.
Example 1: AI research assistant
Components:
- OpenAI or Ollama model.
- DuckDuckGo search tools.
- Custom research functions.
- Multiple agents for research and analysis.
- Workflow for report generation.
- Memory for user preferences.
Possible functionality:
A user submits a research topic. The system searches for relevant information, analyzes findings, organizes sources and generates a structured report.
Example 2: Intelligent document assistant
Components:
- Multimodal or text-based model.
- Custom document-processing tools.
- Knowledge base with vector search.
- Memory for user preferences.
- AgentOS for API access.
Possible functionality:
Users upload documents and ask questions. The system retrieves relevant information, extracts structured data and provides answers grounded in the available documents.
Example 3: Business automation assistant
Components:
- Hosted or self-hosted LLM.
- Custom API and database tools.
- Specialized agents.
- Workflow orchestration.
- AgentOS for serving the application.
Possible functionality:
A business assistant can retrieve customer records, generate reports, organize tasks and coordinate predefined business processes.
These examples are architectural starting points, not complete production implementations. Each requires appropriate authorization, validation, error handling and evaluation.
12. Important considerations before production
Building an agent that works in a local demonstration is different from operating one for real users.
There are several areas worth considering.
1. Tool security
Never give an agent unrestricted access to your operating system, database or external services.
Validate tool inputs and enforce permissions inside the tools themselves.
2. Model selection
Evaluate models based on tool-calling reliability, reasoning, latency, cost and output quality.
A larger model isn't necessarily the best choice for every task.
3. Memory management
Don't store every conversation as a permanent memory.
Decide what information is useful, how long it should be retained and how users can manage it.
4. Knowledge retrieval
Poor document chunking and retrieval can produce incorrect answers even when the underlying model is capable.
Evaluate retrieval quality independently from generation quality.
5. Observability
Monitor tool calls, failed executions, latency, token usage and unexpected behavior.
AgentOS provides tracing and evaluation capabilities that can help with this process.
6. Human approval
Actions such as sending emails, modifying financial records or deleting data should have appropriate permission checks and approval mechanisms.
An agent should not automatically receive permission to perform every action it can technically execute.
Conclusion
Agno provides a useful foundation for moving from simple LLM applications toward more capable agent-based systems.
Its biggest advantage is the way it brings several important concepts together.
You can start with a single agent, connect it to OpenAI or a local Ollama model, add Python functions and toolkits, and gradually introduce memory, knowledge, teams and workflows.
When your application grows beyond a Python script, AgentOS provides a runtime for exposing and managing those components through APIs.
My recommendation is to learn these concepts incrementally:
- Build a basic agent with OpenAI.
- Switch the model to Ollama.
- Connect a few built-in tools.
- Write your own Python tools.
- Experiment with teams and workflows.
- Add persistent memory and document-based knowledge.
- Expose your application through AgentOS.
Don't start by building a large multi-agent architecture. Start with one useful agent, understand how it executes tools, and introduce additional abstractions only when the problem requires them.
The interesting part of agent engineering isn't simply connecting an LLM to a collection of tools. It's designing a reliable system in which models, tools, data and execution logic work together.
References
Aditya Manoj Shinde
Author
I'm Aditya, a developer passionate about AI, Machine Learning, and software development. I love exploring new technologies, building projects, and sharing what I learn along the way.