Qi

Cogito ergo sum

Agent Hermes 与 OpenClaw 部署迁移与运维实战指南

Deployment, Migration & Operations Guide for Agent Hermes & OpenClaw

最后更新 | Last updated: 2026-06-06


一、部署模式总览 | Deployment Patterns Overview

中文

个人 Agent 常见四种部署拓扑:

flowchart TB
    subgraph A["模式 A:本地 Loopback"]
        LAP[笔记本 localhost]
        LAP --> GW1[Gateway 仅本机]
    end
    subgraph B["模式 B:VPS + 消息平台"]
        VPS[$5 VPS 长驻]
        PHONE[手机 Telegram/WhatsApp]
        PHONE --> VPS
    end
    subgraph C["模式 C:分离式 Gateway/执行"]
        GWM[Gateway 机 — 仅消息]
        EXE[执行机 — Docker/SSH]
        GWM -->|SSH| EXE
    end
    subgraph D["模式 D:Serverless(Hermes)"]
        GWH[Hermes Gateway]
        MOD[Modal / Daytona]
        GWH --> MOD
    end
模式 OpenClaw Hermes 适用
A 本地 gateway.bind: loopback Gateway 默认不暴露 HTTP 最安全开发
B VPS openclaw onboard --install-daemon hermes gateway install 最常见生产
C 分离 sandbox + remote node terminal.backend: ssh 高安全
D Serverless Modal/Daytona 后端 低闲置成本

English

Four deployment patterns: local loopback (safest dev), VPS + messaging (most common prod), split gateway/execution (high security), serverless backends (Hermes Modal/Daytona for near-zero idle cost).


二、Hermes 安装 | Hermes Installation

中文

2.1 一键安装

Linux / macOS / WSL2 / Android (Termux):

1
2
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
source ~/.bashrc # 或 source ~/.zshrc

Windows 原生(PowerShell):

