Hermes Agent 第三阶段:高级操作——自定义模型、定时任务、并行子 Agent 与自定义工具
Hermes Agent 第三阶段:高级操作
"第二阶段让你的 Agent 有用。第三阶段让它成为生产力工作枢纽。"
第三阶段你将学会什么
在第二阶段中,你赋予了 Agent 记忆、自定义技能和多平台访问能力。现在我们要深入——将个人 Agent 转变为生产级自动化平台的操作层面。
完成本教程后,你将能够:
- 🎛️ 配置任意 OpenAI 兼容的模型供应商(本地、私有或自定义)
- ⏰ 安排 Hermes 自动执行任务(定时任务、每日简报、监控)
- 👥 启动并行子 Agent,同时处理多个任务
- 🛠️ 构建自定义工具,扩展 Hermes 的能力边界
- 🔒 设置多用户访问和权限控制
第一部分:自定义模型供应商配置
在第一阶段你使用向导选择了供应商。但 Hermes 支持任意 OpenAI 兼容的 API 端点——包括私有服务器、企业内部模型和奇特的开源权重部署。
手动供应商配置
hermes config set provider custom
hermes config set custom-api-base "https://your-server.com/v1"
hermes config set custom-api-key "sk-your-key"
hermes config set custom-model "your-model-name"
配置档案
对于在多个供应商之间切换的用户,Hermes 支持命名配置档案:
hermes profile create work
hermes profile set work provider openai
hermes profile set work model gpt-5.6-sol
hermes profile create home
hermes profile set home provider custom
hermes profile set home custom-api-base "http://home-server:8000/v1"
hermes profile switch work # 切换到工作配置
hermes profile switch home # 切换到家庭配置
hermes profile list # 列出所有配置
高级:路由器配置
你可以配置一个路由器,将不同类型的请求导向不同模型:
# ~/.hermes/config.yaml(手动编辑)
router:
rules:
- pattern: "写|创作|草稿|文章|essay"
model: "claude-sonnet-5"
provider: "anthropic"
- pattern: "代码|调试|重构|测试|code|debug"
model: "gpt-5.6-terra"
provider: "openai"
- pattern: "搜索|浏览|研究|search|research"
model: "gpt-5.6-luna"
provider: "openai"
- pattern: ".*"
model: "hermes-3-12b"
provider: "local"
为什么重要: 有了路由器配置,你可以在复杂推理时用 GPT-5.6 Sol,写作时用 Claude,其他一切由本地模型处理——同时优化成本和质量。
第二部分:定时任务——你的 Agent 按计划工作
Hermes Agent 内置了定时调度器,让你可以按循环计划运行 Agent 任务。无需外部 cron 守护进程。
基础定时任务
# 每天早上8点运行简报任务
hermes cron add \
--name "morning-briefing" \
--schedule "0 8 * * *" \
--prompt "搜索今日 AI 头条新闻,用 5 个要点总结。保存到 ~/briefings/$(date +%Y-%m-%d).md"
# 每小时运行
hermes cron add \
--name "hourly-health" \
--schedule "0 * * * *" \
--prompt "检查我的服务器进程状态,报告任何异常。"
定时格式
标准 cron 语法:
0 8 * * * → 每天 8:00
0 8 * * 1-5 → 工作日 8:00
0 0 1 * * → 每月1日
*/15 * * * * → 每15分钟
实用定时任务场景
| 用途 | 定时 | 提示词 |
|---|---|---|
| 每日新闻简报 | 0 8 * * * |
"总结5条AI头条,保存到 briefings/today.md" |
| 每周博客 | 0 9 * * 1 |
"写一篇1500字博客,保存到 ~/blog/drafts/" |
| 股价提醒 | 0 9,13,16 * * 1-5 |
"检查 SKHY 股价,相比IPO价跌超5%则通过网关提醒我" |
| 竞争监控 | 0 10 * * 1 |
"检查3个竞品网站的新功能变化,总结差异" |
第三部分:并行子 Agent——同时做多件事
默认情况下,Hermes 一次处理一个请求。但通过子 Agent,你可以启动多个 Agent 并行工作——每个有自己的任务、模型和工具集。
启动子 Agent
hermes agent spawn --task "研究 NVIDIA 最新 GPU 发布"
高级子 Agent 配置
hermes agent spawn \
--task "写一个 Python 脚本解析 CSV 数据" \
--model "gpt-5.6-terra" \
--tools "code,file" \
--timeout 120
# 异步启动(发射后不管)
hermes agent spawn --async \
--task "下载并总结 arXiv 上最新的 RLHF 论文" \
--output "~/research/rlhf-summary.md"
集体任务
对于复杂工作流,你可以定义一个集体(collective)——一组协作的子 Agent:
hermes collective create --name "市场研究"
hermes collective add-agent --name "分析1" --task "分析 SK 海力士 Q2 财报"
hermes collective add-agent --name "分析2" --task "研究 2026 年 HBM 市场份额趋势"
hermes collective add-agent --name "分析3" --task "整理竞品定价数据(美光、三星)"
hermes collective run
每个 Agent 独立工作。全部完成后,Hermes 呈现一份合并报告。
子 Agent 命令
hermes agent list # 列出活跃子 Agent
hermes agent status --id <id> # 查看特定子 Agent
hermes agent cancel --id <id> # 取消运行中的子 Agent
hermes collective list # 列出已定义的集体
hermes collective run --name "..." # 运行集体任务
第四部分:构建自定义工具
Hermes 自带 40+ 内置工具,但有时你需要特定的工具。Hermes 允许你用简单的 YAML + Python 格式创建自定义工具。
创建"GitHub Trending"工具
步骤 1:创建清单
hermes tools create --name "github-trending"
步骤 2:创建处理器
# ~/.hermes/tools/github-trending/handler.py
import requests, json, sys
def run(params):
language = params.get("language", "")
max_results = params.get("max_results", 10)
query = "stars:>1000"
if language:
query += f" language:{language}"
api_url = f"https://api.github.com/search/repositories?q={query}&sort=stars&order=desc&per_page={max_results}"
resp = requests.get(api_url, headers={"User-Agent": "Hermes-Agent/1.0"})
repos = resp.json().get("items", [])
return [{"name": r["full_name"], "stars": r["stargazers_count"]} for r in repos]
步骤 3:测试并对话中使用
hermes tools test github-trending --params '{"language": "python", "max_results": 5}'
工具权限模型
# 在 tool.yaml 中
permissions:
network: true # 可以发 HTTP 请求
filesystem: read # read / write / none
execution: false # 可以运行 shell 命令
安全提示: 工具在沙箱环境中运行,权限受其权限模型控制。
network: true, filesystem: none, execution: false的工具无法读取你的文件或运行命令——只能发 API 调用。
安装社区工具
hermes tools search "notion" # 搜索工具注册表
hermes tools install "notion-api" # 安装社区工具
hermes tools publish # 发布你的工具
第五部分:多用户访问与权限
如果你将 Hermes 作为团队 Agent 运行,你需要控制谁能做什么。
创建用户
hermes user add --name "alice" --role "editor"
hermes user add --name "bob" --role "viewer"
基于角色的访问
| 角色 | 权限 |
|---|---|
admin |
完全访问——所有命令、配置、工具 |
editor |
可以聊天、使用工具、创建技能——不能修改系统配置 |
viewer |
只能聊天——不能修改任何配置 |
第三阶段速查表
# 自定义模型
hermes config set provider custom
hermes profile create <名称>
hermes profile switch <名称>
# 定时任务
hermes cron add --name "<名称>" --schedule "<cron>" --prompt "<提示词>"
hermes cron list
# 子 Agent
hermes agent spawn --task "<任务>"
hermes collective create --name "<名称>"
hermes collective run --name "<名称>"
# 自定义工具
hermes tools create --name "<名称>"
hermes tools install "<名称>"
hermes tools list
下期预告:第四阶段——骨灰篇
你已经将 Agent 从对话工具转变为自动化平台。自定义路由、定时任务、并行 Agent 和自定义工具,是"好玩实验"和"正经基础设施"之间的分水岭。
| 阶段 | 标题 | 状态 |
|---|---|---|
| 🟢 第一阶段 | 入门指南 | ✅ 已完成 |
| 🟡 第二阶段 | 记忆、技能和网关 | ✅ 已完成 |
| 🟠 第三阶段 | 高级操作 | ✅ 已完成 |
| 🔴 第四阶段 | 骨灰篇——RL训练、轨迹生成、模型微调 | 📅 下一期 |
准备好了吗? 第四阶段:骨灰篇将教你 RL 训练自己的 Agent 轨迹、生成合成训练数据、微调自定义 Agent 模型。
本教程内容基于 Hermes Agent 最新稳定版本,更新于 2026 年 7 月 10 日。