Hermes Agent 从零搭建完整教程

开源 AI Agent 走”自我进化”路线:五根支柱(记忆 / 技能 / 灵魂 / Cron / 自我改进闭环)+ VPS 一键部署 + Telegram 移动操控,比 Claude Code 更适合”移动办公 + 定时自动化”场景。

基本信息

核心观点

  1. Hermes Agent 定位是”移动办公 AI 助手”:作者明确将 Hermes 与 Claude Code 做心理分区——Claude Code 负责桌前深度编码(90% 知识工作),Hermes 负责出门在外时通过 Telegram 快速调度 Cron、回复评论、查任务,两者互补而非替代。Hermes 已获 140K+ GitHub Stars,MIT 开源,增速在 GitHub 排名前列。

  2. 五支柱架构是理解 Hermes 的核心框架:Memory(user.md + memory.md,每次会话加载持久上下文)→ Skills(skill.md + YAML front matter,渐进式披露,684 个社区技能,91 个内置)→ Soul(soul.md,塑造 Agent 人格/语气)→ Cron(自然语言定时任务,隔离 session 执行,结果回传原始聊天)→ Self-Improving Loop(工作→学习→记忆/技能→搜索历史→循环)。作者强调”自动不等于魔法”——用户必须主动纠正、要求保存记忆、允许 Agent 在复杂工作后创建 Skill。

  3. Cron 是 Hermes 相比 Claude Code 的最大差异化能力:作者已在实际使用中运行 daily AI news briefing、YouTube 评论监控(每 10 分钟检查一次,持续 12 小时)、school community engagement、morning business summaries、server security sweeps 等定时任务。Cron session 是隔离的、不继承当前会话上下文、不能递归创建新 Cron。Claude Code 的 Routines 在 Max 计划限制每天 15 次,Hermes 无此限制。

  4. VPS 部署流程极简化:推荐 Hostinger(有一键 Hermes 部署模板),KVM 2 起步(约 $100/年)。两种部署方式——Docker 容器(推荐,隔离性好,支持多 Agent)vs 根目录直接安装。部署步骤:选计划 → 选 Ubuntu 24.04 LTS → 一键 Docker 安装 Hermes → 设置 admin 账密 → 选推理提供商(OpenAI Codex OAuth,直接用 ChatGPT 订阅额度)→ 选模型(GPT 5.5)→ 连接 Telegram(BotFather 创建 bot → 获取 token → 获取 user ID)→ 完成。

  5. API Key 安全管理是关键最佳实践:绝不直接在聊天中粘贴 API Key(会进入会话历史),正确做法是 hermes config set GITHUB_TOKEN <token> 直接写入 .env 文件。每个 Agent 应使用独立账号/独立 API Key(最小权限原则),如同管理真实实习生——不给信用卡,不给全部权限。用 Claude Code 项目统一管理多个 VPS Agent 的密码、环境变量、架构信息。

  6. 多 Agent 扩展遵循”是否需要独立记忆/权限/调度”决策树:需要不同权限/密钥 → 新 Agent;需要独立长期记忆 → 新 Agent;持续重复工作 → 新 Agent;否则留在主 Agent。坏模式是一个巨型 Agent 持有所有 Key 和所有 Skill(高混乱 + 高风险)。好模式是按职能垂直拆分(marketing Hermes / finance Hermes),各自容器隔离,互不干扰。

  7. Telegram vs CLI 是”遥控器 vs 驾驶舱”:同一 Agent、同一大脑、同一窗口、同一技能、同一记忆,但 Telegram 可见性更低(无法精确管理 context window 何时 compaction)、slash 命令不全、不适合高风险操作(如 vibe code 一个完整 app)。CLI 适合深度编码、构建项目、长时间 session 管理。Telegram 适合定时任务、快速查询、移动办公。

  8. GitHub 同步是 Agent 运维保险:设置 nightly Cron(每晚午夜自动 push 到 private repo),确保 Agent 崩溃/VPS 故障时可从 repo 恢复到新 Agent,不丢失任何记忆和技能。设置过程:自然语言要求 Hermes 创建 private repo → 提供 GitHub Personal Access Token(classic,选 repo scope)→ 用 hermes config set 安全注入 → Agent 自动初始化 Git、创建 .gitignore、首次 push。

实操内容保留

代码/配置

API Key 安全注入命令(在 VPS Docker 容器终端中执行,而非 AI 聊天窗口):

hermes config set GITHUB_TOKEN <your_token_here>