1
iex (irm https://hermes-agent.nousresearch.com/install.ps1)

Windows 推荐路径:WSL2 内运行 bash 安装脚本 — 与 Linux 生产环境一致。

Termux(Android):直接在手机上运行 Agent,适合轻量 Gateway + Telegram Bot。注意电量与后台进程限制。

2.2 安装器做了什么

组件 说明
uv Python 包管理
Python 3.11 经 uv 安装,无需 sudo
Node.js v22 浏览器自动化、WhatsApp bridge
ripgrep 快速文件搜索
ffmpeg TTS 音频转换
仓库克隆 ~/.hermes/hermes-agent/
全局命令 ~/.local/bin/hermes

2.3 安装布局

方式 代码位置 数据目录
Git 安装器(用户) ~/.hermes/hermes-agent/ ~/.hermes/
pip install site-packages ~/.hermes/
sudo 系统安装 /usr/local/lib/hermes-agent/ 每用户 ~/.hermes/$HERMES_HOME

2.4 初始化

1
2
3
4
5
hermes setup              # 完整配置向导
hermes setup --portal # 推荐:OAuth + Tool Gateway 一步完成
hermes model # 选择 Provider 与模型
hermes tools # 配置 toolsets
hermes gateway setup # 配置消息平台

hermes setup --portal 覆盖:模型 Provider + web search + image gen + TTS + cloud browser — 最低摩擦无人值守路径

English

Install via curl script (Linux/macOS/WSL2/Termux) or PowerShell (native Windows; WSL2 preferred). Installer bundles Python, Node, ripgrep, ffmpeg. Run hermes setup --portal for fastest OAuth + Tool Gateway setup.

2.5 非 root / systemd 服务用户

1
2
3
4
5
6
7
8
9
# 管理员一次性(Debian/Ubuntu)
sudo npx playwright install-deps chromium

# 服务用户
curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash
# 或跳过浏览器:bash -s -- --skip-browser

# 确保 PATH 含 ~/.local/bin/hermes
hermes doctor

English

For systemd service accounts: admin installs Playwright system deps; service user runs installer with --skip-browser if headless only. Verify with hermes doctor.


三、OpenClaw 安装 | OpenClaw Installation

中文

1
2
3
npm install -g openclaw@latest
openclaw onboard --install-daemon
openclaw dashboard
步骤 作用
npm install -g 全局 CLI + Gateway
onboard --install-daemon 引导式配置 + 系统服务(launchd/systemd)
dashboard 浏览器控制台 http://127.0.0.1:18789/

工作区默认:~/.openclaw/workspace/(SOUL.md、AGENTS.md 等)

主配置:~/.openclaw/openclaw.json

English

npm install -g openclaw@latest, then openclaw onboard --install-daemon for guided setup and daemon install. Control UI at http://127.0.0.1:18789/. Workspace at ~/.openclaw/workspace/.


四、渠道配置:Telegram 最快路径 | Channel Setup: Telegram Fastest Path

中文

Telegram 是两框架 上手最快 的渠道之一:Bot Token 申请简单、无需企业资质、长轮询即可运行。

4.1 Hermes Telegram

1
2
3
4
5
hermes gateway setup
# 或编辑 ~/.hermes/.env:
# TELEGRAM_BOT_TOKEN=...
# TELEGRAM_ALLOWED_USERS=123456789
hermes gateway start

生产建议:

  • 配置 TELEGRAM_ALLOWED_USERS 或启用 DM pairing
  • terminal.backend: docker
  • 可选 TELEGRAM_HOME_CHANNEL 用于 Cron 投递

4.2 OpenClaw Telegram

1
2
3
4
5
6
7
8
9
{
channels: {
telegram: {
botToken: "...",
dmPolicy: "pairing",
groups: { "*": { requireMention: true } },
},
},
}

通过 openclaw dashboard 或 onboard 向导配置。

4.3 渠道对比速查

渠道 上手难度 Hermes OpenClaw
Telegram ★☆☆ 内置 Adapter 内置
Discord ★★☆ 内置 内置
WhatsApp ★★★ Cloud API / Baileys 内置 bridge
iMessage ★★★★ BlueBubbles 内置 + Nodes
企业微信/飞书 ★★★ 内置 插件

English

Telegram is the fastest channel for both frameworks. Hermes: hermes gateway setup + allowlist/pairing. OpenClaw: channels.telegram in openclaw.json with dmPolicy: pairing.


五、Gateway 系统服务 | Gateway as System Service

中文

5.1 Hermes

1
2
3
4
5
hermes gateway install              # 用户级 systemd/launchd
sudo hermes gateway install --system # Linux 开机系统服务
hermes gateway start
hermes gateway stop
hermes gateway stop --all # 更新前停止所有 Profile

PID 文件:~/.hermes/gateway.pid(Profile 作用域)

后台任务并行运行:Cron 调度(60s tick)、会话过期、记忆 flush、Provider 缓存刷新。

5.2 OpenClaw

openclaw onboard --install-daemon 安装 launchd/systemd 服务。

1
2
3
4
5
6
7
{
gateway: {
mode: "local",
bind: "loopback", // 生产:loopback 或 auth
auth: { mode: "token", token: "long-random-token" },
},
}

远程访问:Tailscale 或 SSH 隧道 — 避免直接公网暴露 18789

English

Hermes: hermes gateway install (user or --system service). OpenClaw: daemon via onboard. Bind loopback or enable auth; use Tailscale/SSH for remote access.


六、hermes claw migrate 迁移 | Migrating from OpenClaw

中文

1
hermes claw migrate

一键从 ~/.openclaw/ 导入:

导入项 目标
SOUL.md Hermes 人格 / global SOUL
MEMORY.md / USER.md 持久记忆条目
skills/ ~/.hermes/skills/
API Keys .env 映射
消息/Gateway 设置 Hermes 平台配置

迁移后仍需

1
2
3
hermes model              # 确认 Provider
hermes gateway setup # 验证渠道 Token
hermes doctor # 健康检查

适用场景:已有龙虾部署、想叠加 Hermes 学习闭环,或社区 HermesClaw 双栈实验。

English

hermes claw migrate imports SOUL, memory, skills, API keys, and messaging config from ~/.openclaw/. Follow with hermes model, hermes gateway setup, and hermes doctor.


七、诊断与审计 | Diagnostics & Auditing

中文

7.1 hermes doctor

1
2
hermes doctor
hermes doctor --ack <id> # 确认处置供应链告警

检查项包括:

  • Python venv 完整性
  • 已知妥协包版本(供应链蠕虫等)
  • 配置迁移状态
  • 安装方式检测(pip/git/Homebrew/Nix)
  • 缺失依赖与修复建议

7.2 openclaw security audit

1
2
3
openclaw security audit
openclaw security audit --deep # 含实时 Gateway 探测
openclaw security audit --fix # 自动修复常见问题

覆盖:入站访问、工具爆炸半径、网络暴露、文件权限、插件策略漂移。

7.3 对照表

操作 OpenClaw Hermes
健康诊断 Gateway 日志 + security audit hermes doctor
安全审计 openclaw security audit --deep doctor + Tirith + 审批配置
更新 npm update -g openclaw hermes update(自动检测安装方式)
配置检查 手动编辑 openclaw.json hermes config check / migrate

English

hermes doctor for health and supply-chain advisories. openclaw security audit [--deep] [--fix] for OpenClaw hardening. hermes update auto-detects install method.


八、ACP IDE 集成 | ACP IDE Integration

中文

1
2
pip install -e '.[acp]'    # 或在标准安装后
hermes acp
编辑器 配置
VS Code ACP Client 扩展 → acp.agents.Hermes Agent
Zed ACP Registry → uvx --from 'hermes-agent[acp]' hermes-acp
JetBrains 指向 acp_registry/

ACP 使用 hermes-acp 精选 toolset:文件、终端、web、memory、skills、delegate_task不含 cronjob、messaging delivery。

审批选项:allow_once / allow_session / allow_always / deny

1
hermes acp --setup-browser --yes   # 可选浏览器工具

English

hermes acp for VS Code, Zed (via ACP Registry + uv), JetBrains. Curated toolset for editor workflows. Configure credentials first with hermes model.


九、轨迹导出与 RL 研究 | Trajectories & RL Research

中文

Hermes 提供 Batch Runner、ShareGPT 轨迹导出、Atropos RL 集成与断点续跑,面向工具调用模型微调。OpenClaw 会话存于 sessions/*.jsonl,可手动提取但无内置 RL 管线。

English

Hermes: batch runner, ShareGPT export, Atropos RL. OpenClaw: jsonl transcripts only — no built-in RL pipeline.


十、移动端 Nodes(OpenClaw)| iOS/Android Nodes

中文

OpenClaw 通过 Web Control UI 配对 iOS/Android Nodes(Canvas、相机、语音)。Hermes 无原生 Node,以 Telegram/WhatsApp 等消息平台作「口袋助理」;Android 可用 Termux 自托管。需手机硬件深度集成选 OpenClaw Nodes;纯消息 + Cron 选 Hermes Gateway。

English

OpenClaw nodes: canvas, camera, voice via Control UI pairing. Hermes: messaging platforms or Termux on Android — no native mobile SDK.


十一、分离式 Gateway/执行(SSH 模式)| Split Gateway / Execution

中文

高安全生产拓扑:

1
2
3
4
5
┌─────────────────────┐         SSH          ┌─────────────────────┐
│ Gateway VPS │ ──────────────────► │ 执行 VPS │
│ - 仅消息 + 配对 │ terminal.backend │ - Docker 沙箱 │
│ - 无敏感代码仓库 │ : ssh │ - GPU / 大磁盘 │
└─────────────────────┘ └─────────────────────┘

Hermes 配置:

1
2
3
4
5
6
terminal:
backend: ssh
ssh:
host: execution.internal
user: hermes
key_path: ~/.ssh/hermes_exec

OpenClaw:sandbox 配置 + remote node 模式。

English

Split trust: Gateway host for messaging only; execution host via SSH/Docker sandbox. Hermes: terminal.backend: ssh. OpenClaw: sandbox + remote nodes.


十二、运维清单 | Operations Checklist

中文

频率 / 硬化项 Hermes OpenClaw
每日 Gateway 日志 / Cron 输出 Dashboard 会话
每周 hermes doctor、command_allowlist security audit
每月 hermes update、轮换 Key npm 更新、审计 Skills
Allowlist / 配对 平台 allowlist + DM pairing dmPolicy: pairing + dmScope
执行隔离 terminal.backend: docker/ssh sandbox + tools.profile
服务化 hermes gateway install onboard --install-daemon
审计 hermes doctor security audit --deep --fix
插件/供应链 Cron enabled_toolsets plugins.allow + shrinkwrap

English

Routine ops: logs, weekly doctor/audit, monthly updates and key rotation. Production: allowlists, pairing, sandboxed execution, gateway services, and supply-chain checks for both frameworks.


十三、故障排查 | Troubleshooting

中文

问题 Hermes 解决 OpenClaw 解决
hermes: command not found source ~/.bashrc;检查 ~/.local/bin 检查 npm global bin PATH
API key 未设置 hermes modelhermes setup --portal onboard 向导
Gateway 不响应 hermes gateway stop && start;查 PID 重启 daemon;查 18789
Telegram 无回复 检查 allowlist / pairing dmPolicy、bot token
配置迁移失败 hermes config checkmigrate 手动合并 openclaw.json
模块导入错误 用 venv 的 hermes,非系统 Python 重装 npm 包
Cron 不触发 hermes gateway 必须运行;cron status Gateway cron 配置
浏览器工具失败 hermes acp --setup-browser Playwright 依赖
供应链告警 hermes doctor --ack security audit

English

Common fixes: PATH for hermes, credentials via hermes model/setup --portal, gateway restart, pairing/allowlists for Telegram, config migrate for Hermes, security audit for OpenClaw. Run hermes doctor / hermes status or openclaw security audit --deep for guided diagnosis.


十四、快速命令对照 | Quick Command Reference

操作 OpenClaw(龙虾) Hermes Agent
安装 npm install -g openclaw@latest curl -fsSL .../install.sh | bash
初始化 openclaw onboard --install-daemon hermes setup / setup --portal
控制 UI openclaw dashboard CLI TUI + 各平台聊天
启动 Gateway daemon 自动 hermes gateway start
系统服务 onboard --install-daemon hermes gateway install
换模型 Runtime 配置 hermes model / /model
安全审计 openclaw security audit hermes doctor
从对方迁移 hermes claw migrate
IDE 集成 外部 Runtime hermes acp
MCP 桥接 hermes mcp serve
更新 npm update -g openclaw hermes update

十五、延伸阅读 | Further Reading


十六、结语 | Conclusion

中文

部署个人 Agent 的「最快路径」是:Hermes 用 curl + setup --portal + Telegram;OpenClaw 用 npm + onboard + Dashboard。生产环境无论选型,都应完成 配对/allowlist、执行沙箱、诊断审计、Gateway 系统服务 四件事。已有龙虾用户可通过 hermes claw migrate 平滑叠加学习闭环;高安全场景采用 SSH 分离 Gateway/执行。运维不是一次性安装 — hermes doctoropenclaw security audit 应纳入日常节奏。

English

Fastest paths: Hermes curl + setup --portal + Telegram; OpenClaw npm + onboard + Dashboard. Production requires pairing/allowlists, execution sandboxing, diagnostics, and gateway services. Migrate from OpenClaw with hermes claw migrate. Split gateway/execution via SSH for high security. Treat hermes doctor and security audit as routine ops, not one-time setup.

Agent Hermes 与 OpenClaw 插件体系与 MCP 生态全解析

Plugin Systems & MCP Ecosystem in Agent Hermes & OpenClaw

最后更新 | Last updated: 2026-06-06


一、扩展哲学对比 | Extension Philosophy Comparison

中文

两个框架都将「核心 Agent 引擎」与「可插拔能力」分离,但扩展面不同:

维度 OpenClaw(龙虾) Hermes Agent
第一层扩展 Workspace Markdown(SOUL/AGENTS) Context files + SOUL.md
第二层扩展 Skills(SKILL.md) Skills + 自动生成
第三层扩展 进程内插件 + Channel 插件 Python 插件系统 + pip 分发
外部工具协议 主要靠 Skills / 内置工具 MCP 客户端 + 服务端 一等公民
默认姿态 插件在 Gateway 进程内 = 可信代码 通用插件默认 opt-inplugins.enabled
供应链 npm shrinkwrap 锁定发布依赖 Tirith + Skills Guard + 懒安装隔离

English

Both separate core engines from pluggable capabilities. OpenClaw extends via workspace files, skills, and in-process Gateway plugins plus channel plugins. Hermes adds a Python plugin system with opt-in general plugins, pip distribution, and first-class bidirectional MCP. OpenClaw treats in-process plugins as trusted; Hermes gates arbitrary user plugins behind plugins.enabled.


二、Hermes 插件发现体系 | Hermes Plugin Discovery

中文

flowchart TB
    subgraph Sources["发现来源(后者覆盖同名前者)"]
        B[bundled plugins/]
        U[~/.hermes/plugins/]
        P[.hermes/plugins/ 项目级]
        PI[pip entry_points]
        N[Nix extraPlugins]
    end
    subgraph Categories["子类别路由"]
        G[通用 plugins/ — tools/hooks/commands]
        PL[platforms/ — Gateway 渠道]
        IG[image_gen/ — 图像后端]
        MEM[memory/ — 记忆 Provider]
        CE[context_engine/ — 压缩引擎]
        MP[model-providers/ — 推理后端]
    end
    Sources --> PM[PluginManager]
    PM --> Categories

2.1 发现来源

来源 路径 用例
Bundled 仓库 plugins/ 随 Hermes 发布(IRC、Teams 等)
User ~/.hermes/plugins/ 个人定制工具/钩子
Project ./.hermes/plugins/ 项目专属(需 HERMES_ENABLE_PROJECT_PLUGINS=true
pip hermes_agent.plugins entry_points 团队 pip 包分发
Nix extraPlugins / extraPythonPackages 声明式部署

同名碰撞时 后加载者覆盖 — 用户插件可替换内置同名 Provider。

2.2 插件类型

类型 选择方式 位置
通用插件 多选 plugins.enabled plugins/
Memory Provider 单选 memory.provider plugins/memory/
Context Engine 单选 context.engine plugins/context_engine/
Model Provider 多注册,用户择一 plugins/model-providers/
Platform 插件 bundled 自动加载;用户平台需 enabled plugins/platforms/

English

Discovery order: bundled → user → project (opt-in) → pip → Nix. Subdirectories route to specialized loaders (memory, context engine, model providers, platforms). Later sources override same-name plugins.

2.3 Opt-in 安全模型(plugins.enabled)

1
2
3
4
5
6
plugins:
enabled:
- my-tool-plugin
- disk-cleanup
disabled:
- noisy-plugin
1
2
3
4
hermes plugins                    # 交互式 SPACE 切换
hermes plugins enable my-plugin
hermes plugins disable my-plugin
hermes plugins install user/repo --enable # 安装并启用

不经过 allowlist 的类别(内置基础设施):

种类 激活方式
Bundled 平台插件(IRC、Teams) gateway.platforms.*.enabled
Bundled 图像后端 image_gen.provider
Memory / Context / Model Provider 各自 config.yaml 单选

第三方 ~/.hermes/plugins/platforms/ 必须 opt-in。

English

General plugins require explicit plugins.enabled. Bundled platforms/backends and provider plugins bypass the allowlist by design. Third-party platform adapters need opt-in.

2.4 插件能力一览

能力 API
注册工具 ctx.register_tool()
生命周期钩子 ctx.register_hook("post_tool_call", ...)
斜杠命令 ctx.register_command()
CLI 子命令 ctx.register_cli_command()
捆绑 Skill ctx.register_skill()plugin:skill
注册 Gateway 平台 ctx.register_platform()
注册推理 Provider register_provider(ProviderProfile(...))
借用用户 LLM ctx.llm.complete()

2.5 Memory Provider 插件

8 种外部记忆后端(Honcho、Mem0、Hindsight、OpenViking 等)通过 plugins/memory/ 发现:

1
2
memory:
provider: "honcho" # 空字符串 = 仅内置 MEMORY.md/USER.md

独占模式 — 同时仅一个 active Provider。详见 记忆系统

2.6 Context Engine 插件

1
2
3
context:
engine: "compressor" # 默认内置 ContextCompressor
engine: "lcm" # 插件:无损上下文

用户必须显式设置 — 插件引擎不会自动激活。

English

Plugins can register tools, hooks, commands, skills, platforms, providers, and context engines. Memory and context engines are single-select via config.


三、OpenClaw 插件体系 | OpenClaw Plugin System

中文

3.1 进程内插件

OpenClaw 插件在 Gateway 同一 Node.js 进程内运行 — 与 Gateway 共享内存与凭证,视为可信代码

1
2
3
4
5
6
7
8
{
plugins: {
allow: ["matrix-channel", "nostr-bridge"], // 显式白名单(推荐)
},
security: {
installPolicy: "allowlist", // 或相关安装策略
},
}
控制 说明
plugins.allow 仅加载列出的插件
security.installPolicy 限制插件安装来源
openclaw security audit --deep 扫描已装 Skills/插件

3.2 Channel 插件

内置渠道:WhatsApp、Telegram、Discord、Slack、Signal、iMessage 等。

插件渠道:Matrix、Nostr、Twitch、Zalo、Feishu 等通过 bundled 或 external channel plugins 扩展。

flowchart LR
    GW[Gateway :18789] --> BC[内置渠道]
    GW --> CP[Channel Plugins]
    CP --> MX[Matrix]
    CP --> NO[Nostr]
    CP --> TW[Twitch]

3.3 插件 Skills 分发

OpenClaw Skills 以 skills/*/SKILL.md 存在于 workspace,社区通过 ClawHub 等市场分发。插件可附带 Skills 目录 — Skills 与插件 plugins.allow 独立,但同样应限制写入权限。

3.4 npm Shrinkwrap 供应链

发布包使用 npm-shrinkwrap.json 锁定依赖图,配合 openclaw security audit 检测已知妥协版本。对比 Hermes 的 hermes doctor 供应链告警。

English

OpenClaw plugins run in-process — trusted code. Use plugins.allow allowlists and security.installPolicy. Channel plugins extend connectivity. Published deps locked via npm-shrinkwrap; audit via openclaw security audit --deep.


四、MCP:Hermes 作为客户端 | MCP: Hermes as Client

中文

Model Context Protocol 让 Hermes 连接外部工具服务器(GitHub、Linear、数据库、文件系统等),无需为每个集成编写原生工具。

4.1 配置形态

Stdio 本地子进程:

1
2
3
4
5
6
mcp_servers:
filesystem:
command: "npx"
args: ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
env:
GITHUB_PERSONAL_ACCESS_TOKEN: "***"

HTTP 远程端点:

1
2
3
4
mcp_servers:
linear:
url: "https://mcp.linear.app/mcp"
auth: oauth

4.2 工具注册命名

1
mcp_<server_name>_<tool_name>
MCP 工具 注册名
filesystem.read_file mcp_filesystem_read_file
github.create-issue mcp_github_create_issue

每个有工具的服务器还创建 runtime toolset:mcp-<server>

4.3 凭证过滤(Credential Filtering)

Stdio MCP 子进程 继承完整 shell 环境:

  • 仅传递配置中显式 env + 安全基线
  • 降低意外泄漏 OPENROUTER_API_KEY 等的风险
  • 对比 OpenClaw 进程内插件可访问 Gateway 级凭证

English

Hermes connects to MCP servers via stdio or HTTP. Tools register as mcp_<server>_<tool>. Stdio servers get filtered env — not the full shell — reducing credential leakage.

4.4 per-server 工具过滤

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mcp_servers:
github:
command: "npx"
args: ["-y", "@modelcontextprotocol/server-github"]
tools:
include: [create_issue, list_issues]
prompts: false
resources: false
stripe:
url: "https://mcp.stripe.com"
tools:
exclude: [delete_customer]
legacy:
url: "https://mcp.legacy.internal"
enabled: false
规则 行为
enabled: false 跳过连接
include 白名单
exclude 黑名单
同时存在 include 优先
prompts/resources: false 禁用 utility 包装器

4.5 目录与 reload-mcp

1
2
3
hermes mcp                  # 交互式目录安装
hermes mcp install n8n # 安装 Nous 审核条目
hermes mcp configure linear # 重新选择工具 checklist

运行中修改配置:

1
/reload-mcp

服务器也可推送 notifications/tools/list_changed 动态刷新工具列表。

4.6 MCP 目录信任模型

optional-mcps/ 条目经 PR 审核合并。安装会执行 manifest 中的 bootstrapgit clonepip installnpm install 等)— 安装前阅读 manifest 的 source:install.bootstrap:

