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",