The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: main's CLI ledger warning, lazy-install gate and MCP session overlay under the unified runtime
teknium18549d7e02510
diff --git a/hermes_cli/config.py b/hermes_cli/config.pyindex 95cb1e75aac..adf44ade719 100644--- a/hermes_cli/config.py+++ b/hermes_cli/config.py@@ -2024,6 +2024,12 @@ def require_readable_config_before_write(config_path: Optional[Path] = None) ->non-mapping root — bare-``except`` loaders treat both as ``{}``, so a subsequent write wouldreplace the recoverable file with only the caller's partial dict. Fails closed."""if config_path is None:+ from agent.safe_worker_policy import worker_config_snapshot++ snapshot = worker_config_snapshot()+ if snapshot is not None:+ # A bypass worker's config IS its frozen snapshot; it never reads the profile file.+ return copy.deepcopy(snapshot)config_path = get_config_path()try:config_path.stat()diff --git a/hermes_cli/gateway_chat.py b/hermes_cli/gateway_chat.pyindex d523cd8f22d..d69c09da0b6 100644--- a/hermes_cli/gateway_chat.py+++ b/hermes_cli/gateway_chat.py@@ -171,6 +171,18 @@ def check_resume_policy(args, snapshot):raise GatewayClientError(_RESUME_POLICY_MISMATCH)+def _register_terminal_process() -> None:+ """The chat client is still a terminal on this HERMES_HOME: record it in the process ledger+ (purpose ``cli`` is never update-reapable) and warn once when another install shares the home."""+ from hermes_cli.process_identity import register_self+ from hermes_cli.shared_profile_warning import shared_profile_warning++ register_self("cli")+ warning = shared_profile_warning()+ if warning:+ print(f"Warning: {warning}", file=sys.stderr)++def launch_from_args(args) -> int:from websockets.exceptions import WebSocketExceptionemitter = None@@ -188,6 +200,7 @@ def launch_from_args(args) -> int:try:validate_options(args)+ _register_terminal_process()from hermes_cli.gateway_chat_startup import ensure_launch_providerif emitter is None:if not ensure_launch_provider(args):diff --git a/tests/hermes_cli/test_shared_profile_warning.py b/tests/hermes_cli/test_shared_profile_warning.pyindex bad1230ff19..a591dac1349 100644--- a/tests/hermes_cli/test_shared_profile_warning.py+++ b/tests/hermes_cli/test_shared_profile_warning.py@@ -74,7 +74,7 @@ def test_warning_tracks_live_other_install_in_same_home(homes, tmp_path):@contextmanagerdef running_cli(home: Path, install: Path):- """Run the real CLI constructor and entrypoint; stop at terminal interaction."""+ """Run the real CLI entrypoint (the gateway chat client); stop at terminal interaction."""env = dict(os.environ, HERMES_HOME=str(home), HOME=str(home.parent), USERPROFILE=str(home.parent))for key in ("HERMES_SPAWN", "HERMES_PARENT_PID", "HERMES_PARENT_START_MARKER"):env.pop(key, None)@@ -85,14 +85,16 @@ import hermes_constants# Model two installed runtime roots without copying the source tree.hermes_constants.PROJECT_ROOT = Path(sys.argv[1])import cli+import hermes_cli.gateway_chat as gateway_chat-def terminal_boundary(self):+async def terminal_boundary(args, emitter=None):print('cli-ready', flush=True)sys.stdin.readline()+ return 0-cli.HermesCLI.run = terminal_boundary-cli.main(model='test-model', provider='openai', api_key='test-only',- base_url='http://127.0.0.1:1/v1', toolsets='none', ignore_rules=True)+gateway_chat.run_gateway_chat = terminal_boundary+cli.main(query='probe', model='test-model', provider='openai', api_key='test-only',+ base_url='http://127.0.0.1:1/v1', toolsets='none')"""output = {}child = subprocess.Popen(diff --git a/tests/hermes_cli/test_update_head_moved_gate.py b/tests/hermes_cli/test_update_head_moved_gate.pyindex d48ebc96a0f..02917bccea0 100644--- a/tests/hermes_cli/test_update_head_moved_gate.py+++ b/tests/hermes_cli/test_update_head_moved_gate.py@@ -76,19 +76,7 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):monkeypatch.setattr(hermes_main, "_resume_windows_gateways_after_update", lambda *a, **k: None)- from hermes_cli import update_cmd_fleet, update_inventory, update_receipt-- monkeypatch.setattr(- update_inventory, "collect_runtime_inventory",- lambda: update_inventory.UpdatePlan(install_method="git", profiles=[], runtimes=[]),- )- monkeypatch.setattr(update_receipt, "collect_fleet_versions", lambda **kwargs: [])- monkeypatch.setattr(- update_cmd_fleet, "_restart_macos_launchd_gateways", lambda *a, **k: None,- )- # These tests own only the HEAD gate, not installers or profile maintenance.- monkeypatch.setattr(update_cmd, "_sync_python_dependencies_after_pull", lambda *a, **k: None)- monkeypatch.setattr(update_cmd, "_run_post_update_maintenance", lambda **kwargs: True)+ # Short-circuit the long tail: dependency install + desktop build.monkeypatch.setattr(hermes_main, "_write_update_incomplete_marker", lambda: None)monkeypatch.setattr(hermes_main, "_clear_update_incomplete_marker", lambda: None)monkeypatch.setattr(main_install_repair, "_clear_update_incomplete_marker", lambda: None)@@ -99,9 +87,8 @@ def _patch_update_deps(monkeypatch, tmp_path, run_side_effect):# unsupported, so the phase is a clean no-op for both snapshots.import hermes_cli.gateway as hermes_gateway- monkeypatch.setattr(hermes_gateway, "_get_service_pids", lambda **kwargs: set())monkeypatch.setattr(- hermes_gateway, "find_gateway_pids", lambda **kwargs: []+ hermes_gateway, "find_gateway_pids", lambda all_profiles=False: [])monkeypatch.setattr(hermes_gateway, "supports_systemd_services", lambda: Falsediff --git a/tools/registry.py b/tools/registry.pyindex 6a941d52a6e..62dd9f1fc1b 100644--- a/tools/registry.py+++ b/tools/registry.py@@ -41,6 +41,12 @@ def current_session_tool_scope():return _session_tool_scope.get()+def _session_slot_key():+ """The overlay slot key for the current session scope: writes go through ``normalize_scope``+ (``register``/``deregister``), so reads must key the same way or the overlay is invisible."""+ return normalize_scope(_session_tool_scope.get())++# Cap on a tool error body; only trims runaway interpolated exceptions (static msgs are ~115 chars)._MAX_TOOL_ERROR_CHARS = 2048_TOOL_ERROR_TRUNCATION_MARKER = "… [truncated]"@@ -500,7 +506,7 @@ class ToolRegistry:"""Return global tools overlaid with one profile's plugin tools."""entries = {**self._tools, **self._scoped_tools.get(hermes_home_key(scope), {})}if scope is None:- entries.update(self._scoped_tools.get(current_session_tool_scope(), {}))+ entries.update(self._scoped_tools.get(_session_slot_key(), {}))return entriesdef _toolset_entries(self, toolset: str, scope: Optional[str]) -> List[ToolEntry]:@@ -536,7 +542,7 @@ class ToolRegistry:"""``_merged_tools(scope).get(name)`` without building the merged dict. An implicit scope(the caller passed none) also sees the current session's tool overlay, as the merge does."""if not explicit_scope:- session_scoped = self._scoped_tools.get(current_session_tool_scope())+ session_scoped = self._scoped_tools.get(_session_slot_key())if session_scoped is not None and name in session_scoped:return session_scoped[name]scoped = self._scoped_tools.get(scope_key)