Hermes Agent 完全使用指南:日常技巧与常见用法详解
约 10 分钟2885 字7 次阅读

Hermes Agent 完全使用指南:日常技巧与常见用法详解
Hermes Agent 是 Nous Research 开源的多平台 AI Agent 框架,支持终端、IDE 和消息平台( Telegram、Discord、飞书等)运行,可接入任意 LLM 提供商。本文详细介绍其日常使用技巧和常见用法,帮助你充分发挥这个强大工具的潜力。
一、初识 Hermes Agent
1.1 什么是 Hermes Agent
Hermes Agent 是一个开源的 AI Agent 框架,与 Claude Code(Anthropic)、Codex(OpenAI)属于同一类别——能够通过工具调用与系统交互的自主编码和任务执行 Agent。它的核心特点包括:
- 自进化技能系统:将可复用的流程保存为技能文档,在未来的对话中自动加载,随着使用不断进化
- 跨会话持久记忆:记住用户身份、偏好、环境配置和经验总结
- 多平台网关:同一套 Agent 运行在 Telegram、Discord、Slack、飞书、邮件等 10+ 平台上
- Provider 无锁定:可随时切换不同模型和提供商(OpenRouter、Anthropic、OpenAI、DeepSeek、本地模型等)
- 可扩展架构:支持插件、MCP 服务器、自定义工具、Webhook 触发、定时任务
1.2 快速安装与启动
# 安装
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
# 交互式聊天(默认)
hermes
# 单次查询
hermes chat -q "What is the capital of France?"
# 设置向导
hermes setup
# 修改模型/提供商
hermes model
# 健康检查
hermes doctor
二、核心概念与架构
2.1 工具集(Toolsets)
Hermes 通过工具集组织能力,每个工具集提供一组相关工具:
| 工具集 | 功能 |
|---|---|
web | 网页搜索与内容提取 |
browser | 浏览器自动化 |
terminal | Shell 命令和进程管理 |
file | 文件读写、搜索、打补丁 |
code_execution | 沙箱 Python 执行 |
vision | 图片分析 |
image_gen | AI 图片生成 |
video | 视频分析与生成 |
tts | 文字转语音 |
skills | 技能浏览与管理 |
memory | 跨会话持久记忆 |
session_search | 搜索历史对话 |
delegation | 子 Agent 任务委托 |
cronjob | 定时任务管理 |
messaging | 跨平台消息发送 |
kanban | 多 Agent 工作队列工具 |
spotify | Spotify 播放控制 |
feishu_doc | 飞书文档工具 |
yuanbao | 腾讯元宝集成 |
2.2 技能(Skills)
技能是 Hermes 的记忆与流程单元。当 Agent 解决了一个复杂问题、发现了某个工作流程或被用户纠正时,可以将这个知识保存为技能文档,在未来的会话中自动加载。技能支持版本管理、使用统计和自动老化机制。
2.3 对话模式与定时任务
Hermes 支持两种持久化执行模式:
- 委托任务(delegate_task):同步子 Agent 孵化,适用于需要并行处理的短时子任务
- 定时任务(cronjob):持久化调度,支持定时重复执行,适用于数据监控、定期报告等场景
三、基础配置与认证
3.1 模型配置
Hermes 支持 20+ 模型提供商,配置方式如下:
# 交互式选择模型
hermes model
# 或直接配置
hermes config set model.provider openrouter
hermes config set model.default anthropic/claude-sonnet-4
主要提供商及认证方式:
| 提供商 | 认证方式 | 环境变量 |
|---|---|---|
| OpenRouter | API Key | OPENROUTER_API_KEY |
| Anthropic | API Key | ANTHROPIC_API_KEY |
| DeepSeek | API Key | DEEPSEEK_API_KEY |
| Google Gemini | API Key | GOOGLE_API_KEY |
| MiniMax | API Key | MINIMAX_API_KEY |
| xAI | API Key | XAI_API_KEY |
3.2 代理配置
如果网络受限需要使用代理:
# 设置 HTTP/SOCKS 代理
export all_proxy=socks5h://192.168.0.48:1080
# 或在配置中设置
hermes config set web.search_backend searxng
hermes config set web.searxng_url http://192.168.0.41:8888
3.3 多提供商与凭证池
Hermes 支持为单一提供商配置多个 API 密钥(凭证池),支持自动轮换和故障转移:
hermes auth list # 查看当前凭证
hermes auth add # 添加新凭证
hermes auth remove <provider> <index> # 移除凭证
四、日常使用技巧
4.1 基础会话操作
# 新建会话(默认)
hermes chat
# 恢复最近会话
hermes chat --continue
# 按标题或ID恢复会话
hermes chat --resume <session_id_or_title>
# 单次查询模式(非交互)
hermes chat -q "解释什么是 RAG"
# 加载指定技能后启动
hermes -s lark-doc -s claude-code
4.2 斜杠命令(Slash Commands)
在交互式会话中可以直接使用斜杠命令:
会话控制
/new 或 /reset # 新建会话
/clear # 清屏 + 新会话
/retry # 重发上一条消息
/undo # 撤销上一次交换
/title [名称] # 为会话命名
/compress # 手动压缩上下文
/stop # 终止后台进程
/rollback [N] # 恢复文件系统检查点
/background <提示> # 后台运行提示
/queue <提示> # 排队等待下一轮
/steer <提示> # 注入消息(不打断当前工作)
/agents # 显示活跃的 Agent 和运行中的任务
/resume [名称] # 恢复命名会话
/goal [文本|sub] # 设置持续目标(跨轮次持续工作)
配置相关
/config # 显示当前配置
/model [名称] # 切换模型
/personality [名称] # 设置人格
/reasoning [级别] # 设置推理深度
/verbose # 切换详细输出模式
/voice [on|off|tts] # 语音模式
/yolo # 切换审批绕过
工具与技能
/tools # 管理工具(CLI)
/toolsets # 列出工具集
/skills # 搜索/安装技能
/skill <名称> # 加载技能到当前会话
/reload-skills # 重新扫描技能目录
/cron # 管理定时任务
/kanban [sub] # 多Profile协作面板
/plugins # 列出插件
网关控制
/approve # 批准待处理命令
/deny # 拒绝待处理命令
/restart # 重启网关
/sethome # 设置当前对话为家庭频道
/update # 更新 Hermes
/platforms # 显示平台连接状态
实用工具
/branch 或 /fork # 分支当前会话
/fast # 切换优先级处理
/browser # 打开 CDP 浏览器连接
/history # 显示对话历史
/save # 保存对话到文件
/copy [N] # 复制上一条回复到剪贴板
/paste # 附加剪贴板图片
/image # 附加本地图片文件
信息查询
/help # 显示命令帮助
/commands [页码] # 浏览所有命令
/usage # Token 使用量
/insights [天数] # 使用分析
/status # 会话信息
/profile # 当前 Profile 信息
/debug # 上传调试报告
4.3 文件操作技巧
Hermes 的文件工具比传统 Shell 命令更智能:
# 读取文件(自动分页,不会一次性加载大文件)
read_file(path="/path/to/file.py", offset=1, limit=500)
# 搜索文件内容
search_files(pattern="def main", path="/project", output_mode="content")
# 查找文件
search_files(pattern="*.md", target="files", path="/project")
# 补丁编辑(精确替换)
patch(path="file.py", old_string="old text", new_string="new text")
# 写入文件(完整覆写)
write_file(path="/tmp/output.txt", content="Hello World")
注意事项:
- 不要用
cat/head/tail读取文件——用read_file - 不要用
grep/rg/find/ls搜索——用search_files - 不要用
sed/awk编辑——用patch - 不要用
echo/heredoc创建文件——用write_file
4.4 终端操作技巧
# 前台执行(默认)
terminal(command="make test", timeout=300)
# 后台执行(用于长时间运行的进程)
terminal(command="python server.py", background=true)
# 带工作目录
terminal(command="npm run build", workdir="/path/to/project")
# PTY 模式(交互式 CLI)
terminal(command="claude", pty=true)
后台进程管理:
# 列出所有后台进程
process(action="list")
# 查看输出
process(action="log", session_id="abc123", limit=50)
# 终止进程
process(action="kill", session_id="abc123")
# 发送输入
process(action="write", session_id="abc123", data="some input")
五、代码开发工作流
5.1 委托 Claude Code
当需要复杂的编码任务时,可以委托 Claude Code 处理:
# 单次任务(推荐)
terminal(command="claude -p 'Add error handling to src/api.py' --max-turns 10 --allowedTools 'Read,Edit'", workdir="/project", timeout=120)
# 交互式任务(需 tmux)
terminal(command="tmux new-session -d -s claude-work -x 140 -y 40")
terminal(command="tmux send-keys -t claude-work 'cd /project && claude' Enter")
terminal(command="sleep 5 && tmux send-keys -t claude-work 'Refactor the database layer' Enter")
5.2 Git 工作流
# 提交所有更改
terminal(command="git add -A && git commit -m 'feat: add user authentication'")
# 创建并切换分支
terminal(command="git checkout -b feature/new-feature")
# 查看状态
terminal(command="git status")
# 查看差异
terminal(command="git diff main...feature-branch")
5.3 测试驱动开发(TDD)
使用 test-driven-development 技能强制执行 RED-GREEN-REFACTOR 循环:
加载 test-driven-development 技能
TDD 流程:先写测试(RED)→ 让测试通过(GREEN)→ 重构(REFACTOR)。
六、飞书集成应用
6.1 飞书文档操作
# 创建文档
lark-cli docs +create --api-version v2 --doc-format markdown --content "# 标题\n\n内容"
# 读取文档
lark-cli docs +fetch --api-version v2 --doc "文档URL或token"
# 更新文档
lark-cli docs +update --api-version v2 --doc "文档token" --command append --content "<p>新内容</p>"
6.2 飞书消息
# 发送消息
lark-cli im +message-send --content "你好" --chat-id <chat_id>
# 搜索聊天记录
lark-cli im +message-search --keyword "关键词"
6.3 飞书日历
# 查看今日日程
lark-cli calendar +agenda
# 创建日程
lark-cli calendar +create --title "会议" --start-time "2025-05-15T10:00:00Z"
# 查询会议室
lark-cli calendar +room-find --start-time "2025-05-15T10:00" --end-time "2025-05-15T11:00"
6.4 飞书云空间
# 上传文件
lark-cli drive +upload --file "/path/to/file.pdf"
# 搜索文件
lark-cli drive +search --keyword "文档名称"
# 下载文件
lark-cli drive +download --file-token <token>
七、定时任务与自动化
7.1 创建定时任务
# 每30分钟执行
hermes cron create "30m" --prompt "检查系统状态"
# 每2小时执行
hermes cron create "every 2h" --prompt "生成AI简报"
# 每天上午9点执行
hermes cron create "0 9 * * *" --prompt "发送日报"
# 指定具体时间
hermes cron create "2025-05-15T10:00:00" --prompt "一次性任务"
7.2 定时任务参数
# 带技能加载
hermes cron create "0 9 * * *" --skills "lark-doc,github-pr-workflow" --prompt "生成项目周报"
# 指定模型
hermes cron create "0 9 * * 1" --model "anthropic/claude-sonnet-4" --prompt "周一早间技术调研"
# 链式任务(上一任务输出作为输入)
hermes cron create "0 9 * * *" --context-from <job_id> --prompt "处理收集到的数据"
# 指定工作目录
hermes cron create "every 1h" --workdir "/path/to/project" --prompt "运行测试"
7.3 管理定时任务
hermes cron list # 列出所有任务
hermes cron edit <id> # 编辑任务
hermes cron pause <id> # 暂停任务
hermes cron resume <id> # 恢复任务
hermes cron run <id> # 立即触发一次
hermes cron remove <id> # 删除任务
八、多 Agent 协作
8.1 delegate_task 的使用场景
# 单任务委托
delegate_task(
goal="分析 /project/src 下的代码质量",
context="项目路径:/project/src,使用 Python 3.11",
toolsets=["terminal", "file"]
)
# 批量并行委托
delegate_task(
tasks=[
{"goal": "修复模块A的bug", "context": "...", "toolsets": ["terminal"]},
{"goal": "优化模块B的性能", "context": "...", "toolsets": ["terminal"]},
{"goal": "编写模块C的测试", "context": "...", "toolsets": ["terminal"]}
]
)
8.2 子 Agent vs 独立进程
delegate_task | 独立 hermes 进程 | |
|---|---|---|
| 隔离性 | 独立对话,共享进程 | 完全独立 |
| 时长 | 分钟级 | 小时/天级 |
| 工具访问 | 父 Agent 的子集 | 完整工具集 |
| 交互式 | 否 | 可(PTY 模式) |
| 适用场景 | 快速并行子任务 | 长期自主任务 |
8.3 多 Agent 协调模式
# Agent A: 后端开发
terminal(command="tmux new-session -d -s backend -x 120 -y 40 'hermes -w'")
terminal(command="sleep 8 && tmux send-keys -t backend 'Build REST API for user management' Enter")
# Agent B: 前端开发
terminal(command="tmux new-session -d -s frontend -x 120 -y 40 'hermes -w'")
terminal(command="sleep 8 && tmux send-keys -t frontend 'Build React dashboard for user management' Enter")
# 检查进度
terminal(command="tmux capture-pane -t backend -p | tail -30")
# 传递上下文
terminal(command="tmux send-keys -t frontend 'Here is the API schema: ...' Enter")
九、记忆与上下文管理
9.1 持久记忆
# 保存记忆
memory(action="add", target="user", content="用户偏好:喜欢简洁的回复风格")
memory(action="add", target="memory", content="项目使用 pytest with xdist")
# 查看记忆
memory(action="list")
# 删除记忆
memory(action="remove", target="memory", old_text="过时的记忆内容")
9.2 跨会话搜索
# 搜索历史对话
session_search(query="之前如何配置 lark-cli")
# 浏览最近会话
session_search()
9.3 上下文压缩
当对话变长时,Hermes 会自动触发上下文压缩:
/compress手动触发压缩- 压缩后 CLAUDE.md 中的信息会保留
- 定期
/clear可以开始全新对话
十、Gateway 与消息平台
10.1 Gateway 部署
# 安装为后台服务
hermes gateway install
# 启动/停止/重启
hermes gateway start
hermes gateway stop
hermes gateway restart
# 查看状态
hermes gateway status
10.2 支持的消息平台
| 平台 | 说明 |
|---|---|
| Telegram | 即时通讯 |
| Discord | 社区/游戏聊天 |
| Slack | 企业协作 |
| 即时通讯 | |
| Signal | 安全通讯 |
| Matrix | 去中心化通讯 |
| 邮件 | |
| 飞书 | 企业协作 |
| DingTalk | 钉钉 |
| WeCom | 企业微信 |
10.3 Webhook 订阅
# 创建 Webhook 路由
hermes webhook subscribe <name>
# 测试 Webhook
hermes webhook test <name>
# 列出 Webhook
hermes webhook list
# 删除 Webhook
hermes webhook remove <name>
十一、技能(Skills)管理
11.1 搜索和安装技能
# 搜索技能
npx skills find "飞书文档"
# 安装技能
npx skills add vercel-labs/agent-skills --skill find-skills --yes --global
# 从 URL 安装
npx skills add https://github.com/owner/repo --skill my-skill --yes --global
# 查看已安装技能
hermes skills list
# 检查更新
hermes skills check
# 更新技能
hermes skills update
11.2 创建自定义技能
# 创建新技能
npx skills init my-custom-skill
# 查看技能目录
ls ~/.hermes/skills/
技能文件结构:
my-custom-skill/
├── SKILL.md # 主文件(必需)
├── references/ # 参考文档
├── scripts/ # 脚本
└── assets/ # 资源文件
11.3 技能创作规范
SKILL.md 必须包含 YAML frontmatter:
---
name: my-skill
description: "技能的简短描述"
version: 1.0.0
author: Hermes Agent
license: MIT
platforms: [linux, macos, windows]
metadata:
hermes:
tags: [tag1, tag2]
related_skills: [other-skill]
---
十二、配置深度指南
12.1 配置文件结构
主配置文件:~/.hermes/config.yaml
关键配置段:
model:
default: anthropic/claude-sonnet-4
provider: openrouter
agent:
max_turns: 90
tool_use_enforcement: true
terminal:
backend: local
cwd: /home/user/projects
timeout: 180
compression:
enabled: true
threshold: 0.50
target_ratio: 0.20
display:
skin: default
tool_progress: true
show_reasoning: false
show_cost: true
delegation:
model: anthropic/claude-haiku
max_concurrent_children: 3
max_spawn_depth: 1
12.2 安全配置
密钥自动抹除:
hermes config set security.redact_secrets true # 启用
命令审批模式:
hermes config set approvals.mode manual # 始终询问(默认)
hermes config set approvals.mode smart # 低风险自动批准,高风险询问
hermes config set approvals.mode off # 跳过所有确认
隐私模式:
hermes config set privacy.redact_pii true # 启用 PII 抹除
12.3 MCP 服务器配置
# 添加 MCP 服务器
hermes mcp add firecrawl --url http://192.168.0.41:3002
# 列出 MCP 服务器
hermes mcp list
# 测试连接
hermes mcp test firecrawl
# 配置工具选择
hermes mcp configure firecrawl
十三、高级话题
13.1 Profiles 多Profile管理
# 列出所有 Profile
hermes profile list
# 创建新 Profile
hermes profile create work
# 克隆现有 Profile
hermes profile create personal --clone-from default
# 切换 Profile
hermes profile use work
# 删除 Profile
hermes profile delete old-profile
# 导出/导入 Profile
hermes profile export work
hermes profile import work-backup.tar.gz
13.2 语音与转录
STT(语音转文字):
hermes config set stt.enabled true
hermes config set stt.provider local # 免费方案:faster-whisper
TTS(文字转语音):
tts:
provider: edge # 免费默认方案
# 或使用 ElevenLabs(需 API Key)
# provider: elevenlabs
13.3 Curators 自动技能维护
Curator 是后台运行的技能生命周期管理器:
hermes curator status # 查看状态
hermes curator run # 手动触发维护
hermes curator pause # 暂停
hermes curator resume # 恢复
hermes curator archive <skill> # 归档技能
hermes curator prune # 清理过期技能
十四、故障排除
14.1 常见问题与解决方案
问题:工具不可用
# 检查工具是否启用
hermes tools list
# 启用工具
hermes tools enable <toolset>
# 重置会话
/hermes reset
问题:模型调用失败
# 检查配置
hermes doctor
# 重新认证
hermes login --provider openrouter
# 检查 API Key
cat ~/.hermes/.env | grep OPENROUTER
问题:Gateway 无响应
# 检查日志
grep -i "failed to send\|error" ~/.hermes/logs/gateway.log | tail -20
# 重启 Gateway
hermes gateway restart
# 清理失效状态
systemctl --user reset-failed hermes-gateway
问题:技能不显示
# 重新加载技能
/reload-skills
# 检查技能路径
ls ~/.hermes/skills/
# 手动加载技能
/skill <skill-name>
14.2 更新 Hermes
# 更新到最新版本
hermes update
# 同时更新技能
npx skills update --global
十五、实战案例
15.1 案例一:自动化代码评审
# 创建一个每天定时运行的代码评审任务
hermes cron create "0 10 * * *" --name "daily-code-review" --skills "github-pr-workflow,claude-code" --prompt "1. 获取今日所有 PR 列表;2. 对每个 PR 进行代码评审;3. 在 PR 下发布评审意见;4. 将评审摘要保存到 ~/reviews/$(date +%Y%m%d).md"
15.2 案例二:飞书日报推送
# 创建工作日早上9点推送日报的任务
hermes cron create "0 9 * * 1-5" --name "daily-feishu-report" --skills "lark-doc,lark-calendar" --prompt "1. 读取今日日历获取会议列表;2. 查询 GitHub 待处理 PR;3. 生成简洁日报;4. 发送到飞书群"
15.3 案例三:多 Agent 并行开发
# Agent A 负责后端 API
hermes chat -q "为用户管理系统构建 FastAPI 后端,包括用户注册、登录、JWT 认证" -w backend-agent
# Agent B 负责前端界面
hermes chat -q "构建 React 管理后台,包括用户列表、详情页、表单" -w frontend-agent
# 完成后合并
hermes chat -q "合并后端和前端代码,确保 API 对接正常"
结语
Hermes Agent 是一个功能强大、高度可定制的 AI Agent 框架。通过熟练掌握本文介绍的各项技巧——从基础的会话操作、文件处理,到高级的多 Agent 协作、定时任务编排——你将能够大幅提升日常工作和生活中的生产力。
建议从你最常用的场景开始尝试,逐步探索更多高级功能。善用技能系统(Skills),让 Hermes 在使用过程中不断学习和进化,成为真正懂你、为你所用的智能助手。
本文基于 Hermes Agent v2.x 版本编写,部分功能可能随版本更新而变化。建议定期查阅官方文档获取最新信息。
相关资源: