agno

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Agno AI Framework Skill

Agno AI Framework 技能指南

Expert assistance for building production-ready multi-agent AI systems using Agno - an incredibly fast multi-agent framework with runtime and control plane.
本指南提供专业指导,助你使用Agno构建可投入生产的多Agent AI系统——Agno是一款兼具运行时环境和控制平面的超快速多Agent框架。

When to Use This Skill

何时使用本技能

This skill should be used when:
  • Building AI agents or multi-agent systems
  • Implementing RAG (Retrieval-Augmented Generation) solutions
  • Creating autonomous AI workflows and pipelines
  • Deploying agents to production with AgentOS
  • Working with LLM-powered applications
  • Questions about Agno framework, agents, teams, or workflows
  • Implementing tools, memory, knowledge bases, or storage for agents
  • Integrating with various LLM providers (Anthropic, OpenAI, Google, etc.)
  • Debugging or optimizing Agno-based applications
  • Setting up production deployment with authentication and monitoring
在以下场景中可使用本技能:
  • 构建AI Agent或多Agent系统
  • 实现RAG(检索增强生成)解决方案
  • 创建自主AI工作流与流水线
  • 通过AgentOS将Agent部署到生产环境
  • 开发基于LLM的应用程序
  • 关于Agno框架、Agent、团队或工作流的相关问题
  • 为Agent实现工具、记忆、知识库或存储功能
  • 集成各类LLM提供商(Anthropic、OpenAI、Google等)
  • 调试或优化基于Agno的应用
  • 搭建带认证与监控的生产部署环境

Overview

概述

Agno is an open-source framework for building, deploying, and managing multi-agent AI systems that emphasizes:
  • Performance: 529× faster than LangGraph, 57× faster than PydanticAI
  • Production-Ready: Complete runtime (AgentOS) and control plane for deployment
  • Security-First: Runs entirely in your cloud infrastructure
  • Model-Agnostic: Supports all major LLM providers (OpenAI, Anthropic, Google, etc.)
Agno是一款用于构建、部署和管理多Agent AI系统的开源框架,核心优势包括:
  • 性能卓越:比LangGraph快529倍,比PydanticAI快57倍
  • 生产就绪:配备完整的运行时环境(AgentOS)和控制平面用于部署
  • 安全优先:完全在你的云基础设施中运行
  • 模型无关:支持所有主流LLM提供商(OpenAI、Anthropic、Google等)

Core Components

核心组件

1. Agents - AI programs where the language model controls execution flow

1. Agents - 由语言模型控制执行流程的AI程序

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

agent = Agent(
    id="my-agent",
    model=Claude(id="claude-sonnet-4"),
    instructions="You are a helpful assistant.",
    markdown=True,
)
python
from agno.agent import Agent
from agno.models.anthropic import Claude

agent = Agent(
    id="my-agent",
    model=Claude(id="claude-sonnet-4"),
    instructions="You are a helpful assistant.",
    markdown=True,
)

Run synchronously

同步运行

agent.run("Hello, how can you help?")
agent.run("Hello, how can you help?")

Run asynchronously

异步运行

await agent.arun("Hello, how can you help?")

**Key Agent Features:**
- **Tools**: Enable agents to take actions and interact with external systems
- **Memory**: Store and recall information from previous interactions
- **Knowledge**: Vector database integration for RAG patterns
- **Storage**: Save session history and state in a database
- **Reasoning**: Analyze action results before responding
await agent.arun("Hello, how can you help?")

**Agent核心特性:**
- **工具**:让Agent能够执行操作并与外部系统交互
- **记忆**:存储并召回之前交互中的信息
- **知识库**:集成向量数据库以实现RAG模式
- **存储**:在数据库中保存会话历史与状态
- **推理**:在给出响应前分析操作结果

2. Teams - Collections of agents working together

2. Teams - 协同工作的Agent集合

python
from agno.team import Team

team = Team(
    id="research-team",
    agents=[researcher, writer, editor],
    instructions="Collaborate to create research articles.",
)
python
from agno.team import Team

team = Team(
    id="research-team",
    agents=[researcher, writer, editor],
    instructions="Collaborate to create research articles.",
)

Agents can delegate work to each other

Agent之间可以委派工作

