仅脚本的 Cron 任务
有时你已经确切知道想要发送的消息内容。你不需要代理(agent)来进行推理——你只需要一个按定时器运行的脚本,并将其输出(如果有)发送到 Telegram / Discord / Slack / Signal。
Hermes 将此称为无代理模式(no-agent mode)。它是去除了大语言模型(LLM)的 cron 系统。
┌──────────────────┐ ┌──────────────────┐
│ scheduler tick │ every │ run script │
│ (every N minutes)│ ──────▶ │ (bash or python) │
└──────────────────┘ └──────────────────┘
│
│ stdout
▼
┌──────────────────┐
│ delivery router │
│ (telegram/disc…) │
└──────────────────┘
- **无 LLM 调用。**零 Token,零代理循环,零模型花费。
- **脚本即任务。**脚本决定是否发出警报。产生输出 → 发送消息。不产生输出 → 静默心跳。
- Bash 或 Python。
.sh/.bash文件在/bin/bash下运行;任何其他扩展名的文件在当前 Python 解释器下运行。~/.hermes/scripts/中的任何文件均被接受。 - **相同的调度器。**与 LLM 任务一起存在于
cronjob中——暂停、恢复、列出、日志记录和投递目标的工作方式完全相同。
何时使用
在以下场景中使用无代理模式:
- **内存/磁盘/GPU 看门狗。**每 5 分钟运行一次,仅在超过阈值时发出警报。
- **CI 钩子。**部署完成 → 发布 commit SHA。构建失败 → 发送日志的最后 100 行。
- 定期指标。“每天早上 9 点的 Stripe 收入”,通过简单的 API 调用 + 美化打印实现。
- **外部事件轮询器。**检查 API,在状态变更时发出警报。
- **心跳检测。**每 N 分钟 ping 一次仪表板以证明主机存活。
当需要代理决定说什么时使用常规(LLM 驱动)的 cron 任务——例如总结长文档、从 feed 中挑选有趣的项目、起草人性化的消息。无代理路径适用于脚本的 stdout 本身就是消息的情况。
从聊天中创建
无代理模式的真正优势在于,代理本身可以为你设置看门狗——无需编辑器,无需 shell,无需记忆 CLI 标志。你描述所需内容,Hermes 编写脚本、安排调度,并告知你何时触发。
示例对话
**你:**如果 RAM 超过 85%,每 5 分钟在 Telegram 上提醒我
Hermes:(写入
~/.hermes/scripts/memory-watchdog.sh,然后使用no_agent=true调用cronjob(...))已设置。每 5 分钟运行一次,仅在 RAM 超过 85% 时向 Telegram 发出警报。脚本:
memory-watchdog.sh。任务 ID:abc123。
在底层,代理进行了两次工具调用:
# 1. Write the check script
write_file(
path="~/.hermes/scripts/memory-watchdog.sh",
content='''#!/usr/bin/env bash
ram_pct=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}')
if [ "$ram_pct" -ge 85 ]; then
echo "RAM ${ram_pct}% on $(hostname)"
fi
# Empty stdout = silent tick; no message sent.
''',
)
# 2. Schedule it — no_agent=True skips the LLM on every tick
cronjob(
action="create",
schedule="every 5m",
script="memory-watchdog.sh",
no_agent=True,
deliver="telegram",
name="memory-watchdog",
)
从那一刻起,每次心跳都是免费的:调度器运行脚本,如果 stdout 非空则将其管道传输到 Telegram,并且绝不接触模型。
代理为你做出的决定
当你提出类似“当 X 发生时提醒我”或“每 N 分钟检查 Y 并在 Z 发生时告诉我”这样的请求时,Hermes 的 cronjob 工具描述会指示它在消息内容完全由脚本确定时使用 no_agent=True。当请求需要推理时(“总结新问题”、“挑选最有趣的头条新闻”、“起草友好的提醒”),它会回退到正常的 LLM 驱动路径。
你不必自己指定 --no-agent。只需描述行为即可。
从聊天中管理看门狗
代理可以像创建任务一样暂停、恢复、编辑和删除任务:
**你:**今晚停止内存看门狗
Hermes:(调用
cronjob(action='pause', job_id='abc123'))已暂停。通过说“重新开启它”或使用
hermes cron resume abc123来恢复。
**你:**改为每 15 分钟一次
Hermes:(调用
cronjob(action='update', job_id='abc123', schedule='every 15m'))
完整的生命周期(创建/列出/更新/暂停/恢复/立即运行/删除)对代理可用,而你无需学习任何 CLI 命令。
从 CLI 创建
更喜欢使用 shell?CLI 路径通过三个命令提供相同的结果:
# 1. Write your script
cat > ~/.hermes/scripts/memory-watchdog.sh <<'EOF'
#!/usr/bin/env bash
# Alert when RAM usage is over 85%. Silent otherwise.
RAM_PCT=$(free | awk '/^Mem:/ {printf "%d", $3 * 100 / $2}')
if [ "$RAM_PCT" -ge 85 ]; then
echo "⚠ RAM ${RAM_PCT}% on $(hostname)"
fi
# Empty stdout = silent run; no message sent.
EOF
chmod +x ~/.hermes/scripts/memory-watchdog.sh
# 2. Schedule it
hermes cron create "every 5m" \
--no-agent \
--script memory-watchdog.sh \
--deliver telegram \
--name "memory-watchdog"
# 3. Verify
hermes cron list
hermes cron run <job_id> # fire it once to test
这就是全部。无需提示,无需技能,无需模型。
脚本输出如何映射到投递
| 脚本行为 | 结果 |
|---|---|
| 退出码 0,stdout 非空 | 原样投递 stdout |
| 退出码 0,stdout 为空 | 静默心跳 — 无投递 |
退出码 0,stdout 最后一行包含 {"wakeAgent": false} | 静默心跳(与 LLM 任务共享的门控机制) |
| 非零退出码 | 投递错误警报(因此损坏的看门狗不会静默失败) |
| 脚本超时 | 投递错误警报 |
“为空时静默”的行为是经典看门狗模式的关键:脚本可以自由地每分钟运行,但通道仅在确实需要注意时才看到消息。
脚本规则
脚本必须位于 ~/.hermes/scripts/ 中。这在任务创建时和运行时都会强制执行——绝对路径、~/ 展开和路径遍历模式(../)会被拒绝。该目录与 LLM 任务使用的预检查脚本门控共享。
解释器的选择取决于文件扩展名:
| 扩展名 | 解释器 |
|---|---|
.sh, .bash | /bin/bash |
| 其他任何扩展名 | sys.executable(当前 Python) |
我们故意不遵循 #!/... shebang——保持解释器集明确且精简,可以减少调度器信任的攻击面。
调度语法
与其他所有 cron 任务相同:
hermes cron create "every 5m" # interval
hermes cron create "every 2h"
hermes cron create "0 9 * * *" # standard cron: 9am daily
hermes cron create "30m" # one-shot: run once in 30 minutes
请参阅 cron 功能参考 了解完整语法。
投递目标
--deliver 接受网关所知的一切内容。一些常见的形式:
--deliver telegram # platform home channel
--deliver telegram:-1001234567890 # specific chat
--deliver telegram:-1001234567890:17585 # specific Telegram forum topic
--deliver discord:#ops
--deliver slack:#engineering
--deliver signal:+15551234567
--deliver local # just save to ~/.hermes/cron/output/
对于机器人令牌平台(Telegram、Discord、Slack、Signal、SMS、WhatsApp),在脚本运行时不需要运行中的网关——该工具使用 ~/.hermes/.env / ~/.hermes/config.yaml 中已有的凭据直接调用每个平台的 REST 端点。
编辑与生命周期
hermes cron list # see all jobs
hermes cron pause <job_id> # stop firing, keep definition
hermes cron resume <job_id>
hermes cron edit <job_id> --schedule "every 10m" # adjust cadence
hermes cron edit <job_id> --agent # flip to LLM mode
hermes cron edit <job_id> --no-agent --script … # flip back
hermes cron remove <job_id> # delete it
所有适用于 LLM 作业的操作(暂停、恢复、手动触发、更改投递目标)也适用于无代理作业。
实际示例:磁盘空间警报
cat > ~/.hermes/scripts/disk-alert.sh <<'EOF'
#!/usr/bin/env bash
# Alert when / or /home is over 90% full.
THRESHOLD=90
df -h / /home 2>/dev/null | awk -v t="$THRESHOLD" '
NR > 1 && $5+0 >= t {
printf "⚠ Disk %s full on %s\n", $5, $6
}
'
EOF
chmod +x ~/.hermes/scripts/disk-alert.sh
hermes cron create "*/15 * * * *" \
--no-agent \
--script disk-alert.sh \
--deliver telegram \
--name "disk-alert"
当两个文件系统的使用率均低于 90% 时保持静默;当某个文件系统超出阈值时,每个超标的文件系统恰好触发一行输出。
与其他模式的比较
| 方法 | 运行内容 | 何时使用 |
|---|---|---|
cronjob --no-agent(本页) | 按 Hermes 的计划运行你的脚本 | 不需要推理的周期性看门狗/警报/指标 |
cronjob(默认,LLM) | 带有可选预检查脚本的代理 | 当消息内容需要对数据进行推理时 |
OS cron + 向 webhook 订阅 发送 curl | 按 OS 计划运行你的脚本 | 当 Hermes 可能不健康时(即你正在监控的对象) |
对于必须在 即使网关宕机时 也能触发的关键系统健康看门狗,请使用操作系统级别的 cron 并通过普通的 curl 向 Hermes webhook 订阅(或任何外部警报端点)发送请求——这些作为独立的操作系统进程运行,不依赖于 Hermes 是否处于运行状态。当被监控的对象是外部系统时,网关内调度器是正确的选择。
相关
- 使用 Cron 自动化一切 — LLM 驱动的 cron 模式。
- 计划任务 (Cron) 参考 — 完整的调度语法、生命周期、投递路由。
- Webhook 订阅 — 用于外部调度器的即发即弃 HTTP 入口点。
- 网关内部原理 — 投递路由器内部原理。