The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): `hermes chat --yolo` reaches the gateway as a per-session approval bypass
teknium10e5736dea519
diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.pyindex 5a3c397fe80..4412f0dddf0 100644--- a/gateway/run_turn_runner.py+++ b/gateway/run_turn_runner.py@@ -1005,6 +1005,9 @@ class TurnRunner(GatewayTurnProgressMixin, GatewaySessionAgentMixin):# removing this in-process gateway write does not affect any of them.from gateway.session_policy import policy_for_sourcepolicy = policy_for_source(runner, ctx.source)+ if policy and policy.yolo and ctx.session_key:+ from tools.approval import enable_session_yolo+ enable_session_yolo(ctx.session_key)platform_key = policy.platform if policy else ("cli" if ctx.source.platform == Platform.LOCAL else ctx.source.platform.value)combined_ephemeral = self._combined_ephemeral_prompt()max_iterations = policy.max_turns if policy else _current_max_iterations()diff --git a/gateway/session_policy.py b/gateway/session_policy.pyindex f4b58087081..2ab9d5be9da 100644--- a/gateway/session_policy.py+++ b/gateway/session_policy.py@@ -8,7 +8,7 @@ from hermes_state_runtime import RuntimeStoreErrorCREATE_FIELDS = frozenset({'request_id', 'source', 'cwd', 'model', 'toolsets','provider', 'base_url', 'reasoning', 'max_turns', 'ignore_rules', 'api_key', 'editor',- 'safe_mode', 'ignore_user_config'})+ 'yolo', 'safe_mode', 'ignore_user_config'})BYPASS_FIELDS = ('safe_mode', 'ignore_user_config')SURFACES = {'cli': 'cli', 'tui': 'tui', 'gui': 'desktop', 'acp': 'acp'}@@ -58,6 +58,12 @@ class LocalSessionPolicy:def ignore_rules(self):return self.safe_mode or json.loads(self.request_json).get('ignore_rules', False)+ @property+ def yolo(self):+ """`hermes chat --yolo`: this session's dangerous-command approvals are bypassed, exactly the+ scope `/yolo` gives a messaging chat; never the process-wide HERMES_YOLO_MODE."""+ return json.loads(self.request_json).get('yolo', False)+@propertydef max_turns(self):from hermes_cli.config import resolve_turn_limit@@ -111,8 +117,9 @@ def build_policy(params, config, *, private_secrets=None, profile_terminal=True)or url.username or url.password or url.query or url.fragment):raise RuntimeStoreError('invalid_params')config.setdefault('model', {})[key] = value- if 'ignore_rules' in params and type(params['ignore_rules']) is not bool:- raise RuntimeStoreError('invalid_params')+ for flag in ('ignore_rules', 'yolo'):+ if flag in params and type(params[flag]) is not bool:+ raise RuntimeStoreError('invalid_params')if 'max_turns' in params:value = params['max_turns']if type(value) is not int or value <= 0:diff --git a/hermes_cli/gateway_chat.py b/hermes_cli/gateway_chat.pyindex d71d17b90a4..ebfc175cdf2 100644--- a/hermes_cli/gateway_chat.py+++ b/hermes_cli/gateway_chat.py@@ -15,13 +15,13 @@ from hermes_cli.gateway_client import GatewayClientError, connect_gateway# the authority. Reject them, rather than mutate process-wide gateway settings._UNSUPPORTED = ("image", "skills", "worktree", "w", "checkpoints", "pass_session_id",- "yolo", "accept_hooks",+ "accept_hooks","no_restore_cwd", "usage_file","run_budget", "verbose", "compact","list_tools", "list_toolsets",)_POLICY = ("model", "provider", "reasoning", "toolsets", "max_turns", "base_url", "ignore_rules", "api_key",- "safe_mode", "ignore_user_config")+ "yolo", "safe_mode", "ignore_user_config")# Where each refused option lives now; the refusal names it so the user is not left guessing._RELOCATED = {"image": "attach the image in `hermes --tui` or the Desktop app",@@ -30,7 +30,6 @@ _RELOCATED = {"w": "`hermes --tui -w`","checkpoints": "`checkpoints.enabled: true` in config.yaml, or `hermes --tui --checkpoints`","pass_session_id": "`hermes --tui --pass-session-id`",- "yolo": "`approvals.mode: off` in config.yaml, or `/yolo` inside the session","accept_hooks": "`hooks_auto_accept: true` in config.yaml, or `hermes --tui --accept-hooks`","no_restore_cwd": "`--in <dir>` (the gateway keeps the session's frozen cwd)","usage_file": "`hermes sessions stats` / `hermes insights` after the run",diff --git a/tests/hermes_cli/test_gateway_chat.py b/tests/hermes_cli/test_gateway_chat.pyindex 5dea52ae582..03b15b959b5 100644--- a/tests/hermes_cli/test_gateway_chat.py+++ b/tests/hermes_cli/test_gateway_chat.py@@ -8,7 +8,7 @@ def test_unsupported_launch_options_fail_before_connection(monkeypatch, capsys):from hermes_cli import gateway_chatcalls = []monkeypatch.setattr(gateway_chat, "connect_gateway", lambda: calls.append(True))- for option in ("yolo", "worktree", "usage_file", "run_budget"):+ for option in ("checkpoints", "worktree", "usage_file", "run_budget"):args = argparse.Namespace(**{option: True})assert gateway_chat.launch_from_args(args) == 2assert option.replace("_", "-") in capsys.readouterr().err@@ -32,9 +32,9 @@ def test_refusals_name_the_replacement_and_a_runnable_safe_mode_example(monkeyparefusal prints a command they can run as-is."""from hermes_cli import gateway_chatmonkeypatch.setattr(gateway_chat, "connect_gateway", lambda: pytest.fail("connected"))- assert gateway_chat.launch_from_args(argparse.Namespace(yolo=True, run_budget=30.0)) == 2+ assert gateway_chat.launch_from_args(argparse.Namespace(checkpoints=True, run_budget=30.0)) == 2err = capsys.readouterr().err- assert "--yolo: use" in err and "approvals.mode" in err+ assert "--checkpoints: use" in err and "checkpoints.enabled" in errassert "--run-budget: use" in err and "run_budget_seconds" in errfor name in gateway_chat._UNSUPPORTED:assert name in gateway_chat._RELOCATED, f"{name} refused without saying where it went"