GitHub Personal Access Token 创建要点

  • 类型选择 Classic token(而非 Fine-grained,因为 Fine-grained 在创建 repo 时权限不足)
  • Scope 勾选 repo(完整读写权限)
  • 建议设为永不过期(生产使用时)
  • 创建后立即复制,页面刷新后无法再查看

Docker 容器内 .env 文件编辑

# 进入 Docker 容器
docker exec -it <container_name> bash
# 编辑 .env
nano /opt/data/.env
# 保存:Ctrl+O → Enter → Ctrl+X

Prompt 模板

初始化 Hermes 人格的 Prompt

“Hey, Mr. Hermes. My name is Nate. I want you to be my ultimate personal AI assistant. So, let me know what you need from me and what features and stuff that you can actually do for me and how you can make my life easier.”

设置 nightly GitHub 同步 Cron 的 Prompt

“What we need to do is set up our first cron job. And I want you to build a skill around this. Basically, every single night at 12:00 a.m., so midnight Central Time, I want you to push changes to this GitHub repo. This is going to be kind of our source of truth. So, if you have any questions about that, please ask. But otherwise, just go ahead and set up the skill and set up the cron.”

让 Agent 自查 Telegram 连接故障的 Prompt

“Hey, for some reason the Telegram connection doesn’t seem to be working. I just shot the message off and said hello, and I’m not getting anything back.”

安装社区 Skill 并执行任务的 Prompt

“I want you to go ahead and real quick install the HyperFrames official skill from here and then generate me a 5-second video which is just like you introducing yourself and showing me a little bit of your personality. If there’s anything in your soul.md already.”

操作步骤

  1. VPS 部署:选 Hostinger → KVM 2 计划 → Ubuntu 24.04 LTS → Docker Manager → One-click Deploy → 搜索 Hermes Agent → 设置 admin 账密 → Deploy
  2. 推理提供商配置:选 OpenAI Codex → 跳转 ChatGPT 登录授权 → 获取 9 位验证码 → 回终端粘贴 → 选择模型(GPT 5.5)
  3. Telegram 连接:BotFather 创建 bot → 复制 token → 终端粘贴 → 搜索 @userinfobot 获取 user ID → 终端粘贴 → 完成
  4. GitHub 备份:自然语言告诉 Hermes 创建 private repo → 生成 GitHub token → hermes config set GITHUB_TOKEN → 告诉 Hermes token 已就位 → Agent 自动创建 repo 并首次 push
  5. 设置 nightly sync Cron:自然语言要求”every night at 12am push changes to GitHub” → Agent 自动创建 skill + Cron job

关键概念

  • Hermes Agent — 开源 AI Agent,MIT 协议,140K+ Stars,New Research 出品
  • OpenClaw — 同类竞品,350K+ Stars,团队更大更新频繁,Nvidia 基于它构建 Nemo Claw
  • Claude Code — 作者 90% 知识工作的主力工具,与 Hermes 互补
  • Codex — OpenAI Codex OAuth 可将 ChatGPT 订阅额度用于 Hermes 推理
  • Skill — Hermes 的核心扩展机制,684 个社区技能,渐进式披露,Agent 可自动创建
  • MCP 模型上下文协议 — Hermes 支持 MCP 连接外部工具

与其他素材的关联

原文精彩摘录

关于 Hermes 与 Claude Code 的心理定位: “Cloud Code is still my daily driver. That’s where I do 90% of my knowledge work throughout the day. But there’s a clear distinction in my mind between the way that I’m going to use Cloud Code and Open Claw or Hermes. So, this is obviously Anthropic’s coding assistant. It lives in your terminal next to your code, and you basically sit there and you drive it… Now, Open Claw and Hermes — I’m not going to use them to sit down and do my knowledge work and my coding. I’m going to use them when I’m on the go. When I want to be on my phone and be able to set up crons really quick and have everything kind of just be managed right there in Telegram where I can talk to something and it wakes up immediately and responds to me back. And it’s truly been a game-changer for being able to go on a walk and still do work.”

关于 Agent 自我改进的关键洞察: “Automatic does not mean magic. The loop works best when the user corrects Hermes, asks it to save things to memory, and lets it create and update skills after you’ve done some complex work… This isn’t a tool you finish setting up, it’s a teammate that you keep using and you keep training.”

关于 API Key 安全管理: “Pretend this is an actual intern or a new employee. What access would you give them? You wouldn’t just give them your credit card. You wouldn’t just give them all the stuff. So why would you do that with an autonomous agent?”

相关页面