Skip to content

[Bug] Hermes inventory 选中旧 venv,无法兼容新版 managed runtime(HERMES_UNAVAILABLE / hermes_yaml) #397

Closed

Description

@mtmtian

Area

Harness Adapter

Summary

codexhost 0.10.1 启动后,本机 Hermes 连接诊断报 HERMES_UNAVAILABLE。已复现:inventory 探针选中了残留的旧 Python 3.11 venv,而当前 Hermes 启动器已迁移到 managed Python 3.14 + hermes_bootstrap。因此,源码中实际存在的 hermes_yaml.py 无法被旧环境导入。

Expected behavior

Hermes 模型清单探针使用该安装当前的正式运行环境,兼容新版 managed-runtime 启动器;不因旧 venv 目录仍然存在而选错解释器。

Actual behavior

host: local
agent: Hermes
status: error
error.code: HERMES_UNAVAILABLE
error.message: Hermes inventory probe exited with 1: Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "<HOME>/.hermes/hermes-agent/hermes_cli/inventory.py", line 41, in load_picker_context
    from hermes_cli.config import (
  File "<HOME>/.hermes/hermes-agent/hermes_cli/config.py", line 34, in <module>
    import hermes_yaml as yaml
ModuleNotFoundError: No module named 'hermes_yaml'
retryable: true

Reproduction

  1. 本机安装新版 Hermes,~/.local/bin/hermes 转发到 ~/.hermes/hermes-agent/.hermes/bin/hermes。
  2. 当前 launcher 使用 managed Python 3.14.7,显式加入 Hermes 源码根目录,再导入 hermes_bootstrap。
  3. 安装目录同时保留旧 venv/bin/python(3.11.15)。
  4. 启动 codexhost 0.10.1,查看 local / Hermes 连接诊断,出现上述错误。

命令行最小复现(已执行):

"$HOME/.hermes/hermes-agent/venv/bin/python" -I -c \
  'from hermes_cli.inventory import load_picker_context; load_picker_context()'

结果:同样的 ModuleNotFoundError: No module named 'hermes_yaml'。

进一步验证(已执行):

  • hermes --print-runtime-command 成功返回当前 managed Python 3.14.7 的命令,包含源码路径初始化和 import hermes_bootstrap。
  • 从已安装 codexhost 的 plugins/hermes/plugin.mjs 提取原样的 INVENTORY_PROBE_SCRIPT,保留上述正式运行命令的 bootstrap,仅将末尾 CLI 入口替换为执行这份探针。
  • 结果:exit code 0,耗时 4.2 秒,返回 65 个模型(65 个 available),currentModelId 非空,stderr 0 字节。
  • 未修改 codexhost、Hermes 源码、依赖或用户配置;codexhost 内的错误尚未修复。上述验证是探针验证,不是完整聊天端到端验证。

codexhost version

0.10.1(Info.plist 与 codexhost-distribution.json 一致)

Codex Desktop version

本机承载应用为 /Applications/ChatGPT.app,CFBundleShortVersionString 为 26.917.71314;未单独确认 Codex Desktop 的产品版本。

OS / Architecture

macOS 27.2 / arm64

Installation

安装于 /Applications/codexhost.app;distribution 元数据为 installer / macos-arm64(未确认最初是否经 DMG 安装)。

Harness / Version

Hermes 本地源码安装,commit d0288be5b3330d2442e3907185b8e9d0958297bb,检查时 working tree 无改动。

  • 当前 managed runtime:Python 3.14.7
  • 残留旧 venv:Python 3.11.15

Connection

Local

Redacted logs / Screenshots

本机已安装 bundle 的相关代码位置与观察:

  • plugins/hermes/plugin.mjs 的 venvPythonFromShim() 只匹配旧式 exec "...venv/bin/python" shim,无法识别当前的转发 launcher。
  • inventoryPythonCandidates() 继续猜测 venv/bin/python 路径;readHermesModelInventory() 选择首个存在的候选。
  • runProbe() 直接执行 ["-I", "-c", INVENTORY_PROBE_SCRIPT],没有当前 Hermes launcher 的源码路径和 bootstrap 初始化。
  • HermesGatewayTransport.probe() 也复用了旧 shim / venv 候选逻辑,start() 同样直接调用 Python。该路径有同类兼容风险,但本次未验证 gateway 或实际聊天失败。

建议评估通过新版 Hermes 的 --print-runtime-command(支持 --module)获取安装绑定的运行命令,并保留 bootstrap 语义;旧版 Hermes 可保留旧解析方式作为兼容路径。inventory 和 gateway 两个调用点宜一并检查。仅给旧 venv 补装单个包无法解决运行环境选择错误。

Activity

  1. mtmtian commented on Oct 2, 2026

    @mtmtian
    Author

    补充 2026-10-02 / codexhost 0.11.0 installer / macOS 27.2 arm64 的实机复现结果:升级到 0.11.0 后,本 issue 的问题仍可复现。

    环境:

    • Codex Desktop:26.928.31416,build 12553(由 codexhost inspect --json 返回)。
    • Hermes:v0.21.5+5347.g666b9f0,git commit 666b9f04c4229341c9188b096eb64d2a5e807347。
    • 当前 launcher:managed Python 3.14.7 + hermes_bootstrap。
    • 遗留 venv/bin/python:3.11.15。

    执行 codexhost harness inspect hermes --refresh true --format compact,返回:

    status: error
    error.code: HERMES_UNAVAILABLE
    ModuleNotFoundError: No module named 'hermes_yaml'
    retryable: true
    

    复核 installed bundle:venvPythonFromShim() 无法识别当前的转发 launcher,readHermesModelInventory() 从旧候选路径选中 venv/bin/python,runProbe() 直接使用 -I -c,没有当前 launcher 的 bootstrap。

    替代验证:从 0.11.0 已安装 bundle 提取原样 INVENTORY_PROBE_SCRIPT,通过 hermes --print-runtime-command 取得当前运行命令,保留源码路径初始化与 import hermes_bootstrap,仅替换末尾入口为执行该探针。结果:exit 0,18 个模型,17 个 available,currentModelId 非空。模型数量与原报告不同,是本次当前配置下的观测,不作为跨版本比较。

    已看到 main 的修复提交:

    这是 0.11.0 发布包的复现补充。main 修复的实机运行和下一发布版尚未验证;本次没有安装 main 构建,也没有修改本机插件、Hermes 环境或模型配置。探针成功不等于完整聊天端到端通过。

  2. Tericerice commented on Oct 28, 2026

    @Tericerice
    Contributor

    Note

    🤖 Claude Opus 5.5 responding on behalf of Tericerice

    结论:当前代码已修复此问题,修复从 v0.12.0 开始包含在发布中。请用 v0.12.0 或更新版本复测,确认后可以关闭。

    在 main(a6e7e3a7)上的核查结果(一次修复调查和两次独立复核):

    • packages/adapters/hermes/src/hermes-inventory.ts:readHermesModelInventory() 先调用 nativeHermesPythonCommand(),也就是让 launcher 执行 --print-runtime-command,得到 managed Python 和 hermes_bootstrap 的完整运行命令。拿到后直接用它执行探针,不再查找 venv/bin/python 等候选。
    • 只有 launcher 明确不支持 --print-runtime-command(旧版 Hermes)时,才回退到旧的 shim/venv 查找。launcher 支持该参数但执行失败或输出异常时,直接报错,不回退。
    • Gateway transport 和其他调用点同样优先使用原生运行命令。
    • 修复 commit 11ca03e4 不在 v0.11.0 中,在 v0.12.0 中。0.11.0 上的补充复现与此一致。

    我们用真实的 _launchers.py、加上一个残留 venv 的模拟环境验证过:探针没有调用残留 venv,返回了正常的 inventory。我们没有在真实 Hermes 安装和 Codex Desktop 上做端到端验证。如果新版本仍能复现,请附上 codexhost harness inspect hermes --refresh true 的输出。

  3. BytePioneer-AI commented on Nov 13, 2026

    @BytePioneer-AI
    Owner

    主线提交 11ca03e 已改为优先使用 Hermes 原生 runtime,修复从 v0.12.0 起发布,避免误选残留旧 venv,因此关闭。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions