mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: add project root to PYTHONPATH in execute_code sandbox
The execute_code sandbox spawns a child process with cwd set to a temporary directory, but never adds the hermes-agent project root to PYTHONPATH. This makes project-root modules like minisweagent_path unreachable from sandboxed scripts, causing ImportError when the agent runs self-diagnostic or analysis code via execute_code. Fix by prepending the hermes-agent root directory to PYTHONPATH in the child process environment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9c322f7f59
commit
23bc642c82
1 changed files with 5 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue