Hermes Agent 架构与生态

Nous Research 开源自改进 AI Agent 框架深度研究

MIT License 自改进学习循环 MCP Native 22K+ GitHub Stars 207 Contributors

1概述

Hermes Agent 是由 Nous Research(与 Hermes 模型家族和 Atropos 强化学习框架同一团队)构建的开源自主 AI Agent,MIT 许可证,目前在 GitHub 拥有 22K+ Stars207 位贡献者

其核心差异化定位是:「会随着你一起成长的 Agent」——内置自改进学习循环,能够从经验中创建技能(SKILL.md)、在反复使用中优化流程、跨会话保持记忆,并持续构建对用户的深度认知模型。

自改进循环

唯一内置学习循环的 Agent —— 每次完成复杂任务后自动生成结构化 SKILL.md,下一次遇到类似任务时自动复用并优化

Core Differentiator

模型无关

支持任何 LLM Provider(Anthropic/OpenAI/本地模型),通过统一适配层注入 AIAgent,支持热切换 /model

Provider Agnostic

MCP Native

内置原生 MCP 客户端(~2200行),支持 stdio/HTTP 双传输,自动工具发现、安全过滤、零配置注入

Tool Protocol

任意平台运行

$5 VPS / GPU集群 / Serverless 均可运行,通过 Docker 容器化,无状态休眠几乎零成本

Portable

2历史版本时间线

v0.1 — 初始版本
基础 CLI 框架,终端对话循环
v0.4 — 消息网关
Signal、DingTalk、 SMS、Mattermost、Matrix 适配器,API Server
v0.5 — 第三方集成
HuggingFace Provider、Telegram 话题、Modal SDK
v0.6 — 多Agent时代
Multi-Agent Profiles、MCP Server 模式、Docker 容器、飞书/企微
v0.60+ (最新)
正式支持 MCP Server 托管、Profile 多身份切换、Atropos RL 框架集成

3核心架构

Hermes 的架构遵循五大设计原则:提示稳定性可观测执行可中断平台无关核心松耦合

┌────────────────────────────────────────────────────────────────────┐ │ HERMES AGENT CORE │ │ │ │ run_agent.py ──► AIAgent class (核心对话循环) │ │ model_tools.py ──► Tool orchestration, _discover_tools() │ │ toolsets.py ──► Toolset definitions, _HERMES_CORE_TOOLS │ │ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ │ agent/ (Agent Internals) │ │ │ │ prompt_builder.py ── 系统提示装配 │ │ │ │ context_compressor.py── 自动上下文压缩 (50%阈值) │ │ │ │ prompt_caching.py ── Anthropic 提示缓存 │ │ │ │ auxiliary_client.py ── 辅助 LLM 客户端 (视觉/摘要) │ │ │ │ memory_manager.py ── 记忆管理器编排 │ │ │ │ trajectory.py ── 轨迹保存辅助 │ │ │ └──────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ │ tools/ (工具实现) │ │ │ │ registry.py ── 中心工具注册表 (schema/handler/dispatch) │ │ │ │ approval.py ── 危险命令检测 │ │ │ │ terminal_tool.py── 终端编排 │ │ │ │ file_tools.py ── read_file/write_file/patch/search_files │ │ │ │ web_tools.py ── web_search/web_extract (Parallel/Firecrawl)│ │ │ │ browser_tool.py── 11项浏览器自动化工具 │ │ │ │ code_execution_tool.py── execute_code 沙箱 │ │ │ │ delegate_tool.py── 子代理委托 (~500行) │ │ │ │ mcp_tool.py ── MCP 客户端 (~2200行, 核心) │ │ │ └──────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ │ gateway/ (消息网关) │ │ │ │ run.py ── GatewayRunner (Telegram/Discord/Slack/WhatsApp…) │ │ │ │ session.py ── SessionStore (多会话管理) │ │ │ └──────────────────────────────────────────────────────────────┘ │ │ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ │ hermes_cli/ (CLI 入口, ~5500行) │ │ │ │ main.py ── 所有 hermes 子命令 │ │ │ │ config.py ── DEFAULT_CONFIG + 环境变量迁移 │ │ │ │ commands.py ── COMMAND_REGISTRY (斜杠命令) │ │ │ │ auth.py ── PROVIDER_REGISTRY (凭证解析) │ │ │ └──────────────────────────────────────────────────────────────┘ │ │ │ │ hermes_state.py ──► SessionDB (SQLite + FTS5 全文搜索) │ └────────────────────────────────────────────────────────────────────┘

标准执行循环

构建提示
系统提示 + 历史上下文 + 保护 token
上下文检查
超过50%阈值时触发自动摘要压缩
模型调用
统一适配层 → Anthropic/OpenAI/本地/自定义
工具执行
注册表分发 → 危险命令审查 → 终端/文件/Web
状态持久化
SQLite FTS5 写入会话历史
响应返回
进度更新 KawaiiSpinner(CLI)/ Chat消息(Gateway)

4三层记忆系统

Hermes 的记忆系统是区别于普通 Agent 的关键创新。它将「发生了什么」与「怎么做」分离,按需加载而非全量拉取,从而避免 token 膨胀。

Layer 1: MEMORY.md

结构化持久笔记,记录重要事实、用户偏好、工作流程摘要。通过 nudge 机制主动追加,不需要每次手动调用。

长期记忆 · 主动写入

Layer 2: Skills (SKILL.md)

程序性记忆,Agent 自动从复杂任务执行中提取结构化操作步骤,形成可搜索、可复用的技能文档。

程序记忆 · 自改进核心

Layer 3: Session DB (SQLite + FTS5)

会话历史全量存储于 ~/.hermes/state.db,支持 BM25 风格全文搜索,每次对话时主动检索相关片段。

会话记忆 · 被动检索

上下文压缩机制

ContextCompressor 在上下文达到模型窗口 50% 阈值时自动触发,使用同模型生成摘要,将历史压缩为紧凑片段(protect_first_n 保护系统提示,protect_last_n 保护最近交互)。

5技能系统(Self-Improving Loop)

技能系统是 Hermes 的核心差异化能力。Agent 每次完成复杂/多步骤任务后,会自动检查是否已存在相关技能——若不存在则生成新的 SKILL.md;若已存在但流程不够优化,则读取并创建改进版本。

「大多数 AI Agent 是套了外壳的聊天机器人。你打字,它回复,关闭标签页,它就忘记你存在过。Hermes 不同——它是个持久系统,活在你的机器或 VPS 上,跨会话保持多层记忆,从自己的错误中学习,在任何你需要的地方出现。」

内置技能分类

apple (iMessage/Reminders/Notes/FindMy) autonomous-ai-agents (Claude Code/Codex/OpenCode) cloudflare-workers-pages creative (ASCII art/manim/p5js) data-science (Jupyter) email (himalaya) github (PR/Issues/Repo) knowledge-base (LLM Wiki/Obsidian) lark (飞书全系集成) mcp (mcporter/native-mcp) media (YouTube/GIF/Audio) mlops (GGUF/llama.cpp/vLLM) note-taking (Obsidian/Notion) openclaw-imports (飞书/飞书日历) productivity (Linear/Notion/OCR) research (arXiv/MCP-Orchestration) smart-home (openHue) social-media (Xitter)

SKILL.md 规范

每个技能文档包含:触发条件、编号步骤、常见陷阱、验证步骤。格式统一,支持 /skills 斜杠命令和 hermes skills search/install 管理。

6MCP 集成

Hermes 内置两个 MCP 客户端路径:Native MCP(通过 config.yaml 配置)和 mcporter CLI bridge(临时/即席服务器)。

Native MCP 架构

mcp_tool.py (~2200行) 实现:stdio 和 SSE/HTTP 双传输、自动重连、安全过滤(PATH/HOME/LANG/env 白名单)、零配置工具注入。配置后 MCP 服务器工具自动出现在 /tools 列表中。

config.yaml 配置示例

mcp_servers: filesystem: command: "npx" args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] timeout: 120 connect_timeout: 60 github: command: "npx" args: ["-y", "@modelcontextprotocol/server-github"] env: GITHUB_PERSONAL_ACCESS_TOKEN: "ghp_..." remote_api: url: "https://api.example.com/mcp" headers: Authorization: "Bearer sk-..." timeout: 180

官方 MCP 服务器支持

@modelcontextprotocol/server-filesystem、@modelcontextprotocol/server-github、@modelcontextprotocol/server-postgres、@modelcontextprotocol/server-brave-search、@modelcontextprotocol/server-puppeteer、@modelcontextprotocol/server-slack 等。

Sampling 支持

MCP Sampling 允许 LLM Server 回调 Hermes(支持 Gemini-3-Flash 等模型),可配置 allowed_models、max_tokens_cap、max_rpm 和 max_tool_rounds。

7子代理委托与 ACP

Subagent Delegation (delegate_task)

delegate_tool 允许 Hermes 生成独立 AIAgent 子进程,拥有独立对话上下文、终端会话和受限工具集。最多 3 个并发子代理,结果摘要返回主 Agent。

# 单任务委托 delegate_task( goal="Debug why tests fail", context="Error: assertion in test_foo.py line 42", toolsets=["terminal", "file"] ) # 并行批量(最多3个) delegate_task(tasks=[ { "goal": "Research topic A", "toolsets": ["web"] }, { "goal": "Research topic B", "toolsets": ["web"] }, { "goal": "Fix the build", "toolsets": ["terminal", "file"] } ])

delegate_task vs execute_code

