diff --git a/tools/code_execution_tool.py b/tools/code_execution_tool.py index b7fac539..f25c983f 100644 --- a/tools/code_execution_tool.py +++ b/tools/code_execution_tool.py @@ -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()