Skip to content

Skip Hermes source venvs built for another Python version - #19160

Merged
teamleaderleo merged 1 commit into
mainfrom
fix-18680-hermes-venv-python
Oct 11, 2026
Merged

teamleaderleo merged 1 commit into
mainfrom
fix-18680-hermes-venv-python

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

Since #12996, cmux-hermes-python-wrapper picked $HERMES_PYTHON_SRC_ROOT/{venv,.venv}/bin/python{,3} before the interpreter that launched Hermes. That fixed #12948: on macOS ps comm resolves a symlinked venv Python to the base interpreter, which lacks the venv's site-packages. However, a Hermes source checkout managed by hermes pm runs on a store interpreter, and its .venv can be an unrelated test env on another Python minor version. The gateway then ran on that venv's Python (for example 3.11), Hermes's bootstrap added site-packages built for the launcher's 3.14, and the gateway crash-looped with No module named 'pydantic_core._pydantic_core'.

What changed

How tested

Fixes #18680

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes Hermes gateway crash-loops (No module named 'pydantic_core._pydantic_core') when a source checkout's .venv runs a different Python minor version than the launcher. The wrapper now resolves the launcher interpreter first and only prefers the source-root venv when its pyvenv.cfg version matches the launcher's.

Written for commit 840a8d1. Summary will update on new commits.

View guided diff Turn on auto-fix


Note

Medium Risk
Changes TUI gateway interpreter selection in the Hermes launch path; wrong logic could break venv preference on macOS or reintroduce version-mismatch crashes.

Overview
Fixes Hermes TUI gateway crash-loops when a source checkout’s .venv targets a different Python minor than the interpreter that launched Hermes (e.g. store Python 3.14 vs an unrelated test venv on 3.11).

cmux-hermes-python-wrapper now resolves the launcher interpreter first (via ps on the TUI’s grandparent), then still prefers $HERMES_PYTHON_SRC_ROOT/{venv,.venv} only when pyvenv.cfg major.minor matches the launcher (or when either version is unknown). Mismatched venvs are skipped and the launcher is used. Helpers read the launcher version with a short -I -S -c probe and the venv version from pyvenv.cfg without executing the venv.

