Skip to content

The agent that grows with you

refactor(cli): health clean for the TOOLS lane seams; behaviour unchanged

Teknium82d390781bf0
diff --git a/hermes_cli/cli_status_bar_mixin.py b/hermes_cli/cli_status_bar_mixin.py
index 89a92e28de9..80be27e52d3 100644
--- a/hermes_cli/cli_status_bar_mixin.py
+++ b/hermes_cli/cli_status_bar_mixin.py
@@ -273,18 +273,8 @@ class CLIStatusBarMixin:
except Exception:
pass
try:
- from hermes_cli.gateway_tools import process_registry
- snapshot["active_background_processes"] = process_registry().count_running()
- except Exception:
- pass
- try:
- from hermes_cli.gateway_tools import process_view
- _view = process_view()
- if _view is not None:
- snapshot["active_background_subagents"] = _view.active_delegations()
- else:
- from tools.async_delegation import active_count as _async_active_count
- snapshot["active_background_subagents"] = _async_active_count()
+ from hermes_cli.gateway_tools import background_counts
+ snapshot.update(background_counts())
except Exception:
pass
diff --git a/hermes_cli/gateway_tools.py b/hermes_cli/gateway_tools.py
index 4fe783bc331..247318d482c 100644
--- a/hermes_cli/gateway_tools.py
+++ b/hermes_cli/gateway_tools.py
@@ -157,6 +157,17 @@ def process_registry():
return local
+def background_counts():
+ """The status bar's ``⚙ N`` processes and running background subagents (cached, no RPC)."""
+ view = process_view()
+ if view is not None:
+ return {"active_background_processes": view.count_running(),
+ "active_background_subagents": view.active_delegations()}
+ from tools.async_delegation import active_count
+ from tools.process_registry import process_registry as local
+ return {"active_background_processes": local.count_running(), "active_background_subagents": active_count()}
+
+
def session_tools():
"""``/tools`` / ``/initiate-setup``: the gateway session's tool catalog (``tools.show``) as
``(tools, toolset_of)``: ``get_tool_definitions``-shaped rows (first description sentence) and
diff --git a/hermes_cli/main.py b/hermes_cli/main.py
index 6e18f7f941c..e0ba3461f89 100644
--- a/hermes_cli/main.py
+++ b/hermes_cli/main.py
@@ -2956,12 +2956,10 @@ def _prepare_agent_startup(args) -> None:
logger.debug("MCP server filter setup failed", exc_info=True)
# TUI launches hand off to a startup path that backgrounds MCP discovery
- # with a bounded join; acp/gateway/cron do their own on the runtime path;
- # chat turns run in the gateway, which owns MCP for them.
- _run_inline_mcp_discovery = not (
- _is_tui_chat_launch(args) or _command_has_dedicated_mcp_startup(args)
- or _chat_runs_at_gateway(args)
- )
+ # with a bounded join; acp/gateway/cron do their own on the runtime path.
+ if _chat_runs_at_gateway(args): # chat turns run in the gateway: it owns MCP, hooks, webhooks
+ return
+ _run_inline_mcp_discovery = not (_is_tui_chat_launch(args) or _command_has_dedicated_mcp_startup(args))
if _run_inline_mcp_discovery and _should_background_mcp_startup(args):
try:
from hermes_cli.mcp_startup import start_background_mcp_discovery
@@ -2991,10 +2989,6 @@ def _prepare_agent_startup(args) -> None:
"MCP tool discovery failed at CLI startup",
exc_info=True,
)
- if _chat_runs_at_gateway(args):
- # Shell hooks and outbound webhooks fire where the tools run: the gateway session registers
- # them from its policy (``accept_hooks`` rides on session.create).
- return
try:
from hermes_cli.config import load_config
from agent.shell_hooks import register_from_config