Skip to content

The agent that grows with you

feat(cli): main's startup tool warning and browser notice print from the gateway snapshot

Tekniumf09541a2e78e
diff --git a/hermes_cli/cli_info_mixin.py b/hermes_cli/cli_info_mixin.py
index d8431cc610c..064a315ed49 100644
--- a/hermes_cli/cli_info_mixin.py
+++ b/hermes_cli/cli_info_mixin.py
@@ -102,6 +102,7 @@ class CLIInfoMixin:
from hermes_cli.banner import build_welcome_banner
self.console.clear()
ctx_len = None
+ gateway_inventory = getattr(getattr(self, "_session_db", None), "banner_inventory", lambda: None)()
if hasattr(self, 'agent') and self.agent and hasattr(self.agent, 'context_compressor'):
ctx_len = self.agent.context_compressor.context_length
from agent.context_pin import is_context_pinned
@@ -128,7 +129,6 @@ class CLIInfoMixin:
enabled_toolsets=self.enabled_toolsets, session_id=self.session_id,
context_length=ctx_len, provider=self.provider, context_pinned=ctx_pinned)
- gateway_inventory = getattr(getattr(self, "_session_db", None), "banner_inventory", lambda: None)()
if gateway_inventory is not None:
from hermes_cli.gateway_session_store import session_label
# The gateway session's snapshot (the TUI banner's data): the CLI enumerates nothing.
@@ -181,7 +181,14 @@ class CLIInfoMixin:
# Tool discovery is deferred on the Termux bare prompt path (warnings show once tools
# init). On the snapshot fast path the check walks every check_fn (~180ms) — run it in
# the background and let its output land above the prompt (patch_stdout-safe).
- if os.environ.get("HERMES_DEFER_AGENT_STARTUP") != "1":
+ gateway_lines = (gateway_inventory or {}).get("tool_availability_warnings")
+ if isinstance(gateway_lines, list):
+ # The gateway resolved this session's tools: print main's warning lines from its snapshot.
+ if gateway_lines:
+ self._console_print()
+ for line in gateway_lines:
+ self._console_print(line)
+ elif os.environ.get("HERMES_DEFER_AGENT_STARTUP") != "1":
if getattr(self, "_defer_tool_warnings", False):
threading.Thread(
target=self._show_tool_availability_warnings,
diff --git a/hermes_cli/cli_tui_runtime_mixin.py b/hermes_cli/cli_tui_runtime_mixin.py
index e2186b49ce8..69278b7cccc 100644
--- a/hermes_cli/cli_tui_runtime_mixin.py
+++ b/hermes_cli/cli_tui_runtime_mixin.py
@@ -229,6 +229,18 @@ class CLITuiRuntimeMixin:
pass
raise KeyboardInterrupt() # fallback for non-prompt_toolkit contexts
+ def _show_startup_browser_notice(self):
+ """Main's ``_show_browser_backend_notice``; on a gateway session the gateway computed the notice
+ (and its once-per-24h stamp) with the session's tools, so it is printed from the snapshot."""
+ inventory = getattr(getattr(self, "_session_db", None), "banner_inventory", lambda: None)()
+ if inventory is None or "browser_backend_notice" not in inventory:
+ self._show_browser_backend_notice()
+ return
+ notice = inventory.get("browser_backend_notice")
+ if notice:
+ from gateway.warning_notifications import render_notification
+ render_notification(lambda: self._console_print(f"[yellow]⚠ {notice}[/yellow]"), platform="cli")
+
def _tui_print_startup(self):
"""Startup output: light-mode probe, banner, advisories, resume/welcome lines, tips."""
from cli import _accent_hex, _detect_light_mode
@@ -243,7 +255,7 @@ class CLITuiRuntimeMixin:
self._ensure_gateway_session() # the banner shows the gateway session's id and inventory
self.show_banner()
self._show_security_advisories()
- self._show_browser_backend_notice()
+ self._show_startup_browser_notice()
# First-run: an unconfigured install routes into provider onboarding instead of
# a chat that spins ~30s and fails with a provider-specific error. TTY only. A
diff --git a/hermes_cli/gateway_session_store.py b/hermes_cli/gateway_session_store.py
index 4de4fe8d0ba..ba32a0a81c1 100644
--- a/hermes_cli/gateway_session_store.py
+++ b/hermes_cli/gateway_session_store.py
@@ -213,6 +213,9 @@ class GatewaySessionStore:
"enabled_toolsets": info.get("enabled_toolsets"),
"context_length": info.get("context_length"),
"cwd": info.get("cwd"),
+ # Main's startup lines under the banner, computed in the gateway (``source: cli`` only).
+ "tool_availability_warnings": info.get("tool_availability_warnings"),
+ "browser_backend_notice": info.get("browser_backend_notice"),
}
diff --git a/tests/hermes_cli/test_gateway_session_store.py b/tests/hermes_cli/test_gateway_session_store.py
index c1ed5373e01..8ed657d72cb 100644
--- a/tests/hermes_cli/test_gateway_session_store.py
+++ b/tests/hermes_cli/test_gateway_session_store.py
@@ -134,3 +134,28 @@ def test_banner_session_label_is_mains_eight_characters_for_a_canonical_id():
assert session_label("20261012_134501_abcdef") == "20261012_134501_abcdef"
assert session_label("local-abc") == "local-abc"
assert session_label(None) is None
+
+
+def test_cli_startup_notices_render_from_the_snapshot(store, monkeypatch):
+ """Main's tool-availability warning and browser notice print from the gateway snapshot (the
+ gateway resolved the session's tools); the CLI process enumerates nothing."""
+ from types import SimpleNamespace
+
+ from hermes_cli.cli_info_mixin import CLIInfoMixin
+ from hermes_cli.cli_tui_runtime_mixin import CLITuiRuntimeMixin
+ db, _ = store
+ db.open_session(cli("local-old", resumed=True))
+ db.current["info"].update(tool_availability_warnings=["[yellow]⚠ terminal off[/]"],
+ browser_backend_notice="browser-harness is missing")
+ printed = []
+ host = SimpleNamespace(_session_db=db, _console_print=lambda *a: printed.append(a[0] if a else ""),
+ _show_browser_backend_notice=lambda: printed.append("LOCAL"))
+ CLITuiRuntimeMixin._show_startup_browser_notice(host)
+ assert printed == ["[yellow]⚠ browser-harness is missing[/yellow]"]
+ monkeypatch.setattr("cli._build_compact_banner", lambda: "compact", raising=False)
+ banner = SimpleNamespace(**vars(host), console=SimpleNamespace(clear=lambda: None), compact=True,
+ session_id="local-old", _show_status=lambda: None, agent=None,
+ _show_tool_availability_warnings=lambda: printed.append("LOCAL-WARN"))
+ printed.clear()
+ CLIInfoMixin.show_banner(banner)
+ assert "[yellow]⚠ terminal off[/]" in printed and "LOCAL-WARN" not in printed