English

Per-server tool filtering via include/exclude. Catalog entries are PR-gated under optional-mcps/. Use /reload-mcp after config changes; servers can push dynamic tool list updates.

4.7 MCP Sampling

MCP 服务器可通过 sampling/createMessage 请求 Hermes 代为推理 — 对不信任服务器设 sampling.enabled: false,并配置 max_rpm / max_tokens_cap 限流。

English

MCP sampling lets servers request LLM inference — disable for untrusted servers; rate limits apply.


五、MCP:Hermes 作为服务端 | MCP: Hermes as Server

中文

hermes mcp serve 将 Hermes 暴露为 MCP 服务器,供 Cursor、Claude Code、VS Code 等客户端调用 消息能力

1
2
3
4
5
6
7
8
{
"mcpServers": {
"hermes": {
"command": "hermes",
"args": ["mcp", "serve"]
}
}
}
工具 功能
conversations_list 列出活跃会话
messages_read 读取消息历史
messages_send 向 telegram:xxx / discord:#channel 发消息
events_poll / events_wait 近实时事件
permissions_respond 审批危险命令

读操作 无需 Gateway 运行;发消息 需要 Gateway 平台适配器在线。

这与 OpenClaw 通过 Gateway WebSocket 统一渠道不同 — Hermes 选择 stdio MCP 桥接 嵌入外部编码 Agent 工作流。

English

hermes mcp serve exposes messaging tools to MCP clients (Cursor, Claude Code). Reads work without gateway; sends require active platform adapters. Bridges external coding agents to Hermes channels.


六、ACP 与 MCP 的关系 | ACP vs MCP

中文

协议 角色 典型编辑器
ACP Hermes 作为 Agent 服务端,编辑器渲染工具/审批/差异 VS Code、Zed、JetBrains
MCP Hermes 作为工具服务端(消息)或工具客户端(GitHub 等) Cursor、Claude Desktop
1
2
3
hermes acp              # 编辑器原生 Agent 体验
hermes mcp serve # 消息桥 MCP 服务
# config.yaml mcp_servers — 扩展 Hermes 工具面

ACP 使用精选 hermes-acp toolset(含 delegate_task),排除 cronjob、messaging delivery 等不适合编辑器 UX 的工具。

English

ACP: Hermes as agent server for IDE UX. MCP: Hermes as messaging bridge (server) or external tool consumer (client). Complementary, not interchangeable.


七、对比矩阵 | Comparison Matrix

中文

能力 OpenClaw Hermes
插件运行时 Gateway 进程内 Node.js Python PluginManager
默认加载 plugins.allow 白名单 通用插件 opt-in plugins.enabled
渠道扩展 Channel Plugins Platform 插件 + 20 内置 Adapter
外部工具协议 主要靠 Skills/内置 MCP 客户端一等公民
对外暴露消息 Gateway WebSocket / Control UI hermes mcp serve
IDE 集成 外部 Runtime 生态 ACP + MCP 双路径
记忆插件 Workspace 文件 plugins/memory/ Provider
上下文引擎 无内置可插拔 plugins/context_engine/
推理 Provider 插件 绑定 Runtime plugins/model-providers/ 18+
供应链审计 shrinkwrap + security audit Tirith + hermes doctor
Skills 随插件分发 社区 + workspace ctx.register_skill()
项目级插件 workspace skills .hermes/plugins/(默认关闭)

English

Matrix: OpenClaw in-process trusted plugins with channel extensions; Hermes opt-in Python plugins with MCP client/server, ACP IDE path, and specialized provider/memory/context plugin loaders.


八、安全最佳实践 | Security Best Practices

中文

OpenClaw

  1. plugins.allow 显式白名单 — 不用则等于加载全部发现项
  2. openclaw security audit --deep 定期扫描
  3. Skills 目录 chmod 限制写入
  4. 不信任来源的 channel plugin 不安装
  5. 验证 npm shrinkwrap 完整性

Hermes

  1. hermes plugins enable 审查过的通用插件
  2. 项目插件保持 HERMES_ENABLE_PROJECT_PLUGINS=false 除非信任仓库
  3. MCP tools.include 最小暴露面
  4. 不信任 MCP 服务器禁用 sampling
  5. Stdio MCP 的 env 仅填必要变量
  6. hermes doctor 检查供应链告警
  7. hermes mcp 目录安装前阅读 manifest

English

OpenClaw: plugins.allow, security audit, lock down skills dirs. Hermes: opt-in plugins, minimal MCP tool exposure, disable sampling for untrusted servers, filtered stdio env, hermes doctor.


九、典型集成场景 | Typical Integration Scenarios

中文

场景 推荐路径
GitHub PR 管理 Hermes mcp_servers.github + include 白名单
Linear 工单 目录 hermes mcp install linear + OAuth
团队自定义 CLI 工具 Hermes ~/.hermes/plugins/
Matrix 聊天渠道 OpenClaw channel plugin 或 Hermes bundled platform
Cursor 发 Telegram hermes mcp serve
VS Code 编码 Agent hermes acp
Honcho 用户建模 Hermes memory.provider: honcho
无损长上下文 Hermes context.engine: lcm 插件

English

Scenarios: GitHub/Linear via MCP, custom tools via Hermes plugins, Matrix via channel plugins, Cursor→Telegram via mcp serve, VS Code via ACP, Honcho via memory provider.


十、故障排查 | Troubleshooting

中文

症状 Hermes 排查 OpenClaw 排查
插件未加载 hermes plugins list 检查 enabled 检查 plugins.allow
MCP 工具缺失 /reload-mcp、检查 filter N/A
MCP OAuth 失败 hermes mcp login <name> 独立终端 N/A
渠道未连接 gateway.platforms.*.enabled channel 配置 + plugin
供应链告警 hermes doctor --ack security audit --fix

English

Hermes: check plugins.enabled, /reload-mcp, hermes mcp login. OpenClaw: check plugins.allow, channel config, security audit.


十一、延伸阅读 | Further Reading


十二、结语 | Conclusion

中文

OpenClaw 的扩展栈是 Workspace + Skills + 进程内 Channel 插件,优势在渠道广度与社区生态,安全关键是 plugins.allow 与 shrinkwrap 供应链。Hermes 的扩展栈是 分层 Python 插件(工具/记忆/上下文/Provider)+ 双向 MCP + ACP,优势在可组合的外部工具生态与 opt-in 默认姿态。实践中常组合使用:Hermes mcp_servers 接 GitHub/Linear,OpenClaw channel plugin 接 Matrix,Cursor 通过 hermes mcp serve 桥接消息 — 插件与 MCP 不是二选一,而是分层装配能力边界

English

OpenClaw extends via workspace, skills, and in-process channel plugins — maximize connectivity with plugins.allow and supply-chain audits. Hermes extends via layered Python plugins and bidirectional MCP/ACP — compose external tools with opt-in safety. In practice, combine MCP servers for SaaS integrations, channel plugins for niche protocols, and hermes mcp serve to bridge coding agents to messaging — plugins and MCP are layers, not either/or.

Agent Hermes 与 OpenClaw 多 Agent 路由与子代理委派全解析

