From 96051955755a83f22afed5e3501d447462fbe9c8 Mon Sep 17 00:00:00 2001 From: Teknium Date: Fri, 10 Apr 2026 18:55:28 -0700 Subject: [PATCH] fix: restore agent.close() cleanup and correct /restart category - Add agent.close() call to _finalize_shutdown_agents() to prevent zombie processes (terminal sandboxes, browser daemons, httpx clients) - Global cleanup (process_registry, environments, browsers) preserved in _stop_impl() during conflict resolution - Move /restart CommandDef from 'Info' to 'Session' category to match /stop and /status --- gateway/run.py | 8 ++++++++ hermes_cli/commands.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gateway/run.py b/gateway/run.py index b370060fc..bf5103d12 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -1275,6 +1275,14 @@ class GatewayRunner: agent.shutdown_memory_provider() except Exception: pass + # Close tool resources (terminal sandboxes, browser daemons, + # background processes, httpx clients) to prevent zombie + # process accumulation. + try: + if hasattr(agent, 'close'): + agent.close() + except Exception: + pass async def _launch_detached_restart_command(self) -> None: import shutil diff --git a/hermes_cli/commands.py b/hermes_cli/commands.py index 7cf8f3052..7abadca61 100644 --- a/hermes_cli/commands.py +++ b/hermes_cli/commands.py @@ -140,7 +140,7 @@ COMMAND_REGISTRY: list[CommandDef] = [ CommandDef("commands", "Browse all commands and skills (paginated)", "Info", gateway_only=True, args_hint="[page]"), CommandDef("help", "Show available commands", "Info"), - CommandDef("restart", "Gracefully restart the gateway after draining active runs", "Info", + CommandDef("restart", "Gracefully restart the gateway after draining active runs", "Session", gateway_only=True), CommandDef("usage", "Show token usage and rate limits for the current session", "Info"), CommandDef("insights", "Show usage insights and analytics", "Info",