The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tools): execute_code shares the interpreter-kill rejection text; collapse redundant supervisor branch
teknium11f1fa9a87e1f
diff --git a/gateway/restart.py b/gateway/restart.pyindex 05dd27d83bd..d6aef066532 100644--- a/gateway/restart.py+++ b/gateway/restart.py@@ -101,7 +101,7 @@ def is_supervised_gateway_launch(environ: Mapping[str, str] | None = None) -> boenv = os.environ if environ is None else environif env.get("HERMES_SUPERVISED_CHILD"):return True- return is_gateway_supervisor_process() if environ is None else is_gateway_supervisor_process(environ)+ return is_gateway_supervisor_process(environ)def is_container_restart_context() -> bool:diff --git a/tests/tools/test_execute_code_lifecycle_guard_deadline.py b/tests/tools/test_execute_code_lifecycle_guard_deadline.pyindex 62b6f676877..085e38caccf 100644--- a/tests/tools/test_execute_code_lifecycle_guard_deadline.py+++ b/tests/tools/test_execute_code_lifecycle_guard_deadline.py@@ -31,3 +31,15 @@ def test_wedged_lifecycle_probe_returns_bounded_error_without_running(monkeypatcassert elapsed < 0.5, f"lifecycle probe wedged execute_code for {elapsed:.2f}s"assert "did not finish" in result["error"]assert ran == [], "a probe with no verdict must not fail open into execution"+++def test_interpreter_kill_in_execute_code_names_the_owned_process_route(monkeypatch):+ """Sibling surface of the terminal guard (#113667): an image-name kill inside a cell gets the same+ proc_* / explicit-PID rejection, not the generic lifecycle text."""+ import tools.process_registry as process_registry++ monkeypatch.setattr(process_registry, "_is_supervised_gateway_process", lambda: True)+ result = json.loads(cet.execute_code('import subprocess; subprocess.run(["pkill", "-9", "python3"])'))+ assert "proc_" in result["error"] and "explicit PID" in result["error"]+ generic = json.loads(cet.execute_code('import os; os.system("hermes gateway restart")'))+ assert "proc_" not in generic["error"] and "cannot restart or stop the gateway" in generic["error"]diff --git a/tools/code_execution_tool.py b/tools/code_execution_tool.pyindex f3722349ae9..894e7a21105 100644--- a/tools/code_execution_tool.py+++ b/tools/code_execution_tool.py@@ -709,8 +709,14 @@ def execute_code("(process-identity probe wedged); the code was not run. Retry the call.")if _probe.value:- from cron.lifecycle_guard import contains_gateway_lifecycle_command+ from cron.lifecycle_guard import (+ HOST_INTERPRETER_KILL_REJECTION,+ contains_gateway_lifecycle_command,+ contains_host_interpreter_kill,+ )if contains_gateway_lifecycle_command(code):+ if contains_host_interpreter_kill(code):+ return tool_error(HOST_INTERPRETER_KILL_REJECTION)return tool_error("Blocked: cannot restart or stop the gateway from inside the ""gateway process. The gateway would kill this script before "diff --git a/tools/terminal_tool_guards.py b/tools/terminal_tool_guards.pyindex 954a904427a..de19c23a1c2 100644--- a/tools/terminal_tool_guards.py+++ b/tools/terminal_tool_guards.py@@ -204,6 +204,7 @@ def gateway_lifecycle_block(return Nonefrom cron.lifecycle_guard import (_MAX_REFERENCED_SCRIPT_BYTES,+ HOST_INTERPRETER_KILL_REJECTION,contains_host_interpreter_kill,contains_launchctl_submit_command,lifecycle_scan_root_within_budget,@@ -248,13 +249,7 @@ def gateway_lifecycle_block(# Name the ownership-scoped route for image-name kills: the intent is almost always "stop# MY background job", and re-rolling the same over-broad spelling is what takes the gateway down.if lifecycle_scan_root_within_budget(command) and contains_host_interpreter_kill(command):- return _blocked_json(- "Blocked: this command kills every process whose image/name matches the Python "- "interpreter, which is the process hosting this gateway (and this command). "- "Stop only the process you own instead: process(action=\"kill\", session_id=\"proc_…\") "- "for a background job Hermes started, or kill/taskkill by its explicit PID.",- "error",- )+ return _blocked_json(HOST_INTERPRETER_KILL_REJECTION, "error")return _blocked_json("Blocked: command or referenced script cannot restart, stop, or ""uninstall the gateway from inside the gateway process. The gateway would "