Multi-Agent Routing & Sub-Agent Delegation in Agent Hermes & OpenClaw

最后更新 | Last updated: 2026-06-06


一、为什么需要多 Agent | Why Multi-Agent?

中文

单一 Gateway 往往要同时服务:

  • 个人 vs 工作人格
  • 不同聊天渠道(Telegram 私聊 vs 工作群)
  • 并行子任务(研究 A/B/C 同时进行)
  • 团队共享 Bot vs 个人助理

两个框架都支持「一个控制平面、多个 Agent 脑」,但路由机制与委派模型不同:

维度 OpenClaw(龙虾) Hermes Agent
路由键 sessionKey + bindings agent:main:platform:chat_type:chat_id
多脑配置 agents.list[] + 独立 workspace hermes -p <profile> 完整隔离
子代理工具 sessions_spawn / sessions_send delegate_task
子代理上下文 精简 bootstrap(目标 workspace) goal + context,零对话历史
跨会话风险 高(控制面工具) 中(委派同步、可取消)

English

A single Gateway often serves multiple personas, channels, parallel workstreams, or team vs personal bots. Both frameworks support multiple agent brains on one control plane, but routing and delegation differ: OpenClaw uses sessionKey + bindings + sessions_spawn; Hermes uses structured session keys, profiles, and delegate_task.


二、OpenClaw 多 Agent 路由 | OpenClaw Multi-Agent Routing

中文

2.1 核心概念

flowchart TB
    subgraph Inbound["入站消息"]
        WA[WhatsApp personal]
        WB[WhatsApp biz]
        TG[Telegram DM]
    end
    subgraph GW["OpenClaw Gateway :18789"]
        BIND[bindings 确定性匹配]
        ROUTE[sessionKey 路由]
    end
    subgraph Agents["agents.list"]
        A1[main — workspace-personal]
        A2[work — workspace-work]
        A3[family — workspace-family]
    end
    WA --> BIND
    WB --> BIND
    TG --> BIND
    BIND --> ROUTE
    ROUTE --> A1 & A2 & A3

每个 Agent 是完整信任边界:

