43c463fa95
The Desktop Electron process injects the Hermes venv's site-packages path (e.g. .../python3.11/site-packages) into PYTHONPATH so the Python 3.11 backend can import its packages. When this PYTHONPATH leaks into terminal subprocesses running a different Python version (e.g. Python 3.13), 3.11 C extension modules appear on sys.path ahead of the correct 3.13 versions and crash with ImportError (PIL _imaging, cryptography, etc.). Replace the existing blunt pop of PYTHONPATH from _ACTIVE_VENV_MARKER_VARS with a surgical Hermes-venv-aware filter: - Parse each PYTHONPATH entry by path - Strip only paths under ~/.hermes/hermes-agent/venv/.../site-packages - Preserve the Hermes source root (needed for import hermes_cli) - Preserve all user-set PYTHONPATH entries The same filter is applied in all three env builders: - _make_run_env (foreground terminal commands) - _sanitize_subprocess_env (background/PTY spawns) - PTY env builder This preserves env_passthrough semantics and never silently discards the user's own PYTHONPATH configuration.