Skip to content

The agent that grows with you

fix: keep launcher YOLO out of shared gateway policy

Teknium628d702c0e50
diff --git a/hermes_cli/gateway_runtime_start.py b/hermes_cli/gateway_runtime_start.py
index 5d3fb31685b..973027f91b9 100644
--- a/hermes_cli/gateway_runtime_start.py
+++ b/hermes_cli/gateway_runtime_start.py
@@ -31,6 +31,7 @@ def spawn_unmanaged_gateway(profile_home: Path, *, deadline: float) -> subproces
# Profile selection is the explicit home, not the invoking client's display
# name. Runtime policy comes from that profile, never a launcher's --yolo.
env.pop("HERMES_PROFILE", None)
+ env.pop("HERMES_YOLO_MODE", None)
remaining(deadline)
logs = home / "logs"
logs.mkdir(parents=True, exist_ok=True)
diff --git a/tests/hermes_cli/test_gateway_runtime_ensure.py b/tests/hermes_cli/test_gateway_runtime_ensure.py
index 4b01720ec70..e00b374adcf 100644
--- a/tests/hermes_cli/test_gateway_runtime_ensure.py
+++ b/tests/hermes_cli/test_gateway_runtime_ensure.py
@@ -166,6 +166,38 @@ def test_unmanaged_child_uses_explicit_home_and_survives_launcher_exit(tmp_path,
gate.touch()
+def test_unmanaged_runtime_does_not_inherit_client_yolo(tmp_path, monkeypatch):
+ from hermes_cli import gateway_runtime_start as start
+
+ home = tmp_path / 'policy-home'
+ home.mkdir(mode=0o700)
+ witness = home / 'policy.json'
+ executable = tmp_path / 'owned-interpreter'
+ repo = Path(__file__).resolve().parents[2]
+ executable.write_text(
+ '#!' + sys.executable + '\nimport json, os, sys\nfrom pathlib import Path\n'
+ + f'sys.path.insert(0, {str(repo)!r})\n'
+ + 'from tools import approval\n'
+ + f'Path({str(witness)!r}).write_text(json.dumps('
+ + "{'yolo': approval._YOLO_MODE_FROZEN, 'sentinel': os.environ.get('RUNTIME_TEST_SENTINEL')}))\n",
+ encoding='utf-8',
+ )
+ executable.chmod(0o700)
+ monkeypatch.setattr(sys, 'executable', str(executable))
+ monkeypatch.setenv('HERMES_YOLO_MODE', '1')
+ monkeypatch.setenv('RUNTIME_TEST_SENTINEL', 'retained')
+ child = start.spawn_unmanaged_gateway(home, deadline=time.monotonic() + 5)
+ try:
+ assert child.wait(timeout=10) == 0
+ finally:
+ if child.poll() is None:
+ child.kill()
+ child.wait(timeout=5)
+ assert json.loads(witness.read_text()) == {'yolo': False, 'sentinel': 'retained'}
+ assert os.environ['HERMES_YOLO_MODE'] == '1'
+
+
@pytest.mark.linux_only
def test_reserved_profile_without_pid_or_control_is_never_absent(tmp_path):
from gateway.runtime_ownership import ProfileOwnership