资源 隔离路径
工作区 agents.list[].workspace → SOUL/AGENTS/MEMORY/skills
状态目录 ~/.openclaw/agents/<agentId>/agent
会话存储 ~/.openclaw/agents/<agentId>/sessions/*.jsonl
认证配置 per-agent auth profiles(不共享

2.2 agents.list 与 bindings

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
agents: {
list: [
{
id: "main",
name: "Personal",
workspace: "~/.openclaw/workspace",
tools: {
allow: ["group:fs", "group:sessions", "agents_list"],
},
subagents: {
allowAgents: ["coder", "research"], // sessions_spawn 目标白名单
},
},
{
id: "coder",
workspace: "~/.openclaw/workspace-coder",
sandbox: { mode: "all", scope: "agent" },
tools: {
deny: ["gateway", "cron", "sessions_spawn"],
},
},
],
},
bindings: [
{
agentId: "main",
match: { channel: "whatsapp", accountId: "personal" },
},
{
agentId: "main",
match: {
channel: "whatsapp",
peer: { kind: "group", id: "120363999999999@g.us" },
},
},
],
}

路由规则:bindings 按 (channel, accountId, peer, guild/team) 确定性匹配,最具体规则优先

2.3 session.dmScope 与 DM 隔离

行为
per-channel-peer 每个发送者独立 DM 会话(多用户收件箱推荐
per-account-channel-peer 多账号渠道下按账号+发送者隔离
1
2
3
4
5
6
{
session: { dmScope: "per-channel-peer" },
channels: {
whatsapp: { dmPolicy: "pairing" },
},
}

sessionKey路由选择器,不是认证令牌。与 dmPolicy: pairing 组合可硬化多用户场景。

English

OpenClaw routes via agents.list (full per-agent workspace, state, sessions, auth) and deterministic bindings. Each agent is an isolated trust boundary. session.dmScope controls DM isolation; sessionKey routes sessions but does not authenticate users.

2.4 sessions_spawn 与 sessions_send

sessions_spawn — 启动后台子代理:

1
2
3
4
5
6
- 会话键:agent:<agentId>:subagent:<uuid>
- deliver: false(结果以内部事件回传)
- 完成后 announce 到请求者聊天渠道
- 默认 maxConcurrent: 8
- 可继承或覆盖 model/thinking
- 默认 maxSpawnDepth: 1(子代理不能再 spawn)

sessions_send — 向另一会话发送消息(跨会话操作,高风险)。

深度 sessionKey 形态 角色 能否 spawn
0 agent:<id>:main 主代理 始终可以
1 agent:<id>:subagent:<uuid> 子代理 / 编排者 仅当 maxSpawnDepth >= 2
2 agent:<id>:subagent:<uuid>:subagent:<uuid> 叶子 worker 永远不能

编排者模式maxSpawnDepth: 2):

1
Main → Orchestrator sub-agent → Worker sub-sub-agents

深度 1 编排者保留 sessions_spawnsubagentssessions_list;深度 2 worker session 工具。

2.5 子代理精简 Bootstrap

子代理从目标 Agent 的 workspace 加载 bootstrap 文件(AGENTS.mdTOOLS.md 等),但 不继承 主会话完整历史。可选 cwd 指定子任务工作目录。

这与 Hermes delegate_task「仅 goal+context」哲学类似,但 OpenClaw 仍注入 workspace 级人格与工具指南。

2.6 allowAgents 门禁(常见踩坑)

sessions_spawn 有两层门禁:

  1. 工具 allowlist — 必须包含 sessions_spawn(或 group:sessions
  2. 跨 Agent spawn — 调用方 agents.list[].subagents.allowAgents 必须列出目标 agentId
1
2
3
4
5
6
// 正确:allowAgents 与 tools 同级,不在 tools 下
{
id: "main",
tools: { allow: ["group:sessions", "agents_list"] },
subagents: { allowAgents: ["finance"] }, // 或 ["*"]
}

agents_list 工具验证可 spawn 的目标列表。

English

sessions_spawn starts background sub-agents with reduced bootstrap from the target workspace. Cross-agent spawning requires subagents.allowAgents on the caller — separate from tools.allow. sessions_send is a high-risk cross-session primitive; deny by default on untrusted surfaces.

2.7 团队 vs 个人 Agent 模式

模式 配置要点
个人多人格 多 workspace + bindings 按 accountId/peer
团队共享 Bot dmScope: per-channel-peer + dmPolicy: pairing + 收紧 tools
编排者-专家 main 绑定全渠道,allowAgents 指向 sandboxed 专家 Agent
agentToAgent tools.agentToAgent.enabled + allow: [ids]

硬化基线应对不可信面 deny:gatewaycronsessions_spawnsessions_send

English

Patterns: personal multi-persona via bindings, team bots with per-channel-peer + pairing, orchestrator-specialist with sandboxed worker agents. Harden untrusted surfaces by denying control-plane tools.


三、Hermes 多 Agent 与 Profile 隔离 | Hermes Multi-Agent & Profile Isolation

中文

3.1 Session Key 格式

1
agent:main:{platform}:{chat_type}:{chat_id}

示例:agent:main:telegram:private:123456789

组成部分 说明
agent:main 主 Agent 实例(未来可扩展多 agent id)
platform telegram / discord / slack / cli 等
chat_type private / group / channel
chat_id 平台原生 ID;线程型平台含 thread ID

禁止手动拼接 — 使用 build_session_key()。详见 Gateway 架构

3.2 Profile 隔离(hermes -p)

1
2
hermes -p work gateway start
hermes -p personal chat

每个 Profile 拥有独立:

资源 路径
HERMES_HOME ~/.hermes-profiles/<name>/ 或自定义
config.yaml / .env Profile 作用域
state.db 会话 Profile 作用域
Gateway PID Profile 作用域
Bot Token 锁 acquire_scoped_lock() 防多 Profile 抢同一 Token

团队 vs 个人:团队 Bot 用 work Profile + 平台 allowlist;个人进化用 default Profile + 学习闭环。

English

Hermes session keys follow agent:main:{platform}:{chat_type}:{chat_id}. Profiles (hermes -p <name>) fully isolate config, sessions, gateway, and token locks — the primary multi-agent pattern on Hermes.

3.3 跨会话镜像与投递

Hermes Gateway 的 delivery.py 支持跨平台投递,但 Cron 投递不镜像进 Gateway 会话历史(避免消息交替违规)。这与 OpenClaw sessions_send 的跨会话写入是不同层面的能力。

English

Cross-platform delivery exists via delivery.py, but cron deliveries are excluded from gateway session history to preserve message ordering invariants.


四、Hermes delegate_task 委派 | Hermes delegate_task Delegation

中文

4.1 设计理念

flowchart LR
    PARENT[父 AIAgent] -->|delegate_task| C1[子代理 1]
    PARENT -->|delegate_task| C2[子代理 2]
    PARENT -->|delegate_task| C3[子代理 3]
    C1 --> S1[摘要回注]
    C2 --> S2[摘要回注]
    C3 --> S3[摘要回注]
    S1 & S2 & S3 --> PARENT
  • 每个子代理:独立会话、独立终端、可选独立 toolsets
  • 中间工具调用 不进入 父上下文 — 仅最终摘要返回
  • 同步执行于父轮次内;父中断则子任务取消
1
2
3
4
5
6
7
8
9
10
11
12
delegate_task(tasks=[
{
"goal": "Research WebAssembly edge deployments",
"context": "Focus on Wasmtime, Wasmer, WASI 2025 progress",
"toolsets": ["web"],
},
{
"goal": "Review src/auth/ for security issues",
"context": "Project at /home/user/app. Run: pytest tests/auth/ -v",
"toolsets": ["terminal", "file"],
},
])

4.2 与 sessions_spawn 对比

维度 OpenClaw sessions_spawn Hermes delegate_task
执行模型 后台非阻塞,announce 回聊天 父轮次内同步等待摘要
上下文 workspace bootstrap + 可选 cwd 仅 goal + context 字符串
会话键 agent:id:subagent:uuid 内部子会话,不暴露给用户
嵌套 maxSpawnDepth 2 编排者模式 role=orchestrator + max_spawn_depth
持久性 可 auto-archive 60min 父中断即丢弃;用 cron 做持久任务
凭证 per-agent auth 继承父 credential pool
fallback per-agent 配置 继承父 fallback_providers

4.3 隔离子代理(Isolated Subagents)

子代理 不知道 父对话任何内容。「修复我们刚讨论的 bug」会失败 — 必须在 context 中写明路径、错误信息、约束。

应传入 context 不应假设
绝对路径、项目根 父会话中的指代
测试命令、技术栈 用户偏好(除非写入 context)
明确目标与验收标准 父代理已读过的文件内容

4.4 并行工作流(Parallel Workstreams)

1
2
3
4
delegation:
max_concurrent_children: 3 # 默认每批 3 并行,可提高到 30+
max_spawn_depth: 1 # 默认叶子子代理
orchestrator_enabled: true
配置 默认 说明
max_concurrent_children 3 单批 delegate_task 并行上限
max_spawn_depth 1 >1 允许 orchestrator 再委派
orchestrator_enabled true false 全局禁用嵌套

编排者子代理role="orchestrator")可保留 delegate_task;叶子子代理默认 禁止 delegate_taskclarifymemorysend_messageexecute_code

4.5 成本优化:delegation.provider

1
2
3
delegation:
provider: openrouter
model: google/gemini-3-flash-preview

子代理使用廉价模型跑并行研究,父代理用强模型综合 — 常见 质量/成本 平衡点。

English

delegate_task spawns isolated children with separate sessions and toolsets; only summaries return to the parent. Synchronous within the parent turn — interrupted parents cancel children. Pass explicit goal + context; children have zero conversation history. Override delegation.provider/model for cost optimization.

4.6 典型模式速查

模式 工具选择
并行研究 toolsets: ["web"]
代码审查 toolsets: ["terminal", "file"]
多文件重构 多 task 并行,各管不同目录
收集 + 分析 execute_code 机械收集 → delegate_task 推理分析

English

Patterns: parallel research (web), code review (terminal+file), gather-then-analyze (execute_code then delegate_task).


五、风险矩阵 | Risk Matrix

中文

能力 风险 OpenClaw 缓解 Hermes 缓解
sessions_spawn 跨 Agent 越权 spawn allowAgents 白名单 N/A(不同工具)
sessions_send 跨会话注入/泄露 deny + tools.profile 无对等一等工具
delegate_task 父中断丢工作 N/A 用 cron / background terminal
多用户 DM 会话串线 per-channel-peer + pairing 平台 allowlist + pairing
团队 Bot 任意用户触发工具 sandbox + deny 控制面 Docker backend + manual approval
嵌套子代理 资源耗尽 maxChildrenPerAgent max_concurrent_children

English

Risk matrix: cross-agent spawn gates (allowAgents), deny sessions_send on untrusted surfaces, use cron for durable work instead of delegation, isolate DMs with per-channel-peer and pairing.


六、OpenClaw 与 Hermes 选型 | When to Use Which

中文

flowchart TD
    Q[需要多 Agent?] --> OC{要后台长期子任务<br/>+ 聊天 announce?}
    OC -->|是| OC1[OpenClaw sessions_spawn]
    OC -->|否| HM{要并行摘要<br/>+ 父上下文隔离?}
    HM -->|是| HM1[Hermes delegate_task]
    HM -->|否| PR{要完全隔离配置<br/>+ 凭证?}
    PR -->|OpenClaw| OC2[agents.list 多 workspace]
    PR -->|Hermes| HM2[hermes -p profiles]
场景 推荐
WhatsApp 双账号 → 双人格 OpenClaw bindings + agents.list
Telegram 团队 Bot + 个人 CLI Hermes -p work / -p personal
三路并行网络调研 Hermes delegate_task 批量
编码编排者 → 沙箱 worker OpenClaw maxSpawnDepth: 2
跨会话发消息给另一用户 OpenClaw sessions_send(慎用)
IDE 内并行子任务 Hermes ACP 含 delegate_task

English

Use OpenClaw sessions_spawn for background announced sub-runs and multi-workspace routing via bindings. Use Hermes delegate_task for parallel in-turn summaries and hermes -p for full profile isolation.


七、生产配置清单 | Production Checklist

中文

OpenClaw

  • session.dmScope: "per-channel-peer"(多用户)
  • dmPolicy: "pairing"
  • subagents.allowAgents 显式列出可 spawn 目标(避免 ["*"] 除非可信)
  • 不可信面 deny sessions_sendgatewaycron
  • 专家 Agent 启用 sandbox.mode: "all"
  • agents_list 定期审计可 spawn 列表

Hermes

  • 团队 Bot 配置平台 allowlist,禁用 GATEWAY_ALLOW_ALL_USERS
  • 并行委派设置 delegation.max_concurrent_children 防止 API 风暴
  • 子任务用 delegation.provider 指向 Flash 模型
  • 持久任务用 cronjob 而非 delegate_task
  • 多 Profile 时确认 Token 锁无冲突
  • 子代理 context 含绝对路径与验收标准

English

OpenClaw: per-channel-peer, pairing, explicit allowAgents, deny risky tools, sandbox specialists. Hermes: allowlists, cap concurrent children, cheap delegation models, cron for durable work, explicit subagent context.


八、命令对照 | Command Reference

操作 OpenClaw Hermes
列出可 spawn Agent agents_list 工具 N/A
启动子代理 sessions_spawn delegate_task
跨会话消息 sessions_send send_message(不同语义)
多配置隔离 agents.list + workspace hermes -p <profile>
查看子代理状态 subagents 工具 父会话内摘要
会话键 Gateway sessionKey build_session_key()
DM 隔离 session.dmScope 平台 allowlist + pairing

九、延伸阅读 | Further Reading


十、结语 | Conclusion

中文

OpenClaw 的多 Agent 哲学是 bindings 路由多个完整 workspace 脑,用 sessions_spawn 做后台 announce 式子任务,适合「一个 Gateway 服务多渠道、多人格、编排者-专家」拓扑。Hermes 的多 Agent 哲学是 Profile 隔离 + 同步 delegate_task 并行,用极简 context 换父上下文清洁,适合「并行研究/审查 + 强模型综合 + 学习闭环沉淀」。二者可经 hermes claw migrate 迁移人格与技能,但路由与委派语义不可直接互换 — 选型应取决于你需要 后台会话 announce 还是 轮内并行摘要

English

OpenClaw routes multiple full workspace brains via bindings, with background sessions_spawn sub-runs that announce back — ideal for multi-channel, multi-persona, orchestrator-worker topologies. Hermes isolates via profiles and parallel synchronous delegate_task with minimal context — ideal for in-turn research/review with a strong parent synthesizer. Choose based on whether you need background announced sessions or in-turn parallel summaries.

Agent Hermes 与 OpenClaw 模型 Provider 与 Token 成本优化全解析

Model Providers & Token Cost Optimization in Agent Hermes & OpenClaw

最后更新 | Last updated: 2026-06-06


一、成本问题的本质 | The Nature of Agent Cost

中文

个人 AI Agent 的运行成本主要来自三类 Token 消耗:

成本来源 说明 谁更敏感
主模型推理 每轮对话 + 工具循环的输入/输出 Token 两者皆然
系统提示词前缀 SOUL/AGENTS/MEMORY/Skills 索引等静态内容 OpenClaw 全量注入;Hermes 分层控制
辅助模型调用 压缩摘要、视觉、审批评分、网页提取 Hermes 独有,可独立优化

OpenClaw 的模型选择通常绑定在 Gateway 配置或外部 Agent Runtime(Claude Code、Cursor 等),成本优化侧重 工作区文件瘦身工具爆炸半径。Hermes 将 Provider 解析、凭证轮换、fallback、辅助模型、Prompt 缓存、上下文压缩统一纳入 runtime_provider.pyAIAgent 循环——适合需要 模型无关 + 长期无人值守 Cron 的场景。

English

Personal agent costs come from three token buckets:

Source Description Who feels it more
Main model inference Input/output tokens per turn and tool loop Both
System prompt prefix SOUL, AGENTS, MEMORY, skill indexes OpenClaw full injection; Hermes layered control
Auxiliary model calls Compression, vision, approval scoring, web extract Hermes-specific, independently tunable

OpenClaw model choice is typically tied to Gateway config or external runtimes; cost control focuses on workspace slimming and tool blast radius. Hermes unifies provider resolution, credential rotation, fallback, auxiliary models, prompt caching, and context compression in runtime_provider.py and the AIAgent loop — ideal for model-agnostic and unattended cron deployments.


二、Hermes Provider 体系(18+)| Hermes Provider Ecosystem (18+)

中文

Hermes 通过 plugins/model-providers/ 插件注册推理后端,用户插件可覆盖同名内置 Provider。核心解析链:

flowchart LR
    REQ[用户消息 / Cron / ACP] --> RES[runtime_provider.py]
    RES --> POOL[Credential Pool 轮换]
    POOL --> MAIN[主模型 API 调用]
    MAIN -->|失败| FB[fallback_providers]
    MAIN --> AUX[auxiliary.* 侧任务]
    AUX --> COMP[compression / vision / approval]

2.1 主模型槽位(Main Model)

配置位于 ~/.hermes/config.yamlmodel: 段:

1
2
3
4
5
model:
provider: openrouter
default: anthropic/claude-opus-4.7
base_url: ''
api_mode: chat_completions
切换方式 作用域 说明
hermes model 全局默认 交互式选择 Provider + 模型
hermes setup --portal 全局 OAuth 一次覆盖模型 + Tool Gateway
Dashboard Models 页 全局 可视化主模型与 8 个辅助槽位
/model provider:model 当前会话 Gateway/CLI 内热切换
/model ... --global 全局 + 当前会话 等同 Dashboard 的 Change

English

Hermes registers inference backends via plugins/model-providers/; user plugins override bundled ones. Resolution flow: request → runtime_provider.py → credential pool → main API call → optional fallback_providers → auxiliary tasks.

Main model config lives under model: in config.yaml. Switch via hermes model, hermes setup --portal, dashboard, or /model (session-only or --global).

2.2 三种 API 模式(api_mode)

api_mode 适用 Provider 实现路径
chat_completions OpenRouter、大多数 OpenAI 兼容端点 标准 Chat Completions
codex_responses openai-codex OpenAI Responses API 专用路径
anthropic_messages anthropic 原生 agent/anthropic_adapter.py 翻译 Messages API

Fallback 激活时会按目标 Provider 就地切换 api_mode:Codex → codex_responses,Anthropic → anthropic_messages,其余 → chat_completions

English

Three API modes: chat_completions (default), codex_responses (OpenAI Codex), anthropic_messages (native Anthropic). Fallback swaps api_mode in-place when activating a backup provider.

2.3 Nous Portal 与 Tool Gateway

hermes setup --portal 是最低摩擦路径:

  • 300+ 模型 单一 OAuth 订阅
  • Tool Gateway 捆绑:web search、image generation、TTS、cloud browser
  • OAuth 自动刷新,适合 Cron 无人值守
  • Portal 订阅者对按 Token 计费的 Provider 享 10% 折扣
1
2
hermes setup --portal    # 登录 + 设置 Nous Provider + 启用 Tool Gateway
hermes portal info # 查看已接入能力

对比单独配置 OPENROUTER_API_KEY + 各工具 API Key,Portal 显著降低 密钥管理成本辅助服务账单碎片度

English

hermes setup --portal covers 300+ models plus Tool Gateway (search, images, TTS, browser) under one OAuth — ideal for unattended cron with automatic token refresh. Portal subscribers get 10% off token-billed providers.

2.4 OpenRouter 与自定义端点

Hermes 严格隔离 API Key 与 base URL:

  • OPENROUTER_API_KEY 仅发往 openrouter.ai 端点
  • OPENAI_API_KEY 用于自定义 OpenAI 兼容端点及回退
  • provider: custom + custom_providers 列表支持 LM Studio、Together、本地 vLLM 等

避免「配置了 OpenRouter 却把 OpenAI Key 泄漏到自定义 localhost」的常见踩坑。

English

API keys are scoped to their base URLs. OPENROUTER_API_KEY never leaks to custom endpoints; provider: custom supports local and third-party OpenAI-compatible servers.


三、凭证池轮换(Credential Pool)| Credential Pool Rotation

中文

凭证池处理 同 Provider 多 Key 轮换fallback_providers 处理 跨 Provider 故障转移。执行顺序:先池,后 fallback

1
2
3
4
5
请求 → 从池选 Key(fill_first / round_robin / least_used / random)
→ 429?先重试一次,再轮换下一 Key(冷却 1h)
→ 402 账单/配额?立即轮换(冷却 24h)
→ 401?尝试 OAuth 刷新,失败则轮换
→ 池耗尽 → 激活 fallback_providers

3.1 快速配置

1
2
3
hermes auth add openrouter --api-key sk-or-v1-second-key
hermes auth add anthropic --type oauth # Claude Max OAuth
hermes auth list # ← 标记当前选中凭证
1
2
3
credential_pool_strategies:
openrouter: round_robin
anthropic: least_used

3.2 与 Gateway 并发

凭证池使用线程锁保护 select() / mark_exhausted_and_rotate(),多 Telegram/Discord 会话并发时安全。子代理通过 delegate_task _spawn 时 继承父代理凭证池,同 Provider 子任务可共享轮换能力。

English

Credential pools rotate multiple keys for the same provider before cross-provider fallback kicks in. Strategies: fill_first, round_robin, least_used, random. Thread-safe for concurrent gateway sessions; subagents inherit the parent’s pool.


四、主模型 Fallback 链 | Primary Model Fallback Chain

中文

1
2
3
4
5
fallback_providers:
- provider: openrouter
model: anthropic/claude-sonnet-4
- provider: nous
model: nous-hermes-3
特性 行为
触发条件 429/5xx 重试耗尽、401/403/404、畸形响应
作用域 按轮(per-turn) — 每轮新消息先尝试主模型
单轮上限 每轮最多激活 fallback 一次,防止级联循环
会话连续性 历史、工具调用、上下文完整保留
CLI 管理 hermes fallback add/list/remove/clear
sequenceDiagram
    participant U as 用户消息
    participant A as AIAgent
    participant P as 主 Provider
    participant F as fallback_providers
    U->>A: 新轮次开始
    A->>P: 调用主模型
    P-->>A: 429 / 503
    A->>F: _try_activate_fallback()
    F-->>A: 切换 provider+client+api_mode
    A->>F: 继续本轮回话
    Note over A: 下一轮消息重新尝试主模型

4.1 Fallback 覆盖范围

上下文 支持 fallback
CLI / Gateway 会话
Cron 任务 ✔(继承 fallback_providers
子代理 delegate_task ✔(继承父链;可用 delegation.provider 覆盖主模型)
辅助模型任务 ✘(独立 auto-detection 链)

English

fallback_providers is an ordered list tried on primary failure. Per-turn scope: each new user message retries the primary first; at most one fallback activation per turn. Cron and subagents inherit the chain; auxiliary tasks use their own routing.


五、辅助模型与成本杠杆 | Auxiliary Models & Cost Levers

中文

Hermes 将侧任务从主模型剥离,共 8 个辅助槽位

任务 config 键 典型优化
Title Gen auxiliary.title_generation Flash 模型写标题(默认 gemini-flash)
Vision auxiliary.vision 主模型无视觉时指向 gpt-4o-mini / gemini-flash
Compression auxiliary.compression 勿用 Opus 做摘要 — 1/50 成本
Web Extract auxiliary.web_extract 网页摘要用廉价 chat 模型
Approval auxiliary.approval approval_mode: smart 的评分模型
Skills Hub auxiliary.skills_hub 技能搜索,通常 auto 即可
MCP auxiliary.mcp MCP 辅助操作
Triage Specifier auxiliary.triage_specifier Kanban 任务规格化
1
2
3
4
5
6
7
8
9
10
auxiliary:
compression:
provider: openrouter
model: google/gemini-3-flash-preview
approval:
provider: openrouter
model: anthropic/claude-haiku-4-5
title_generation:
provider: openrouter
model: google/gemini-3-flash-preview

provider: auto 表示使用主模型 — 对 Compression / Approval 通常是 浪费

English

Eight auxiliary slots offload side jobs from the main model. Override compression and approval with fast/cheap models — using Opus for summarization wastes reasoning tokens. provider: auto means “use main model.”

5.1 Smart Approval 的辅助 LLM 成本

approval_mode: smart 时,每条待审批命令会调用 auxiliary.approval 做风险分类:

模式 行为 Token 成本
manual(默认) 用户手动审批 无辅助调用
smart 辅助 LLM 评估低/高风险 每条危险模式匹配 + 一次 aux 调用
off YOLO(硬阻断列表仍生效) 无辅助调用

成本建议:将 auxiliary.approval 指向 haiku / flash / gpt-5-mini;切勿用 Opus 做审批评分。容器后端(Docker/Modal)跳过审批检查 — 容器即边界。

English

approval_mode: smart routes each dangerous-command candidate through auxiliary.approval. Point it at haiku/flash/mini models — never Opus. Container backends skip approval checks entirely.

5.2 辅助模型容量错误 Fallback

显式配置 auxiliary.vision.provider: glm 等时,若遇 402/日配额耗尽/连接失败,Hermes 按层回退:

  1. 配置的 aux Provider
  2. auxiliary.*.fallback_chain(可选)
  3. 主代理 Provider + 模型(安全网)
  4. 全部失败 → WARNING 日志 + 抛出原错误

瞬时 429(Retry-After触发此阶梯,尊重显式 Provider 选择。

English

Explicit auxiliary providers fall back through optional fallback_chain, then the main agent model, on capacity errors (402, daily quota, connection failure) — not transient 429s.


六、上下文压缩(ContextCompressor)| Context Compression

中文

Hermes 采用 双层压缩,防止长会话 Token 爆炸:

flowchart TB
    MSG[新消息到达] --> HY[Gateway Session Hygiene 85%]
    HY --> AG[Agent ContextCompressor 50%]
    AG --> P1[Phase1: 剪枝旧 tool 输出]
    P1 --> P2[Phase2: 划定 head/tail 边界]
    P2 --> P3[Phase3: 辅助 LLM 结构化摘要]
    P3 --> P4[Phase4: 重组消息列表]
层级 阈值 位置 目的
Gateway 卫生 85% 上下文 gateway/run.py 隔夜 Telegram 会话安全网
Agent 压缩器 50%(可配) context_compressor.py 主循环精确 Token 管理
1
2
3
4
5
6
7
8
9
10
compression:
enabled: true
threshold: 0.50
target_ratio: 0.20
protect_last_n: 20

auxiliary:
compression:
provider: openrouter
model: google/gemini-3-flash-preview

关键警告:摘要模型的上下文窗口必须 ≥ 主模型。否则中间段无法一次送入摘要 API,压缩退化为 无摘要丢弃 — 最常见的质量劣化原因。

压缩触发 会话分裂parent_session_id 链),详见 记忆系统

English

Dual compression: gateway hygiene at 85% (safety net), agent ContextCompressor at 50% (default). Four phases: prune old tool output, bound head/tail, auxiliary LLM structured summary, reassemble. Summary model context must be ≥ main model or middle turns are dropped without summary.

6.1 可插拔 Context Engine

1
2
3
context:
engine: "compressor" # 默认有损摘要
engine: "lcm" # 插件:无损上下文管理

插件需用户显式设置 context.engine — 默认 "compressor" 始终使用内置实现。

English

Plugins can replace the context engine via context.engine (e.g., lossless lcm). User must opt in explicitly.


七、Anthropic Prompt Caching | Anthropic Prompt Caching

中文

对 Claude 模型,Hermes 自动启用 cache_controlagent/prompt_caching.py),多轮对话输入成本可降约 75%

策略 system_and_3(Anthropic 最多 4 个断点):

1
2
断点 1: 系统提示词(跨轮稳定)
断点 2-4: 倒数第 3/2/1 条非 system 消息(滚动窗口)
设计原则 原因
系统提示词稳定性 保护断点 1 缓存命中
压缩仅首次追加注记 避免 mid-session 突变系统提示
TTL 可选 5m / 1h 长间隔对话用 1h
1
2
prompt_caching:
cache_ttl: "5m"

启用条件:Claude 模型名 + Provider 支持 cache_control(原生 Anthropic 或 OpenRouter)。

English

Anthropic prompt caching via system_and_3 strategy: system prompt plus rolling 3-message window. ~75% input cost reduction on multi-turn Claude conversations. Preserve prompt stability; compression appends a note only on first compaction.


八、Cron 成本治理 | Cron Cost Governance

中文

无人值守 Cron 是 Token 成本 放大器。Hermes 提供多层节制:

机制 作用
enabled_toolsets 单任务仅暴露必要 toolset,缩小 schema prompt
hermes tools → cron 平台 全局 Cron 默认 toolset
no_agent=True 纯脚本,零 LLM Token
wakeAgent: false 预检脚本跳过本轮 Agent
context_from 流水线传递上游输出,避免重复抓取
Provider recovery 凭证池 + fallback_providers 防 Cron 因 429 整体失败
每任务 provider/model 廉价模型跑高频巡检
1
2
3
4
5
6
7
8
cronjob(
action="create",
schedule="every sunday 9am",
enabled_toolsets=["web", "file"], # 不带 terminal/browser/delegation
provider="openrouter",
model="google/gemini-3-flash-preview",
prompt="Summarize this week's AI news...",
)

反面教材:默认携带 moabrowserdelegation 的 Cron 在每次 LLM 调用中注入大量工具 schema — 对小任务极其浪费。

English

Cron amplifies token cost. Control via enabled_toolsets, platform defaults in hermes tools, no_agent script-only jobs, wakeAgent: false gates, per-job cheap models, and inherited fallback/credential pools. Avoid bloated toolsets on simple scheduled tasks.


九、OpenClaw 模型与成本 | OpenClaw Models & Cost

中文

OpenClaw 模型由 Gateway Runtime 或外部编码 Agent(Claude Code、Cursor)配置,无 Hermes 式 18+ Provider 抽象。成本杠杆:工作区瘦身、tools.profile: messaging、子代理 sessions_spawn 隔离长任务、openclaw security audit 收紧工具面。云账单常见 $10–150+/月;Hermes 对辅助模型、压缩、缓存的可编程控制更细。

English

OpenClaw lacks Hermes-style multi-provider runtime. Cost levers: slim workspaces, tight tool profiles, sessions_spawn isolation, security audit. Cloud bills commonly $10–150+/month; Hermes offers finer aux/compression/caching control.


十、模型选择卫生(Hygiene)| Model Selection Hygiene

中文

实践 Hermes OpenClaw
主模型用于推理 ✔ 复杂工具循环 ✔ Agent Runtime
廉价模型用于摘要/标题 auxiliary.* 显式覆盖 依赖外部 Runtime 或手动
视觉任务分离 auxiliary.vision 取决于所选 Runtime
高频 Cron 专用模型 per-job provider/model 按 Agent 配置
避免 mid-session 突变系统提示 设计原则 + 缓存友好 工作区文件顺序注入
监控用量 Dashboard Usage analytics Gateway 日志 + 提供商控制台
凭证轮换 hermes auth 多 Key 按渠道/Provider 手动

English

Hygiene checklist: cheap models for aux tasks, dedicated cron models, stable system prompts for cache hits, credential pools for rate limits, dashboard analytics for monitoring.


十一、成本优化决策树 | Cost Optimization Decision Tree

flowchart TD
    START[账单过高?] --> Q1{主模型是否过强?}
    Q1 -->|是| A1[降级主模型 / 按任务选模型]
    Q1 -->|否| Q2{辅助任务用主模型?}
    Q2 -->|是| A2[配置 auxiliary.compression 等 Flash 模型]
    Q2 -->|否| Q3{Cron 工具过多?}
    Q3 -->|是| A3[enabled_toolsets 精简]
    Q3 -->|否| Q4{长会话上下文膨胀?}
    Q4 -->|是| A4[调低 compression.threshold / 检查摘要模型窗口]
    Q4 -->|否| Q5{Claude 多轮对话?}
    Q5 -->|是| A5[确认 prompt caching 已启用]
    Q5 -->|否| A6[凭证池 + fallback 防失败重试浪费]

十二、配置速查 | Configuration Quick Reference

中文

目标 命令 / 配置
一键 Portal hermes setup --portal
交互选模型 hermes model
管理 fallback hermes fallback
管理凭证池 hermes auth
热切换会话模型 /model provider:model
压缩阈值 compression.threshold
审批智能模式 approval_mode: smart + auxiliary.approval
Cron 工具集 enabled_toolsets / hermes tools
Prompt 缓存 TTL prompt_caching.cache_ttl

English

Quick ref: hermes setup --portal, hermes model, hermes fallback, hermes auth, /model, compression.*, auxiliary.*, enabled_toolsets, prompt_caching.cache_ttl.


十三、延伸阅读 | Further Reading


十四、结语 | Conclusion

中文

Hermes 将 Provider 解析、凭证池、fallback、辅助模型、双层压缩、Anthropic 缓存 串成可配置的成本治理体系;OpenClaw 则通过 工作区瘦身、工具 profile、子代理隔离 控制爆炸半径。实践中的最高 ROI 动作通常是:为 Compression / Title / Approval 配置 Flash 模型、为 Cron 设置 enabled_toolsets、启用凭证池与 fallback 避免失败重试、在 Claude 长会话中依赖 Prompt Caching。模型无关不等于成本无关 — 侧任务与工具 schema 才是隐形大户

English

Hermes offers a configurable cost stack: providers, credential pools, fallback, auxiliary models, dual compression, and Anthropic caching. OpenClaw leans on workspace slimming, tool profiles, and sub-agent isolation. Highest-ROI moves: flash models for aux tasks, enabled_toolsets for cron, pools + fallback for resilience, prompt caching for long Claude sessions. Model-agnostic doesn’t mean cost-agnostic — auxiliary calls and tool schemas are the hidden spend.

Agent Hermes 与 OpenClaw 自动化调度与主动巡检全解析

Agent Hermes & OpenClaw: Automation Scheduling and Proactive Monitoring — A Deep Dive

最后更新 | Last updated: 2026-06-06


一、自动化能力概览 | Automation Capability Overview

中文

个人 Agent 的「主动性」取决于能否在无人值守时执行任务。两个框架提供互补机制:

维度 OpenClaw(龙虾) Hermes Agent
定时调度 cron 工具(Gateway 内) cronjob 工具 + Gateway 调度器
主动巡检 HEARTBEAT.md + heartbeat 周期 Cron + wakeAgent 门控
调度粒度 默认 30m heartbeat 60s scheduler tick
零成本巡检 HEARTBEAT_OK 静默 no_agent + wakeAgent: false
流水线串联 单 Agent 内多任务 context_from 跨任务链
安全 deny cron 给不可信面 Prompt 扫描 + cron 工具禁用

English

Proactivity depends on unattended execution. Both frameworks offer complementary automation:

Dimension OpenClaw (Lobster) Hermes Agent
Scheduling cron tool (in Gateway) cronjob tool + Gateway scheduler
Proactive checks HEARTBEAT.md + heartbeat cadence Cron + wakeAgent gate
Scheduler tick Default 30m heartbeat 60s scheduler tick
Zero-cost checks HEARTBEAT_OK silent ack no_agent + wakeAgent: false
Pipelines Multi-task within one agent context_from cross-job chains
Security deny cron on untrusted surfaces Prompt scan + cron toolset disabled in cron runs

二、Hermes cronjob 工具全解析 | Hermes cronjob Tool Deep Dive

中文

Hermes 将定时任务管理收敛为单一 cronjob 工具(action 风格),CLI、Gateway、自然语言对话共用同一 API。

2.1 支持的操作

Action 作用
create 创建一次性或周期性任务
list 列出所有任务
update 修改 schedule、prompt、skills 等
pause 暂停调度
resume 恢复并计算下次运行时间
run 下次 tick 立即触发
remove 删除任务
1
2
3
4
5
6
7
8
cronjob(
action="create",
name="morning-digest",
schedule="0 9 * * *",
skills=["blogwatcher"],
prompt="Check configured feeds and summarize anything new.",
deliver="telegram",
)

2.2 调度格式

类型 格式 示例
相对延迟(一次性) 30m, 2h, 1d 30 分钟后执行一次
间隔(周期性) every 30m, every 2h 每 2 小时
Cron 表达式 标准 5 段 0 9 * * 1-5 工作日 9:00
自然语言 every day 7am 解析为等效 cron
ISO 时间戳 2026-03-15T09:00:00 指定时刻一次性

重复行为

调度类型 默认 repeat 覆盖
一次性 1
间隔 / cron forever repeat=5 限制次数

2.3 Skill-Backed Cron

任务可附加零个、一个或多个技能,执行时按顺序注入:

1
2
3
4
5
6
7
cronjob(
action="create",
skills=["blogwatcher", "maps"],
prompt="Combine new feed items with nearby events into one brief.",
schedule="every 6h",
name="local-brief",
)

技能内容作为上下文注入,prompt 仅承载任务指令——避免在 cron prompt 中粘贴完整技能正文。

English

Hermes unifies scheduling in the cronjob tool with actions: create, list, update, pause, resume, run, remove. Schedule formats: relative delays, intervals (every N), cron expressions, natural language, ISO timestamps. Attach zero or more skills loaded in order at execution. Prompt carries task instruction only.


三、workdir 与 profile 钉扎 | workdir & profile Pinning

中文

Cron 任务默认脱离任何代码库运行——不加载 AGENTS.md.cursorrules,终端/文件工具使用 Gateway 启动目录。

3.1 workdir 钉扎

1
2
3
4
5
6
cronjob(
action="create",
schedule="every 1d at 09:00",
workdir="/home/me/projects/acme",
prompt="Audit open PRs, summarize CI health, and post to #eng",
)

workdir 设置时:

  • 注入该目录的 AGENTS.md.cursorrules(与交互式 CLI 相同发现顺序)
  • terminalread_filepatchexecute_code 使用该目录为 cwd
  • 路径必须是存在的绝对路径
  • workdir="" 可清除钉扎

序列化约束:带 workdir 的任务在 scheduler tick 上串行执行(进程全局 cwd 状态)。

3.2 profile 钉扎

1
2
3
4
5
6
cronjob(
action="create",
schedule="every 1d at 03:00",
profile="night-ops",
prompt="Tail the security log and flag anomalies",
)

调度器临时切换 HERMES_HOME 到目标 profile,加载其 .env + config.yaml。带 profile 的任务同样串行执行HERMES_HOME 是进程全局状态)。

English

Cron jobs default to detached execution without project context. workdir pins AGENTS.md/.cursorrules injection and tool cwd to an absolute project path — serial execution due to global cwd. profile pins HERMES_HOME/config for the run — also serial due to global profile switch.


四、投递选项与静默模式 | Delivery Options & Silent Mode

中文

4.1 deliver 参数

行为
origin / local 回到来源聊天 / 仅本地 cron/output/
telegram / telegram:ID / telegram:chat:thread Telegram 目标
discord:#channel / slack / whatsapp 各平台 home 或具名频道
all / origin,all 扇出全部 home channel(去重)
telegram,discord 逗号分隔多目标

最终响应自动投递,无需 prompt 内 send_message

4.2 响应包装

默认包装 header/footer 标明来源为定时任务。设 cron.wrap_response: false 可输出原始内容。

4.3 [SILENT] 静默抑制

若 Agent 最终响应以 [SILENT] 开头,抑制外发投递,输出仍保存到 ~/.hermes/cron/output/ 供审计。

1
2
Check if nginx is running. If healthy, respond with only [SILENT].
Otherwise, report the issue.

仅成功运行可静默;失败任务始终投递。

English

deliver routes output to origin, local files, specific platforms, or all fan-out. Final agent response auto-delivers without send_message. [SILENT] prefix suppresses outbound delivery on success while saving locally. Failed jobs always deliver. cron.wrap_response: false removes the wrapper header/footer.


五、no-agent 模式与 wakeAgent 门控 | no-agent Mode & wakeAgent Gate

中文

5.1 no-agent 模式(零 Token 看门狗)

1
2
3
4
5
hermes cron create "every 5m" \
--no-agent \
--script memory-watchdog.sh \
--deliver telegram \
--name "memory-watchdog"
语义 说明
执行 仅运行脚本,不调用 LLM
输出 stdout 原文投递
空 stdout 静默 tick,不投递
非零退出/超时 投递错误告警
脚本位置 必须在 ~/.hermes/scripts/

.sh/.bash/bin/bash;其他用当前 Python 解释器。

5.2 wakeAgent 门控(LLM 任务的 $0 预检)

script= 的 LLM 任务,预检脚本末行可输出 JSON 决定是否唤醒 Agent:

1
{"wakeAgent": false}
1
{"wakeAgent": true, "context": {"new_issues": 3}}
行为 说明
wakeAgent: false 跳过本次 Agent 调用,零 Token
省略或 true 正常唤醒 Agent(默认)
context 字段 注入 Agent 上下文的结构化数据

典型配方

门控类型 场景
文件变更门控 仅当 feed.json mtime > last_run 时唤醒
外部标志门控 CI 部署后 drop /tmp/ready 文件
SQL 计数门控 仅当新行数 > 0 时唤醒,并传递 count
flowchart TD
    T[Scheduler Tick] --> S{有 script?}
    S -->|否| A[直接运行 Agent]
    S -->|是| R[运行预检脚本]
    R --> W{末行 wakeAgent?}
    W -->|false| Z[静默跳过 — $0]
    W -->|true/省略| A
    A --> D[投递结果]

English

no_agent=True: script-only, zero LLM tokens, stdout delivered verbatim, empty stdout = silent tick. wakeAgent gate: pre-check script emits {"wakeAgent": false} on last stdout line to skip the agent call for that tick — useful for 1-5 min polls that only need the LLM when state changed. Optional context object passes structured data to the agent.


六、context_from 流水线 | context_from Pipelines

中文

Cron 任务在隔离会话中运行,无上次执行记忆。context_from 自动将上游任务最近输出前置到当前 prompt:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 阶段 1:采集
cronjob(action="create", name="ai-news-fetch",
schedule="0 7 * * *",
prompt="Fetch top 10 AI stories from HN, save to raw.md")

# 阶段 2:筛选(读取阶段 1 最近输出)
cronjob(action="create", name="ai-news-triage",
schedule="30 7 * * *",
context_from="ai-news-fetch",
prompt="Score each story 1-10, output top 5 to ranked.md")

# 阶段 3:发布
cronjob(action="create", name="ai-news-brief",
schedule="0 8 * * *",
context_from="ai-news-triage",
prompt="Write 3 tweet drafts and deliver to telegram:7976161601")
格式 示例
单任务 ID/名称 context_from="ai-news-fetch"
多任务列表 context_from=["job_a", "job_b"]

输出从 ~/.hermes/cron/output/{job_id}/*.md 读取,按列表顺序拼接。读取最近已完成输出——不等待同 tick 仍在运行的上游任务。

English

context_from prepends upstream jobs’ most recent completed output from ~/.hermes/cron/output/{job_id}/ to the current prompt. Accepts single job ID/name or list for fan-in. Enables collect → filter → deliver pipelines without glue code or databases.


七、Gateway 调度器 internals | Gateway Scheduler Internals

中文

sequenceDiagram
    participant T as 60s Ticker
    participant L as .tick.lock
    participant J as jobs.json
    participant A as AIAgent
    participant D as Delivery
    T->>L: 获取文件锁
    T->>J: 加载任务
    T->>T: 筛选 due jobs (next_run <= now)
    loop 每个 due job
        T->>A: 创建全新会话(无历史)
        opt 附加 skills
        T->>A: 注入 skills + prompt + context_from
        opt script 预检
        T->>A: wakeAgent 门控
        A->>D: 完成 → 投递
        T->>J: 更新 run_count, next_run
    end
    T->>L: 释放锁

存储:jobs.json(原子写)、cron/output/{job_id}/。Gateway 每 60s tick,.tick.lock 防重叠;Cron 会话禁用 cronjob toolset。enabled_toolsets 可 per-job 收紧工具 schema。

English

60s tick, file lock, fresh sessions, cron toolset disabled in cron runs, enabled_toolsets for cost control, fallback provider inheritance.


八、OpenClaw HEARTBEAT 主动巡检 | OpenClaw HEARTBEAT Proactive Monitoring

中文

OpenClaw 的主动性主要通过 Gateway heartbeat 实现——周期性 Agent turn,默认 30 分钟(Anthropic OAuth 检测时为 1 小时)。

8.1 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
heartbeat: {
every: "30m", // "0m" 禁用
target: "last", // "none" | "last" | "slack" | "telegram" ...
activeHours: {
start: "09:00",
end: "22:00",
timezone: "America/New_York",
},
schedule: [ // 可选:时段差异化间隔
{ start: "08:00", end: "18:00", every: "15m" },
{ start: "23:00", end: "08:00", every: "2h" },
],
},
}

8.2 HEARTBEAT.md 清单

工作区中的 HEARTBEAT.md 是巡检 checklist——短小、稳定、适合每 30 分钟考虑:

1
2
3
4
5
# Heartbeat Checklist

- Scan inbox for urgent emails (last 30 min)
- Check calendar for meetings in next 2 hours
- Verify production health endpoint returns 200

tasks: 结构化块(任务级独立间隔):

1
2
3
4
5
6
7
tasks:
- name: inbox-triage
interval: 30m
prompt: Check for urgent emails.
- name: calendar-scan
interval: 2h
prompt: Check for upcoming meetings.
行为 说明
仅 due tasks 进入 prompt 节省 Token
无 due tasks 跳过整个 heartbeat(reason=no-tasks-due
非 task 正文 追加为额外上下文
状态持久化 heartbeatTaskState 存 session state

8.3 HEARTBEAT_OK 静默

一切正常时回复 HEARTBEAT_OK — 静默确认,不外发;有异常才 alert 到 target

English

OpenClaw heartbeat: 30m cadence (1h for Anthropic OAuth), HEARTBEAT.md checklist, optional tasks: per-interval checks, HEARTBEAT_OK silent ack.


九、OpenClaw cron 工具与风险 | OpenClaw cron Tool & Risks

中文

OpenClaw 提供 cron 工具让 Agent 创建持久定时任务——属于高风险控制面工具

风险 说明
持久性 任务存于 Gateway,重启后仍执行
权限扩散 可调度 exec/browser 等危险操作
Prompt 注入 恶意消息诱导创建有害 cron
跨会话 与当前聊天上下文解耦

硬化:tools.deny: ["cron", "gateway", "sessions_spawn"];不可信面必须 deny;openclaw security audit 定期审查。Hermes 对等:Cron 内禁用 cronjob + Prompt 扫描。

English

OpenClaw cron is high-risk persistent scheduling — deny on untrusted surfaces, minimal profiles, security audit. Hermes: cron toolset disabled in cron runs + prompt scanning.


十、安全:Cron Prompt 扫描 | Security: Cron Prompt Scanning

中文

Hermes 在创建/更新时扫描 prompt:注入、凭证外泄、不可见 Unicode、SSH 后门等——阻断则拒绝创建并返回明确错误。运行时:cron_mode: deny(无人值守推荐)、enabled_toolsets 限制、脚本限于 ~/.hermes/scripts/script_timeout_seconds 默认 120s。

English

Create/update prompt scanning blocks injection and exfiltration. Runtime: cron_mode: deny, limited toolsets, script sandbox, configurable timeout.


十一、选型速查 | Selection Quick Reference

场景 OpenClaw Hermes
30m 收件箱/日历巡检 HEARTBEAT.md cron + wakeAgent
每日定时简报 cron 工具 cronjob + deliver
多阶段流水线 单 Agent 内编排 context_from 链
零 Token 看门狗 no_agent
不可信面 deny cron deny cronjob + Prompt 扫描

十二、最佳实践与命令速查 | Best Practices & Quick Commands

中文

Hermes Cron

  1. 自包含 prompt:Cron 会话无历史,须写清一切必要细节
  2. 技能而非长 prompt:复用工作流用 skills=[...] 附加
  3. 收敛 toolsetsenabled_toolsets=["web","file"] 控制成本
  4. 健康检查用 [SILENT]:正常时静默,异常才打扰
  5. 流水线用 context_from:避免硬编码文件路径在 prompt 中
  6. 生产用 Nous Portal OAuth:无人值守避免 API key 过期
操作 命令
添加 /cron add 30m "..." 或自然语言描述
列表 /cron list / hermes cron list
暂停/恢复 /cron pause|resume <id>
手动触发 /cron run <id> / hermes cron tick
安装调度 hermes gateway install

OpenClaw Heartbeat

  1. 保持 HEARTBEAT.md 短小:<20 行 checklist
  2. tasks: 分间隔:不同检查项用不同 interval
  3. activeHours 限制:避免深夜无意义 Token 消耗
  4. target: “last”:有异常时发到最近活跃渠道
  5. deny cron 给聊天 Agent:heartbeat 与 cron 职责分离

English

Hermes: self-contained prompts, skills attachment, limited toolsets, [SILENT] health checks, context_from pipelines, Nous Portal OAuth. Commands: /cron add|list|pause|resume|run, hermes gateway install.

OpenClaw: short HEARTBEAT.md, per-task intervals, activeHours, target last channel, deny cron on chat agents.


十三、延伸阅读 | Further Reading


十四、结语 | Conclusion

中文

自动化调度与主动巡检让个人 Agent 从「被动应答」进化为「持续值守」。OpenClaw 以 HEARTBEAT.md + 30 分钟 heartbeat + HEARTBEAT_OK 静默 提供轻量、内置的主动性,适合多渠道助理的日常巡检。Hermes 以 60 秒调度器、cronjob 统一 API、context_from 流水线、no-agent 零 Token 看门狗和 wakeAgent 门控 提供工业级无人值守能力,适合复杂流水线和成本敏感的高频轮询。安全配置的核心原则一致:不可信面 deny 调度工具,自包含 prompt,最小 toolset,失败必告警

English

Automation and proactive monitoring evolve personal agents from reactive to always-on. OpenClaw offers lightweight proactivity via HEARTBEAT.md, 30m heartbeat, and HEARTBEAT_OK silent ack — ideal for multi-channel daily checks. Hermes offers industrial unattended capability via 60s scheduler, unified cronjob API, context_from pipelines, no-agent zero-token watchdogs, and wakeAgent gates — ideal for complex pipelines and cost-sensitive frequent polling. Shared security principle: deny scheduling tools on untrusted surfaces, self-contained prompts, minimal toolsets, and fail-loud on errors.

0%