维度delegate_taskexecute_code
推理能力完整 LLM 推理循环仅 Python 代码执行
上下文全新隔离对话无对话,仅脚本
工具访问全部非阻塞工具+推理7个工具 via RPC
并行性最多3个并发单脚本
适用场景需要判断的复杂任务机械性多步骤管道
Token成本较高(全 LLM 循环)较低(仅 stdout)

ACP (Agent Communication Protocol)

ACP 是外部工具(如代码编辑器)标准化调用 Hermes 的协议(参考 agentcommunicationprotocol.dev)。Hermes 将 AIAgent 循环本身定义为同步编排引擎,ACP Gateway 暴露 REST 接口,支持单 Agent 和多 Agent 单服务器两种部署模式。

Multi-Agent 路线图

当前 GitHub Issue #344 正在推进原生 Multi-Agent 编排架构:扩展 delegate_task 支持依赖感知 DAG 执行、Agent 间结果传递、checkpoint + stuck 检测与重规划。

8消息网关与部署

GatewayRunner 通过 adapter 模式支持 12+ 消息平台:Telegram、Discord、Slack、WhatsApp、Signal、Matrix、Email、SMS (Twilio)、电话 (Bland.ai/Vapi)、飞书、钉钉、企业微信。

部署形态

💻
本地终端
hermes 直接启动,TTY交互
🌐
消息网关
hermes gateway 启动,长连接推送通知
🐳
Docker 容器
hermes docker 命令,v0.6+
☁️
Cloudflare Workers
Hermes Skills 支持 CF Workers/Pages 部署
Cron 调度
自然语言描述调度任务,无需 cron 语法
🔗
ACP Server
REST API 暴露 Agent 能力

9Hermes vs OpenClaw 对比

维度Hermes AgentOpenClaw
核心范式自改进 Agent 循环(do→learn→improve)控制平面优先(Gateway 协调一切)
技能来源Agent 自动生成 SKILL.md静态、人工编写的技能
记忆系统三层(MEMORY.md + Skills + SQLite/FTS5)会话历史 + 持久上下文
RL 集成深度集成 Atropos(batch trajectories)无内置 RL 框架
架构哲学Agent 循环为同步编排引擎中央控制器协调一切
工具生态MCP Native + 120+ 内置工具MCP 工具池 + MindStudio 插件
多 Agentdelegate_task(并发最多3),路线图中 DAGworkspace 多 Agent 原生支持
学习曲线技能系统需理解自改进机制控制平面模式更直观

10生态现状

awesome-hermes-agent

社区维护awesome列表:技能/工具/集成/资源汇总,879 Stars

github.com/0xNyk/awesome-hermes-agent

Skills Hub

官方技能目录:apple、mcp、media、productivity、research、lark等20+分类

hermes-agent.nousresearch.com/docs/skills

飞书集成

openclaw-imports 提供飞书多维表格、日历、云文档、IM、任务、VC 等全系集成

lark-* 技能体系

MindStudio 插件

@mindstudio-ai/agent SDK 提供120+类型化能力(sendEmail/searchGoogle/generateImage等)

无自托管选项

关键数字一览

22K+ Stars
GitHub nousresearch/hermes-agent
👥
207 Contributors
开源社区贡献
📦
20+ Skills分类
内置技能库
🔌
MCP Native
原生支持所有 MCP 服务器
💬
12+ 消息平台
Telegram/Discord/Slack/WhatsApp…
🏗️
v0.6 (最新)
Multi-Agent Profiles + Docker

参考文献

  1. NousResearch/hermes-agent — GitHub (22K Stars)
  2. Architecture | Hermes Agent — Nous Research 官方文档
  3. Architecture — Mintlify 文档镜像
  4. MCP Integration — Hermes Agent
  5. Subagent Delegation | Hermes Agent
  6. Bundled Skills Catalog | Hermes Agent
  7. Session Storage | Hermes Agent (SQLite + FTS5)
  8. Hermes Agent Skills Guide — The System That Learns From You
  9. Hermes Agent Memory System: Technical Deep Dive
  10. AI 101: Hermes Agent — OpenClaw's Rival? | Turing Post
  11. OpenClaw vs. Hermes Agent: The race to build AI assistants | The New Stack
  12. What Is Hermes Agent? The OpenClaw Alternative | MindStudio
  13. How Hermes Agent Memory Actually Works | Vectorize
  14. r/aiagents: Hermes Agent architecture deep dive
  15. Agent Communication Protocol — Architecture
  16. Multi-Agent Architecture Issue #344 — GitHub
  17. Hermes vs OpenClaw: Key Differences | LushBinary
  18. Hermes Agent Reference Architecture | ChatBotKit
  19. The Self-Improving AI Agent That Learns From Experience | PyShine
  20. awesome-hermes-agent — 社区Awesome列表