Merge pull request #1383 from NousResearch/hermes/hermes-7ef7cb6a

fix: add project root to PYTHONPATH in execute_code sandbox
This commit is contained in:
Teknium 2026-03-14 21:41:50 -07:00 committed by GitHub
commit f9a61a0d9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 157 additions and 0 deletions

View file

@ -440,6 +440,11 @@ def execute_code(
child_env[k] = v
child_env["HERMES_RPC_SOCKET"] = sock_path
child_env["PYTHONDONTWRITEBYTECODE"] = "1"
# Ensure the hermes-agent root is importable in the sandbox so
# modules like minisweagent_path are available to child scripts.
_hermes_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
_existing_pp = child_env.get("PYTHONPATH", "")
child_env["PYTHONPATH"] = _hermes_root + (os.pathsep + _existing_pp if _existing_pp else "")
# Inject user's configured timezone so datetime.now() in sandboxed
# code reflects the correct wall-clock time.
_tz_name = os.getenv("HERMES_TIMEZONE", "").strip()