前身为 Phidata,轻量高性能 Agent 框架。核心设计理念:一切可配置、一切可插拔。Agent 类是唯一入口,通过组合模式组装 Memory、Knowledge、Tools 等能力。
代码组织从单一 agno/agent/agent.py(1735 行)拆分出专门模块:
agno/agent/ ├── agent.py → Agent 主类(1700+ 行) ├── _messages.py → 系统/用户消息构建 ├── _utils.py → 辅助函数 └── _init.py → Manager 初始化
Agno 拥有所有框架中最复杂的系统提示词构建管线——get_system_message() 函数超过 200 行,按 17 个有序步骤组装:
1. description → Agent 描述
2. role → <your_role>{role}</your_role>
3. instructions → <instructions> 或纯列表
4. additional_information → markdown / datetime / location / name
5. _tool_instructions → 工具使用指引
6. resolve_in_context → {variable} 模板替换
7. expected_output → <expected_output>
8. additional_context → 自定义上下文
9. skills → Skill 系统提示片段
10. memories → <memories_from_previous_interactions>
+ enable_agentic_memory → update_user_memory 工具指引
11. cultural_knowledge → <cultural_knowledge> 文化知识
+ enable_agentic_culture → create_or_update_cultural_knowledge 工具指引
12. session_summary → <summary_of_previous_interactions>
13. learnings → 学习结果注入
14. search_knowledge → RAG 搜索指令
15. model system msg → 模型特定提示
16. JSON output prompt → 结构化输出指引
17. session_state → <session_state> 完整状态
format_message_with_state_variables() 将 {var_name} 替换为 session_state / dependencies / metadata / user_id,使用 Python string.Template.safe_substitute() 避免缺失变量报错。
<cultural_knowledge>
---
Name: {name}
Summary: {summary}
Content: {content}
</cultural_knowledge>
文化知识系统实现跨 Agent/跨 Session 的共享经验——类似于组织知识库,但由 Agent 自主贡献和更新。
<updating_user_memories> - You have access to the `update_user_memory` tool - If the user's message includes information that should be captured as a memory, use the `update_user_memory` tool - Memories should include details that could personalize ongoing interactions with the user. </updating_user_memories>
Agent.run() → get_system_message() → 构建 17 步系统提示词 → get_user_message() → 构建用户消息(含知识检索) → model.response() → LLM 调用 → (tool_calls → execute → LLM call)* → 工具循环 → response → (save memories / update learnings)
Toolkit — 工具分组类,@tool 装饰器update_user_memory 工具更新记忆create_or_update_cultural_knowledge 贡献libs/agno/agno/agent/agent.py — Agent 主类libs/agno/agno/agent/_messages.py — 系统提示词构建(核心)libs/agno/agno/utils/prompts.py — JSON 输出提示词模板libs/agno/agno/tools/toolkit.py — 工具系统libs/agno/agno/memory/agent/memory.py — 记忆系统libs/agno/agno/knowledge/ — 知识库