Skip to content

Crash on Python <3.10: TypeError with X | None type hints #21798

Closed as not planned

Description

@hrnbld

Bug Description

Hermes Agent crashes immediately on Python 3.9 with TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Steps to Reproduce

  1. Use Python 3.9 (or < 3.10)
  2. Run hermes --version or any hermes command
  3. Observe crash

Error Output

Traceback (most recent call last):
  File "/path/to/hermes-agent/hermes", line 10, in <module>
    from hermes_cli.main import main
  File "/path/to/hermes-agent/hermes_cli/main.py", line 6452, in <module>
    env: dict[str, str] | None = None,
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'

Root Cause

Multiple files use Python 3.10+ type hint syntax (X | None, dict[str, str] | None) without:

  1. Adding from __future__ import annotations to make it a string annotation (forward-compatible)
  2. Or checking Python version >= 3.10 in the launcher

Affected files include:

  • hermes_constants.py
  • utils.py
  • hermes_cli/main.py
  • Many plugin/model provider files (shown in "Failed to load bundled provider plugin" warnings)

Suggested Fix

  1. Add from __future__ import annotations to ALL Python files that use | type syntax
  2. OR add Python version check in hermes launcher script:
import sys
if sys.version_info < (3, 10):
    raise RuntimeError("Hermes Agent requires Python 3.10 or higher")

Environment

  • OS: macOS (LibreSSL 2.8.3)
  • Python: 3.9.x (system) or 3.11.x (venv)
  • Hermes Agent: v0.13.0 (2026.5.7)

Workaround

Use Python 3.11+ via venv, or fix shebang to point to correct Python binary.

Activity

  1. added
    type/bugSomething isn't working
    comp/cliCLI entry point, hermes_cli/, setup wizard
    comp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint
    P3Low — cosmetic, nice to have
    on May 8, 2026
  2. alt-glitch commented on May 8, 2026

    @alt-glitch

    Related: PR #13765 adds from __future__ import annotations to 112 files for Python 3.9 PEP 604 compatibility. Also related to #16257 and PR #15158 which fix the same class of bug in specific files.\n\nWorkaround: use Python 3.10+ (recommended) or wait for #13765 to land.

  3. mtthw-prvs-mngd commented on May 19, 2026

    @mtthw-prvs-mngd

    Confirming this still reproduces on v0.14.0 (2026.5.16) with a fresh install on macOS (Apple Silicon, Sonoma 14.x). Same trace as the OP, slightly different line:

    Traceback (most recent call last):
      File "/Users/me/.hermes/hermes-agent/hermes", line 10, in <module>
        from hermes_cli.main import main
      File "/Users/me/.hermes/hermes-agent/hermes_cli/main.py", line 205, in <module>
        _apply_profile_override()
      File "/Users/me/.hermes/hermes-agent/hermes_cli/main.py", line 164, in _apply_profile_override
        from hermes_constants import get_default_hermes_root
      File "/Users/me/.hermes/hermes-agent/hermes_constants.py", line 110, in <module>
        def get_optional_skills_dir(default: Path | None = None) -> Path:
    TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
    

    Concrete root cause on macOS specifically:

    The installer drops a launcher at ~/.hermes/hermes-agent/hermes with shebang #!/usr/bin/env python3. On macOS, /usr/bin/env python3 resolves to the system Python at /usr/bin/python3 which Apple has shipped as 3.9.6 since macOS 12 — still the default on Sonoma 14 / Sequoia 15. The installer itself uses uv to build a venv with Python 3.11.15 at ~/.hermes/hermes-agent/venv/bin/python, so the right Python is right there — the launcher just doesn't use it.

    $ file ~/.hermes/hermes-agent/hermes
    ... Python script text executable, ASCII text
    $ head -1 ~/.hermes/hermes-agent/hermes
    #!/usr/bin/env python3
    $ /usr/bin/env python3 --version
    Python 3.9.6
    $ ~/.hermes/hermes-agent/venv/bin/python --version
    Python 3.11.15
    

    Workaround that's been reliable across v0.13.0 and v0.14.0:

    alias hermes="$HOME/.hermes/hermes-agent/venv/bin/hermes"

    The venv binary's auto-generated shebang correctly points at the venv Python (it's pip install-created), so invoking it directly bypasses the broken top-level launcher.

    Suggested fix (smallest possible change):

    Change the launcher's shebang from #!/usr/bin/env python3 to either:

    1. Absolute path to venv: #!/Users/${USER}/.hermes/hermes-agent/venv/bin/python — installer-templated, would need substitution at install time but is correct-by-construction
    2. Relative resolution: re-write the launcher to be a small bash script that exec's "$(dirname "$0")/venv/bin/python" "$(dirname "$0")/hermes.py" "$@" — no install-time templating needed

    Option 2 is what most installers in this position do (uv itself ships entry-point shims that work this way). It also survives $HOME moves and multi-user installs without re-running the installer.

    The version-check approach the OP suggested is fine as a defensive fallback, but it'd give users a "your Python is too old" error when they actually have a correct Python sitting 12 inches away in the bundled venv — which feels like the wrong UX.

    Happy to send a PR if you'd like — let me know if option 2 is the direction or if you'd prefer the version-check + clearer error message.

  4. teknium1 commented on Jul 13, 2026

    @teknium1
    Collaborator

    Thanks for the detailed macOS reproduction and for identifying that the bundled venv was not being used.

    Automated hermes-sweeper review found this addressed on current main:

    • scripts/install.sh:1603-1644 now writes the user-facing hermes launcher as a Bash shim that execs $INSTALL_DIR/venv/bin/hermes, so it does not invoke /usr/bin/env python3.
    • scripts/install.sh:59 and scripts/install.sh:1322-1343 provision and pin the managed venv to Python 3.11.
    • pyproject.toml:20 now declares Python 3.11–3.13 support, and website/docs/reference/faq.md:147-160 documents that requirement.
    • This implementation is included in release v2026.7.1 (commit d682f320b35a13084371a541a835e1d988c982b8).

    The related unmerged PR #22366 proposed an import-time version error; the current installer instead fixes the reported standard-install path by consistently dispatching through the managed 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

    P3Low — cosmetic, nice to havecomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointcomp/cliCLI entry point, hermes_cli/, setup wizardsweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions