Hermes Agent v0.18.0 升级实战:1953个commit带来的3个性能提升与1个致命坑

发布时间:2026/7/3 7:52:48
Hermes Agent v0.18.0 升级实战:1953个commit带来的3个性能提升与1个致命坑 Hermes Agent v0.18.0 升级实战1953 个 commit 带来的性能提升与一个致命坑摘要6 月 19 日刚升完 v0.17.07 月 1 日 v0.18.0 又来了——1953 个 commit、998 个 merged PR、P0/P1 清零。本文记录从 v0.17.0 到 v0.18.0 的完整升级过程包括安全网备份、git tag 纯净切版、gateway drain 机制与 systemd TimeoutStopSec 冲突导致的反复崩溃修复、三层 skill 保护机制拆解、以及后台自学习降本实测。文末附回滚命令全程可复现。一、为什么要升7 月 1 日Nous Research 发布了 Hermes Agent v0.18.0v2026.7.1——The Judgment Release。这次更新不追求新功能而是干了一件疯狂的事12 天内把仓库里所有 P0 和 P1 级别的 issue/PR 全部清零。数字说话指标v0.17.0 → v0.18.0Commits1,953Merged PRs998P0/P1 清零496 issues 196 PRs核心文件变更83 files, 20,527 / -4,332 行社区贡献者370核心文件变动分布文件变更量说明gateway/run.py3,193 行scale-to-zero / drain 机制hermes_state.py1,215 行state DB schema 修复、FTS5 写入损坏检测run_agent.py577 行agent loop 优化agent/context_compressor.py736 行token 级尾部保护预算二、升级前的安全网跨大版本升级1000 commits不备份就是赌命。标准三步# 1. 全量备份 config state skills webui 配置BACKUP_DIR~/backup-hermes-pre-v0.18.0-$(date%Y%m%d-%H%M%S)mkdir-p$BACKUP_DIRcp-a~/.hermes/config.yaml~/.hermes/.env~/.hermes/state.db\~/.hermes/auth.json~/.hermes/cron/~/.hermes/skills/$BACKUP_DIR/cp-a~/.hermes-web-ui/$BACKUP_DIR/hermes-web-ui/tarczf${BACKUP_DIR}.tar.gz-C$(dirname$BACKUP_DIR)$(basename$BACKUP_DIR)# 2. Git stash 当前修改cd~/.hermes/hermes-agent gitstashpush-mpre-v0.18.0-upgrade# 3. 拉取最新 taggitconfighttp.proxyhttp://127.0.0.1:7890# 国内需要代理gitfetch--tags⚠️铁律只切 release tag不拉 master。hermes update命令实际行为是git checkout main会拉到 tag 之后 N 个未测试的 commit。正确做法是直接git checkout v2026.7.1。三、升级执行 验证cd~/.hermes/hermes-agent# 切换 taggitcheckoutv2026.7.1# 验证必须是纯 tag无后缀偏移gitdescribe--tags# 期望v2026.7.1# ❌ 异常v2026.7.1-919-gd712a7fd7 → 919 commits past tag 在 main 上# 重新安装venv/bin/pipinstall-e.# 验证版本hermes--version# Hermes Agent v0.18.0 (2026.7.1)# 重启 gatewaysystemctl--userrestarthermes-gateway四、致命坑gateway drain 与 systemd TimeoutStopSec 冲突升级完成后gateway 开始反复崩溃。journalctl 显示7月0209:52:52hermes-gateway.service:Failedwithresultexit-code.7月0212:17:11hermes-gateway.service:Failedwithresultexit-code.7月0212:52:39hermes-gateway.service:Statestop-sigtermtimedout.Killing.#3小时内重启了4次日志中的关键警告WARNING: Stale systemd unit detected: hermes-gateway.service has TimeoutStopSec5s but drain_timeout0s (expected 30s). systemd may SIGKILL the gateway mid-drain.根因v0.18.0 引入了gateway drain优雅排空机制——收到 SIGTERM 后gateway 需要时间排空正在处理的会话然后安全退出。但旧的 systemd unit 文件里TimeoutStopSec5s只给 5 秒v0.18.0 gateway: 给我 30 秒排空当前会话 systemd unit: 5 秒后直接 SIGKILL ↓ 每次重启必被强杀 → 循环崩溃修复重新生成 systemd unithermesgatewayinstall--force新生成的 unit 文件对比旧 unit新 unitTimeoutStopSec5s90s✅ExecStartgateway run --replace--profile friday gateway run新 unit 还会以hermes-gateway-friday.service命名profile 感知需要停用旧的systemctl--userstophermes-gateway.service systemctl--userdisablehermes-gateway.service systemctl--userrestarthermes-gateway-friday.service五、三个实打实的性能提升5.1 推理模型不再被误杀v0.17.0 中Hermes 每 90-180 秒检测 stream 是否存活。DeepSeek R1 / o1 / Grok 等推理模型思考阶段可能超过这个时间 → 被当成死连接杀掉。v0.18.0 新增reasoning_timeouts.py216 行按模型名匹配推理模型白名单自动设置 floor 超时场景v0.17.0v0.18.0DeepSeek R1 思考 120s 90s 被误杀✅ floor 超时放过常规模型非推理✅ 不变✅ 零影响5.2 后台自学习 token 消耗降级每次对话结束后Hermes 会用 background review fork 回顾本轮生成内容判断是否要保存 skill/memory。v0.17.0用主模型重放整段对话 → 全额 token 费用。v0.18.0切到auxiliary模型。如果 auxiliary 和主模型相同 → 利用 prompt cache热读便宜如果不同 → 只传最近几轮摘要cold-write 大幅减少。长对话场景下 post-turn review 的 token 消耗可降低 50-80%。5.3 上下文压缩更智能v0.17.0 的压缩用字符数估算尾部保护预算不准导致保护过度 → 压缩无效 → 反复浪费 token。v0.18.0 修复了三个问题Token 级尾部预算估算保护更精确压缩更有效摘要分隔符修复END MARKER 放在摘要最后旧摘要不会泄露到新轮次无效压缩抑制压缩效果追踪无效时自动抑制重试六、skill 不会被后台乱改了——三层保护这是此次升级在可用性上最重要的改进。v0.17.0 有一个已知 bug后台 review fork 会把 curator 指令注入用户的 session DB下次对话 agent 会变成 curator 人格拒绝执行任务。v0.18.0 上了三重锁第一层类型隔离后台 review fork 只能改 agent 自己创建的本地 skill。内置 skill、hub skill、外部目录 skill 全部拒绝Refusing background curator patch for skill xxx: the skill lives in skills.external_dirs, which are externally owned and read-only.第二层先读后写即使第一层放行fork 也必须先skill_view()读过 skill 的当前内容才允许写。不读原文就别想改Refusing background curator patch for skill my-skill:thecurrentSKILL.mdcontenthasnotbeenloadedinthisreviewturn.第三层会话隔离Review fork 完全隔离于用户主会话review_agent._persist_disabledTrue# 禁止写 session DBreview_agent._session_dbNone# 无 DB 连接review_agent._end_session_on_closeFalse# 不关闭主会话七、WebUI 版本对齐hermes-agent 和 hermes-webui 是两个独立项目版本必须对齐否则会报ModuleNotFoundError。组件升级前升级后hermes-agentv0.17.0 (v2026.6.19)v0.18.0 (v2026.7.1)hermes-webuiv0.51.692v0.51.815关键修复webui v0.51.791 适配了 agent v0.18.0 的 verification-stop nudge 过滤机制——否则 agent 的自验证回合会以裸 system 消息显示在聊天中。v0.51.815 包含了这个修复同时比最新的 v0.51.816 少一个 Claude Code 侧边栏开关无影响。cd~/hermes-webui gitcheckoutv0.51.815八、回滚预案如果升级后出现不可接受的问题一键回滚到 v0.17.0cd~/.hermes/hermes-agent gitcheckoutv2026.6.19 venv/bin/pipinstall-e. systemctl--userrestarthermes-gateway-friday# webui 同步回滚cd~/hermes-webui gitcheckoutv0.51.692配置备份在~/backup-hermes-pre-v0.18.0-*.tar.gz276MB包含 config.yaml、.env、state.db、auth.json、cron、skills 的完整快照。总结v0.18.0 是一次稳定性驱动的升级——不炫技、不加功能12 天修完 692 个 P0/P1。升级后最直观的感受Gateway 稳定了——不再被 systemd TimeoutStopSec 误杀Token 省了——后台 review 切辅助模型Skill 安全了——三层锁防后台乱改推理模型不被杀了——有白名单 floor 超时唯一的坑是 gateway drain 与 systemd unit 的兼容性问题修复只需一行命令。整体值得升级。