team.run("Research AI trends and write an article")
undefined
team.run("Research AI trends and write an article")
undefined

3. Workflows - Orchestrated sequences of agents and logic

3. Workflows - 编排好的Agent与逻辑序列

python
from agno.workflow import Workflow, RunResponse

workflow = Workflow(
    id="content-workflow",
    steps=[
        {"agent": researcher, "message": "Research topic"},
        {"agent": writer, "message": "Write draft"},
        {"agent": editor, "message": "Edit and polish"},
    ]
)

workflow.run("Create content about AI agents")
python
from agno.workflow import Workflow, RunResponse

workflow = Workflow(
    id="content-workflow",
    steps=[
        {"agent": researcher, "message": "Research topic"},
        {"agent": writer, "message": "Write draft"},
        {"agent": editor, "message": "Edit and polish"},
    ]
)

workflow.run("Create content about AI agents")

4. AgentOS - Production runtime for deployment

4. AgentOS - 用于部署的生产级运行时环境

python
from agno.os import AgentOS
from agno.db.postgres import PostgresDb
python
from agno.os import AgentOS
from agno.db.postgres import PostgresDb

Setup database

配置数据库

db = PostgresDb( id="production-db", db_url="postgresql+psycopg://user:pass@localhost:5432/agno" )
db = PostgresDb( id="production-db", db_url="postgresql+psycopg://user:pass@localhost:5432/agno" )

Create AgentOS instance

创建AgentOS实例

agent_os = AgentOS( description="Production Multi-Agent System", agents=[agent1, agent2], teams=[team1], workflows=[workflow1], db=db, )
agent_os = AgentOS( description="Production Multi-Agent System", agents=[agent1, agent2], teams=[team1], workflows=[workflow1], db=db, )

Get FastAPI app

获取FastAPI应用

app = agent_os.get_app()
app = agent_os.get_app()

Serve with uvicorn

使用uvicorn启动服务

if name == "main": agent_os.serve(app="main:app", reload=True, port=7777)
undefined
if name == "main": agent_os.serve(app="main:app", reload=True, port=7777)
undefined

Quick Start Guide

快速入门指南

Installation

安装

bash
pip install agno
bash
pip install agno

Create Your First Agent

创建你的第一个Agent

python
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.duckduckgo import DuckDuckGoTools
python
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

Create an agent with web search capability

创建具备网页搜索能力的Agent

agent = Agent( id="web-search-agent", model=Claude(id="claude-sonnet-4"), tools=[DuckDuckGoTools()], instructions="Search the web and provide accurate information.", show_tool_calls=True, markdown=True, )
agent = Agent( id="web-search-agent", model=Claude(id="claude-sonnet-4"), tools=[DuckDuckGoTools()], instructions="Search the web and provide accurate information.", show_tool_calls=True, markdown=True, )

Run the agent

运行Agent

response = agent.run("What are the latest AI trends?") print(response.content)
undefined
response = agent.run("What are the latest AI trends?") print(response.content)
undefined

Add Memory and Storage

添加记忆与存储

python
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.memory import AgentMemory
python
from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.memory import AgentMemory

Setup database for persistence

配置用于持久化的数据库

db = PostgresDb( id="agent-db", db_url="postgresql+psycopg://ai:ai@localhost:5532/ai" )
db = PostgresDb( id="agent-db", db_url="postgresql+psycopg://ai:ai@localhost:5532/ai" )

Create agent with memory

创建带记忆功能的Agent

agent = Agent( id="memory-agent", model=Claude(id="claude-sonnet-4"), db=db, memory=AgentMemory(create_user_memories=True), storage={"messages": True, "sessions": True}, instructions="Remember user preferences and context.", )
agent = Agent( id="memory-agent", model=Claude(id="claude-sonnet-4"), db=db, memory=AgentMemory(create_user_memories=True), storage={"messages": True, "sessions": True}, instructions="Remember user preferences and context.", )

Conversations persist across sessions

对话内容会在会话间持久化

agent.run("My name is John", session_id="session_123") agent.run("What's my name?", session_id="session_123") # Remembers "John"
undefined
agent.run("My name is John", session_id="session_123") agent.run("What's my name?", session_id="session_123") # 会记住"John"
undefined

Build a RAG Agent with Knowledge

构建带知识库的RAG Agent