Tests add a Hermes-like process tree and assert mismatched venvs lose to the launcher while same-version venvs still win (preserving the symlinked-venv/macOS behavior from #12948).

Reviewed by Cursor Bugbot for commit 840a8d1. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Python tools launched through Hermes now avoid virtual environments with a Python version that differs from the launcher’s version. When no matching environment is available, they use the launcher’s Python interpreter, with python3 as a fallback.

The TUI Python wrapper picked $HERMES_PYTHON_SRC_ROOT/{venv,.venv} before
the launcher's own interpreter (#12996). A Hermes source checkout managed by
`hermes pm` runs on a store interpreter, and its .venv can be an unrelated
test env on another Python minor version, so the gateway crash-looped
loading extensions built for the launcher's version.

Resolve the launcher interpreter first, and skip a source venv whose
pyvenv.cfg version differs from it. Venvs without a readable version, or
when the launcher is unknown, are still preferred as before, which keeps
the symlinked-venv fix for #12948.

Fixes #18680

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: manaflow-ai/cmux/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: fbbddc79-db8a-4e83-8cf6-fa9e1f0161ba

📥 Commits

Reviewing files that changed from the base of the PR and between 3dd1fe7 and 840a8d1.


📒 Files selected for processing (2)
  • Resources/bin/cmux-hermes-python-wrapper
  • tests/test_hermes_wrapper_hooks.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.



📝 Walkthrough

Walkthrough

The Hermes Python wrapper now checks the launcher’s Python version before selecting a source-root virtual environment. It skips a virtual environment when both versions are known and differ. Tests cover matching and mismatched versions.

Changes

Hermes interpreter selection

Layer / File(s) Summary
Version-aware interpreter selection
Resources/bin/cmux-hermes-python-wrapper, tests/test_hermes_wrapper_hooks.py
The wrapper checks the launcher version against each source-root virtual environment’s configured version. It skips a known mismatch and falls back to the launcher interpreter when no eligible virtual environment is found. Tests cover matching and mismatched versions.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: austinywang


Merge Risk: ⚪ Minimal · up to 840a8

No concrete merge-blocking issue was established for the supported Hermes invocation. The change is mergeable after normal checks.

Pre-merge checks | Passed 24 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (24 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main behavior change: skipping Hermes source virtual environments built for a different Python version.
Description check Passed The description clearly explains the problem, resulting behavior, implementation, issue linkage, and test command. It uses equivalent headings for Summary and Testing, but it omits the required Change…
Linked Issues check Passed The active direct issue is #18680. The wrapper now discovers the Hermes launcher interpreter before source-root virtual environments. It reads the venv pyvenv.cfg version and compares major.minor wi…
Out of Scope Changes check Passed The changes are limited to Resources/bin/cmux-hermes-python-wrapper and its focused test file. The helper functions, launcher-selection logic, version checks, and new tests directly support issue #1…
Cmux Cloud Persistent Session And Early Input Passed PASS: The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. The diff changes Hermes Python interpreter selection and adds tests. It does no…
Cmux Swift Actor Isolation Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It introduces no production Swift changes, so it cannot introduce or worsen the speci…
Cmux Swift Blocking Runtime Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It introduces no Swift production changes, so the Swift blocking-runtime check is not…
Cmux Browser Automation Off-Main Passed PASS: The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It does not change browser socket commands, Sources/TerminalController.swift,…
Cmux Expensive Synchronous Load Passed The custom check applies only to production Swift changes. The reviewed diff changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py; it contains no Swift, Obj…
Cmux Cache Substitution Correctness Passed PASS: The pull request changes a Bash production wrapper and Python tests, not production Swift, TypeScript, or JavaScript. The diff updates interpreter selection and adds version checks; it does not …
Cmux No Hacky Sleeps Passed The production change only discovers the launcher and compares Python versions from pyvenv.cfg; it introduces no sleep, timer, polling, fixed delay, retry wait, or wall-clock synchronization. The ad…
Cmux Algorithmic Complexity Passed The production change uses bounded iteration over exactly two possible venv directories and two interpreter names per directory (Resources/bin/cmux-hermes-python-wrapper:75-90). The pyvenv.cfg scan is…
Cmux Swift Concurrency Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It introduces no Swift, Objective-C, or Objective-C++ code, so the Swift concurrency …
Cmux Swift @Concurrent Passed PASS: The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. The diff contains no Swift files or Swift concurrency changes, so `.github/revi…
Cmux Swift Package Boundaries Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It contains no production Swift changes and no Swift package boundary changes, so thi…
Cmux Swiftpm Lockfiles Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It does not change SwiftPM packages, Xcode project package references, .gitignore f…
Cmux Swift Logging Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It adds no Swift code and no production Swift logging. The Swift logging check is the…
Cmux User-Facing Error Privacy Passed The production path reaches Hermes TUI users because cmux-hermes-agent-wrapper sets HERMES_PYTHON to cmux-hermes-python-wrapper (lines 381-408). The diff changes interpreter selection only. The …
Cmux Full Internationalization Passed PASS: The PR changes only a Bash Hermes Python wrapper and Python tests. It adds no Swift UI text, app catalog or Info.plist entries, web UI/API copy, metadata, markdown, changelog, or locale-specific…
Cmux Swiftui State Layout Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. The diff contains no SwiftUI views, ObservableObject, @Published, `GeometryReader…
Cmux Architecture Rethink Passed PASS: The pull request changes only the Bash wrapper and Python tests. It introduces no Swift architecture changes, lifecycle ownership, timing repair, or duplicate Swift wiring covered by the rule.
Cmux Swift Auxiliary Window Close Shortcuts Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. The authoritative diff contains no Swift, storyboard, XIB, or window-related files, s…
Cmux Source Artifacts Passed The diff changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. Both are intentional product source and test code. The test creates temporary data at runtime…
Cmux No Test Or Debug Seam In Production Source Passed The pull request changes only Resources/bin/cmux-hermes-python-wrapper and tests/test_hermes_wrapper_hooks.py. It changes no Swift file under a production Sources/ path, so this custom check doe…

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

CI fast guards passes on 840a8d1493 (https://github.com/manaflow-ai/cmux/actions/runs/38100034519). This covers only the fast guards, not CI: CI's result is the ci-status check, and the CI failure attribution comment names any failing test.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Subagent review at 840a8d1: merge. Ran tests/test_hermes_wrapper_hooks.py on the head (passes, including the #12948 symlinked-venv case) and with main's wrapper swapped in (the new test fails with the #18680 symptom). pyvenv.cfg parsing falls back to the old venv-first behavior on anything unknown. Follow-up nit: the read loop skips a final line with no trailing newline.

@teamleaderleo
teamleaderleo merged commit 2322f7d into main Oct 11, 2026
160 of 166 checks passed
@teamleaderleo
teamleaderleo deleted the fix-18680-hermes-venv-python branch October 11, 2026 01:08
@github-actions

Copy link
Copy Markdown
Contributor

Merge receipt for 840a8d1493: every check was green at merge (13 verified; 20 skipped by policy). Full suite runs on main after merge.

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

Labels

None yet

Projects

None yet

1 participant