Skip to content

The agent that grows with you

fix(tui): --ignore-rules stays scoped to its own TUI session

Teknium4c59232b1c05
diff --git a/hermes_cli/gateway_runtime_start.py b/hermes_cli/gateway_runtime_start.py
index 3ba95e0fdb4..5fb901a8fe1 100644
--- a/hermes_cli/gateway_runtime_start.py
+++ b/hermes_cli/gateway_runtime_start.py
@@ -33,9 +33,11 @@ def spawn_unmanaged_gateway(profile_home: Path, *, deadline: float) -> subproces
env[_WINDOWS_GATEWAY_BREAKAWAY_ENV] = "1"
env.update(HERMES_HOME=str(home), HERMES_GATEWAY_DETACHED="1", PYTHONIOENCODING="utf-8")
# Profile selection is the explicit home, not the invoking client's display
- # name. Runtime policy comes from that profile, never a launcher's --yolo.
+ # name. Runtime policy comes from that profile, never a launcher's --yolo/--ignore-rules
+ # (those ride the launching session's frozen policy, not every later session's daemon).
env.pop("HERMES_PROFILE", None)
env.pop("HERMES_YOLO_MODE", None)
+ env.pop("HERMES_IGNORE_RULES", 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 dff06557244..8c41d070fba 100644
--- a/tests/hermes_cli/test_gateway_runtime_ensure.py
+++ b/tests/hermes_cli/test_gateway_runtime_ensure.py
@@ -202,7 +202,9 @@ def test_unmanaged_child_uses_explicit_home_and_survives_launcher_exit(tmp_path,
@pytest.mark.platforms("linux")
@pytest.mark.spawns_gateway_lookalike # stub interpreter records env then exits; reaped below
-def test_unmanaged_runtime_does_not_inherit_client_yolo(tmp_path, monkeypatch):
+def test_unmanaged_runtime_does_not_inherit_client_launch_flags(tmp_path, monkeypatch):
+ # --yolo / --ignore-rules are frozen on the launching session's policy; inherited by the
+ # daemon they would bypass approvals or skip skills.auto_load for every later session.
from hermes_cli import gateway_runtime_start as start
home = tmp_path / 'policy-home'
@@ -215,12 +217,14 @@ def test_unmanaged_runtime_does_not_inherit_client_yolo(tmp_path, monkeypatch):
+ 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",
+ + "{'yolo': approval._YOLO_MODE_FROZEN, 'ignore_rules': os.environ.get('HERMES_IGNORE_RULES'),"
+ + " '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('HERMES_IGNORE_RULES', '1')
monkeypatch.setenv('RUNTIME_TEST_SENTINEL', 'retained')
child = start.spawn_unmanaged_gateway(home, deadline=time.monotonic() + 5)
try:
@@ -229,8 +233,8 @@ def test_unmanaged_runtime_does_not_inherit_client_yolo(tmp_path, monkeypatch):
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'
+ assert json.loads(witness.read_text()) == {'yolo': False, 'ignore_rules': None, 'sentinel': 'retained'}
+ assert os.environ['HERMES_YOLO_MODE'] == os.environ['HERMES_IGNORE_RULES'] == '1'
@pytest.mark.platforms("linux")
diff --git a/ui-tui/src/__tests__/canonicalGateway.test.ts b/ui-tui/src/__tests__/canonicalGateway.test.ts
index 9b6031a7d64..a1560e9c12a 100644
--- a/ui-tui/src/__tests__/canonicalGateway.test.ts
+++ b/ui-tui/src/__tests__/canonicalGateway.test.ts
@@ -24,3 +24,9 @@ it('carries `hermes --tui --yolo` (HERMES_YOLO_MODE) onto session.create as the
expect(localCreationOptions({ HERMES_YOLO_MODE: '0' } as NodeJS.ProcessEnv)).not.toHaveProperty('yolo')
expect(localCreationOptions({} as NodeJS.ProcessEnv)).not.toHaveProperty('yolo')
})
+
+it('carries `hermes --tui --ignore-rules` (HERMES_IGNORE_RULES) onto session.create as the frozen launch flag', () => {
+ expect(localCreationOptions({ HERMES_IGNORE_RULES: '1' } as NodeJS.ProcessEnv).ignore_rules).toBe(true)
+ expect(localCreationOptions({ HERMES_IGNORE_RULES: '0' } as NodeJS.ProcessEnv)).not.toHaveProperty('ignore_rules')
+ expect(localCreationOptions({} as NodeJS.ProcessEnv)).not.toHaveProperty('ignore_rules')
+})
diff --git a/ui-tui/src/canonicalGateway.ts b/ui-tui/src/canonicalGateway.ts
index f45a8ed276f..83c252c7e4f 100644
--- a/ui-tui/src/canonicalGateway.ts
+++ b/ui-tui/src/canonicalGateway.ts
@@ -90,9 +90,14 @@ export function localCreationOptions(env = process.env): Record<string, unknown>
// requires an int, so the environment's text form is undone here.
if (env.HERMES_TUI_MAX_TURNS) { options.max_turns = Number(env.HERMES_TUI_MAX_TURNS) }
- // `hermes --tui --yolo` exports HERMES_YOLO_MODE=1 (the in-process TUI read it); over the canonical
- // gateway it must ride session.create as the frozen launch flag or the session prompts anyway.
- if (['1', 'true', 'yes', 'on'].includes((env.HERMES_YOLO_MODE ?? '').trim().toLowerCase())) { options.yolo = true }
+ // `hermes --tui --yolo` / `--ignore-rules` export HERMES_YOLO_MODE / HERMES_IGNORE_RULES (the in-process
+ // TUI read them); over the canonical gateway they must ride session.create as frozen launch flags or the
+ // session prompts anyway / still loads rules, SOUL, memory and skills.auto_load.
+ const truthy = (value?: string) => ['1', 'true', 'yes', 'on'].includes((value ?? '').trim().toLowerCase())
+
+ if (truthy(env.HERMES_YOLO_MODE)) { options.yolo = true }
+
+ if (truthy(env.HERMES_IGNORE_RULES)) { options.ignore_rules = true }
return options
}