python
from agno.agent import Agent
from agno.knowledge.pdf import PDFKnowledgeBase
from agno.vectordb.pgvector import PgVector
python
from agno.agent import Agent
from agno.knowledge.pdf import PDFKnowledgeBase
from agno.vectordb.pgvector import PgVector

Setup vector database

配置向量数据库

vector_db = PgVector( db_url="postgresql+psycopg://ai:ai@localhost:5532/ai", table_name="agno_knowledge" )
vector_db = PgVector( db_url="postgresql+psycopg://ai:ai@localhost:5532/ai", table_name="agno_knowledge" )

Create knowledge base from PDFs

从PDF文件创建知识库

knowledge = PDFKnowledgeBase( path="docs/", vector_db=vector_db, )
knowledge = PDFKnowledgeBase( path="docs/", vector_db=vector_db, )

Load documents into vector database

将文档加载到向量数据库

knowledge.load(recreate=False)
knowledge.load(recreate=False)

Create RAG agent

创建RAG Agent

rag_agent = Agent( id="rag-agent", model=Claude(id="claude-sonnet-4"), knowledge=knowledge, search_knowledge=True, instructions="Answer questions using the knowledge base. Cite sources.", )
rag_agent = Agent( id="rag-agent", model=Claude(id="claude-sonnet-4"), knowledge=knowledge, search_knowledge=True, instructions="Answer questions using the knowledge base. Cite sources.", )

Agent searches knowledge base before responding

Agent会先搜索知识库再给出响应

rag_agent.run("What does our documentation say about agents?")
undefined
rag_agent.run("What does our documentation say about agents?")
undefined

Common Patterns

常见模式

1. Structured Output with Pydantic

1. 基于Pydantic的结构化输出

python
from pydantic import BaseModel, Field
from agno.agent import Agent

class MovieReview(BaseModel):
    title: str = Field(..., description="Movie title")
    rating: float = Field(..., ge=0, le=10)
    summary: str = Field(..., description="Brief summary")
    pros: list[str]
    cons: list[str]

agent = Agent(
    model=Claude(id="claude-sonnet-4"),
    output_model=MovieReview,
    structured_output=True,
)

response = agent.run("Review the movie Inception")
review: MovieReview = response.output  # Type-safe structured output
python
from pydantic import BaseModel, Field
from agno.agent import Agent

class MovieReview(BaseModel):
    title: str = Field(..., description="Movie title")
    rating: float = Field(..., ge=0, le=10)
    summary: str = Field(..., description="Brief summary")
    pros: list[str]
    cons: list[str]

agent = Agent(
    model=Claude(id="claude-sonnet-4"),
    output_model=MovieReview,
    structured_output=True,
)

response = agent.run("Review the movie Inception")
review: MovieReview = response.output  # 类型安全的结构化输出

2. Human-in-the-Loop (HITL)

2. 人在回路(HITL)

python
from agno.agent import Agent
from agno.tools import tool

@tool
def execute_trade(stock: str, amount: int) -> str:
    """Execute a stock trade (requires approval)."""
    return f"Executed trade: {amount} shares of {stock}"

agent = Agent(
    model=Claude(id="claude-sonnet-4"),
    tools=[execute_trade],
    require_approval_for_tools=True,  # Requires human approval
)
python
from agno.agent import Agent
from agno.tools import tool

@tool
def execute_trade(stock: str, amount: int) -> str:
    """Execute a stock trade (requires approval)."""
    return f"Executed trade: {amount} shares of {stock}"

agent = Agent(
    model=Claude(id="claude-sonnet-4"),
    tools=[execute_trade],
    require_approval_for_tools=True,  # 需要人工批准
)

Agent will pause and wait for approval before executing trade

Agent会暂停并等待批准后再执行交易

agent.run("Buy 100 shares of AAPL")
undefined
agent.run("Buy 100 shares of AAPL")
undefined

3. Multi-Agent Collaboration

3. 多Agent协作

python
from agno.team import Team
python
from agno.team import Team

Define specialized agents

定义专业化Agent

researcher = Agent( id="researcher", role="Research specialist", tools=[DuckDuckGoTools()], instructions="Find accurate information on topics.", )
writer = Agent( id="writer", role="Content writer", instructions="Write engaging, well-structured content.", )
editor = Agent( id="editor", role="Editor", instructions="Review and improve content quality.", )
researcher = Agent( id="researcher", role="Research specialist", tools=[DuckDuckGoTools()], instructions="Find accurate information on topics.", )
writer = Agent( id="writer", role="Content writer", instructions="Write engaging, well-structured content.", )
editor = Agent( id="editor", role="Editor", instructions="Review and improve content quality.", )

Create team

创建团队

content_team = Team( id="content-team", agents=[researcher, writer, editor], leader=researcher, # Lead agent coordinates instructions=""" 1. Researcher finds information 2. Writer creates content 3. Editor reviews and finalizes """, )
content_team = Team( id="content-team", agents=[researcher, writer, editor], leader=researcher, # 主导Agent负责协调 instructions=""" 1. Researcher finds information 2. Writer creates content 3. Editor reviews and finalizes """, )

Team collaborates automatically

团队会自动协作

content_team.run("Create an article about quantum computing")
undefined
content_team.run("Create an article about quantum computing")
undefined

4. Context Injection and Dependencies

4. 上下文注入与依赖传递

python
undefined
python
undefined

Pass dynamic context to agents

向Agent传递动态上下文

agent.run( "Write a story about {character}", dependencies={"character": "a brave robot named Anna"} )
agent.run( "Write a story about {character}", dependencies={"character": "a brave robot named Anna"} )

Pass runtime metadata

传递运行时元数据

agent.run( "Generate report", metadata={"user_id": "123", "department": "engineering"} )
agent.run( "Generate report", metadata={"user_id": "123", "department": "engineering"} )

Manage session state

管理会话状态

agent.run( "Continue our conversation", session_id="user_123", session_state={"preferences": {"theme": "dark"}} )
undefined
agent.run( "Continue our conversation", session_id="user_123", session_state={"preferences": {"theme": "dark"}} )
undefined

5. Streaming Responses

5. 流式响应

python
undefined
python
undefined

Stream agent responses

流式获取Agent响应

for chunk in agent.run_stream("Tell me a story"): if chunk.content: print(chunk.content, end="", flush=True)
for chunk in agent.run_stream("Tell me a story"): if chunk.content: print(chunk.content, end="", flush=True)

Async streaming

异步流式获取

async for chunk in agent.arun_stream("Tell me a story"): if chunk.content: print(chunk.content, end="", flush=True)
undefined
async for chunk in agent.arun_stream("Tell me a story"): if chunk.content: print(chunk.content, end="", flush=True)
undefined

AgentOS API Deployment

AgentOS API部署

Run Agents via REST API

通过REST API运行Agent

bash
undefined
bash
undefined

Start AgentOS server

启动AgentOS服务器

python main.py
python main.py

Run agent via API

通过API运行Agent

curl --location 'http://localhost:7777/agents/my-agent/runs'
--header 'Content-Type: application/x-www-form-urlencoded'
--data-urlencode 'message=Tell me about Agno'
--data-urlencode 'stream=True'
--data-urlencode 'user_id=user@example.com'
--data-urlencode 'session_id=session_123'
curl --location 'http://localhost:7777/agents/my-agent/runs'
--header 'Content-Type: application/x-www-form-urlencoded'
--data-urlencode 'message=Tell me about Agno'
--data-urlencode 'stream=True'
--data-urlencode 'user_id=user@example.com'
--data-urlencode 'session_id=session_123'

Pass dependencies via API

通过API传递依赖

curl --location 'http://localhost:7777/agents/my-agent/runs'
--data-urlencode 'message=Write a story'
--data-urlencode 'dependencies={"character_name": "Anna"}'
curl --location 'http://localhost:7777/agents/my-agent/runs'
--data-urlencode 'message=Write a story'
--data-urlencode 'dependencies={"character_name": "Anna"}'

Pass structured output schema

通过API传递结构化输出 schema

curl --location 'http://localhost:7777/agents/my-agent/runs'
--data-urlencode 'message=Generate data'
--data-urlencode 'output_schema={"type":"object","properties":{"name":{"type":"string"}}}'
undefined
curl --location 'http://localhost:7777/agents/my-agent/runs'
--data-urlencode 'message=Generate data'
--data-urlencode 'output_schema={"type":"object","properties":{"name":{"type":"string"}}}'
undefined

Authentication

认证

python
undefined
python
undefined

Secure AgentOS with API keys

使用API密钥保护AgentOS

agent_os = AgentOS( agents=[agent], security_key="your-secret-key", )
agent_os = AgentOS( agents=[agent], security_key="your-secret-key", )

Client requests

客户端请求示例

curl --location 'http://localhost:7777/agents/my-agent/runs'
--header 'Authorization: Bearer your-secret-key'
--data-urlencode 'message=Hello'
undefined
curl --location 'http://localhost:7777/agents/my-agent/runs'
--header 'Authorization: Bearer your-secret-key'
--data-urlencode 'message=Hello'
undefined

Advanced Features

高级特性

Hooks and Background Tasks

钩子与后台任务

python
from agno.hooks import hook
python
from agno.hooks import hook

Pre-run hook

运行前钩子

@hook def validate_input(run_input, agent): """Validate input before agent runs.""" if "forbidden" in run_input.message: raise ValueError("Forbidden content detected") return run_input
@hook def validate_input(run_input, agent): """在Agent运行前验证输入。""" if "forbidden" in run_input.message: raise ValueError("Forbidden content detected") return run_input

Post-run hook (background)

运行后钩子(后台执行)

@hook(run_in_background=True) async def log_response(run_output, agent): """Log responses without blocking.""" await analytics_service.log(run_output)
agent = Agent( model=Claude(id="claude-sonnet-4"), pre_run_hooks=[validate_input], post_run_hooks=[log_response], )
@hook(run_in_background=True) async def log_response(run_output, agent): """无阻塞地记录响应。""" await analytics_service.log(run_output)
agent = Agent( model=Claude(id="claude-sonnet-4"), pre_run_hooks=[validate_input], post_run_hooks=[log_response], )

Enable background hooks globally in AgentOS

在AgentOS中全局启用后台钩子

agent_os = AgentOS( agents=[agent], run_hooks_in_background=True, )
undefined
agent_os = AgentOS( agents=[agent], run_hooks_in_background=True, )
undefined

Reasoning and Model Controls

推理与模型控制

python
undefined
python
undefined

Enable reasoning

启用推理功能

agent = Agent( model=Claude(id="claude-sonnet-4"), reasoning=True, # Agent thinks before responding instructions="Think carefully about each question.", )
agent = Agent( model=Claude(id="claude-sonnet-4"), reasoning=True, # Agent会先思考再给出响应 instructions="Think carefully about each question.", )

Control model parameters

控制模型参数

agent = Agent( model=Claude( id="claude-sonnet-4", temperature=0.7, max_tokens=2000, ), )
undefined
agent = Agent( model=Claude( id="claude-sonnet-4", temperature=0.7, max_tokens=2000, ), )
undefined

Context Management

上下文管理

python
undefined
python
undefined

Automatic context compression

自动上下文压缩

agent = Agent( model=Claude(id="claude-sonnet-4"), compress_context=True, # Automatically compress long contexts max_context_length=100000, )
undefined
agent = Agent( model=Claude(id="claude-sonnet-4"), compress_context=True, # 自动压缩长上下文 max_context_length=100000, )
undefined

Model Provider Support

模型提供商支持

Agno supports all major LLM providers:
python
undefined
Agno支持所有主流LLM提供商:
python
undefined

Anthropic Claude

Anthropic Claude

from agno.models.anthropic import Claude model = Claude(id="claude-sonnet-4")
from agno.models.anthropic import Claude model = Claude(id="claude-sonnet-4")

OpenAI

OpenAI

from agno.models.openai import OpenAIChat model = OpenAIChat(id="gpt-4o")
from agno.models.openai import OpenAIChat model = OpenAIChat(id="gpt-4o")

Google Gemini

Google Gemini

from agno.models.google import Gemini model = Gemini(id="gemini-2.0-flash-exp")
from agno.models.google import Gemini model = Gemini(id="gemini-2.0-flash-exp")

AWS Bedrock

AWS Bedrock

from agno.models.bedrock import Bedrock model = Bedrock(id="anthropic.claude-3-5-sonnet-20241022-v2:0")
from agno.models.bedrock import Bedrock model = Bedrock(id="anthropic.claude-3-5-sonnet-20241022-v2:0")

Azure OpenAI

Azure OpenAI

from agno.models.azure import AzureOpenAIChat model = AzureOpenAIChat(id="gpt-4o")
undefined
from agno.models.azure import AzureOpenAIChat model = AzureOpenAIChat(id="gpt-4o")
undefined

Built-in Tools and Integrations

内置工具与集成

Agno includes 100+ pre-built tool integrations:
python
undefined
Agno包含100+预构建的工具集成:
python
undefined

Web Search

网页搜索

from agno.tools.duckduckgo import DuckDuckGoTools from agno.tools.tavily import TavilyTools
from agno.tools.duckduckgo import DuckDuckGoTools from agno.tools.tavily import TavilyTools

File Operations

文件操作

from agno.tools.file import FileTools
from agno.tools.file import FileTools

APIs

API集成

from agno.tools.github import GitHubTools from agno.tools.slack import SlackTools
from agno.tools.github import GitHubTools from agno.tools.slack import SlackTools

Data Analysis

数据分析

from agno.tools.pandas import PandasTools from agno.tools.sql import SQLTools
from agno.tools.pandas import PandasTools from agno.tools.sql import SQLTools

Web Scraping

网页抓取

from agno.tools.newspaper import NewspaperToolkit from agno.tools.beautifulsoup import BeautifulSoupTools
from agno.tools.newspaper import NewspaperToolkit from agno.tools.beautifulsoup import BeautifulSoupTools

And many more...

还有更多...

undefined
undefined

Create Custom Tools

创建自定义工具

python
from agno.tools import tool

@tool
def calculate_roi(investment: float, return_value: float) -> dict:
    """
    Calculate return on investment.

    Args:
        investment: Initial investment amount
        return_value: Final return value

    Returns:
        Dictionary with ROI percentage and profit
    """
    profit = return_value - investment
    roi_percentage = (profit / investment) * 100

    return {
        "profit": profit,
        "roi_percentage": roi_percentage,
        "investment": investment,
        "return": return_value,
    }
python
from agno.tools import tool

@tool
def calculate_roi(investment: float, return_value: float) -> dict:
    """
    计算投资回报率。

    参数:
        investment: 初始投资金额
        return_value: 最终回报金额

    返回:
        包含ROI百分比和利润的字典
    """
    profit = return_value - investment
    roi_percentage = (profit / investment) * 100

    return {
        "profit": profit,
        "roi_percentage": roi_percentage,
        "investment": investment,
        "return": return_value,
    }

Use in agent

在Agent中使用自定义工具

agent = Agent( model=Claude(id="claude-sonnet-4"), tools=[calculate_roi], show_tool_calls=True, )
undefined
agent = Agent( model=Claude(id="claude-sonnet-4"), tools=[calculate_roi], show_tool_calls=True, )
undefined

Best Practices

最佳实践

1. Use Structured Instructions

1. 使用结构化指令

python
agent = Agent(
    instructions="""
    You are a customer support agent. Follow these rules:
    1. Always greet users warmly
    2. Ask clarifying questions if needed
    3. Provide step-by-step solutions
    4. Verify customer satisfaction before closing
    5. Escalate complex issues to human agents
    """,
)
python
agent = Agent(
    instructions="""
    你是一名客户支持Agent,请遵循以下规则:
    1. 始终热情问候用户
    2. 必要时提出澄清问题
    3. 提供分步解决方案
    4. 结束对话前确认客户满意度
    5. 将复杂问题升级给人工Agent
    """,
)

2. Implement Proper Error Handling

2. 实现完善的错误处理

python
try:
    response = agent.run(user_input)
except Exception as e:
    logger.error(f"Agent error: {e}")
    # Implement fallback logic
python
try:
    response = agent.run(user_input)
except Exception as e:
    logger.error(f"Agent错误: {e}")
    # 实现回退逻辑

3. Use Session Management

3. 使用会话管理

python
undefined
python
undefined

Maintain conversation context

维持对话上下文

agent.run(message, session_id=f"user_{user_id}")
undefined
agent.run(message, session_id=f"user_{user_id}")
undefined

4. Monitor and Evaluate

4. 监控与评估

python
undefined
python
undefined

Use hooks for monitoring

使用钩子进行监控

@hook def track_usage(run_output, agent): """Track agent usage and performance.""" metrics.record({ "agent_id": agent.id, "response_time": run_output.metrics.time_to_first_token, "tokens_used": run_output.metrics.output_tokens, })
undefined
@hook def track_usage(run_output, agent): """跟踪Agent的使用情况和性能。""" metrics.record({ "agent_id": agent.id, "response_time": run_output.metrics.time_to_first_token, "tokens_used": run_output.metrics.output_tokens, })
undefined

5. Optimize for Production

5. 为生产环境优化

python
undefined
python
undefined

Use database for persistence

使用数据库实现持久化

db = PostgresDb(db_url=os.getenv("DATABASE_URL"))
db = PostgresDb(db_url=os.getenv("DATABASE_URL"))

Enable caching

启用缓存

agent = Agent( db=db, storage={"messages": True, "sessions": True}, )
agent = Agent( db=db, storage={"messages": True, "sessions": True}, )

Deploy with AgentOS

通过AgentOS部署

agent_os = AgentOS( agents=[agent], db=db, security_key=os.getenv("API_SECRET_KEY"), )
undefined
agent_os = AgentOS( agents=[agent], db=db, security_key=os.getenv("API_SECRET_KEY"), )
undefined

Performance Benchmarks

性能基准

Agno is optimized for production use:
  • Agent instantiation: ~3 microseconds
  • Memory per agent: ~6.6 KiB
  • Throughput: 529× faster than LangGraph, 57× faster than PydanticAI
Agno针对生产环境进行了优化:
  • Agent实例化:约3微秒
  • 单Agent内存占用:约6.6 KiB
  • 吞吐量:比LangGraph快529倍,比PydanticAI快57倍

Reference Files

参考文件

This skill includes comprehensive documentation in
references/
:
  • llms-full.md - Complete Agno documentation (4.8MB)
  • llms-txt.md - Condensed documentation (3.1MB)
  • llms.md - Quick reference (203KB)
  • index.md - Documentation index
本技能包含
references/
目录下的完整文档:
  • llms-full.md - 完整Agno文档(4.8MB)
  • llms-txt.md - 精简版文档(3.1MB)
  • llms.md - 快速参考手册(203KB)
  • index.md - 文档索引

Use Cases and Examples

用例与示例

1. Documentation Assistant (RAG)

1. 文档助手(RAG)

Build an AI assistant that answers questions from your knowledge base using vector search.
构建一个通过向量搜索从知识库中回答问题的AI助手。

2. Competitor Analysis

2. 竞品分析

Automated competitive intelligence through web search and content analysis.
通过网页搜索和内容分析实现自动化竞争情报收集。

3. Research Agent

3. 研究Agent

Create research articles with web search, fact-checking, and writing capabilities.
创建具备网页搜索、事实核查和写作能力的研究文章生成Agent。

4. Web Data Extraction

4. 网页数据提取

Transform unstructured web content into organized, structured data.
将非结构化网页内容转换为结构化数据。

5. Content Generation Pipeline

5. 内容生成流水线

Multi-agent workflow for researching, writing, and editing content.
用于研究、写作和编辑内容的多Agent工作流。

Common Issues and Solutions

常见问题与解决方案

Issue: Agent not using tools

问题:Agent未使用工具

Solution: Ensure
show_tool_calls=True
and verify tool descriptions are clear.
解决方案:确保
show_tool_calls=True
,并验证工具描述是否清晰。

Issue: Context too long

问题:上下文过长

Solution: Enable
compress_context=True
or implement context summarization.
解决方案:启用
compress_context=True
或实现上下文摘要功能。

Issue: Slow responses

问题:响应缓慢

Solution: Use streaming (
run_stream()
) and optimize tool execution.
解决方案:使用流式响应(
run_stream()
)并优化工具执行效率。

Issue: Lost conversation context

问题:对话上下文丢失

Solution: Implement proper session management with
session_id
and database storage.
解决方案:使用
session_id
和数据库存储实现完善的会话管理。

Resources

资源

License

许可证

Apache-2.0

Note: This skill was generated from official Agno documentation. For the most up-to-date information, always refer to the official docs at https://docs.agno.com
Apache-2.0

注意:本技能基于官方Agno文档生成。如需获取最新信息,请始终参考官方文档:https://docs.agno.com