The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(gateway): a classic CLI session's snapshot carries main's startup tool warnings
Teknium6f9cc7132738
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex b742e1b9b22..389eba7cb98 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -4531,6 +4531,8 @@ export interface CanonicalSessionInfo {context_length?: number | nullenabled_toolsets?: string[] | nulltool_availability?: Record<string, unknown> | null+ tool_availability_warnings?: string[] | null+ browser_backend_notice?: string | nullsource: stringmodel?: string | nulllazy: boolean@@ -4839,6 +4841,8 @@ export interface CanonicalSnapshotInfo {context_length?: number | nullenabled_toolsets?: string[] | nulltool_availability?: Record<string, unknown> | null+ tool_availability_warnings?: string[] | null+ browser_backend_notice?: string | nulldesktop_protocol: 'hermes-gateway-v1'source?: string | nullmodel?: string | nulldiff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 050946e1076..e50df09142a 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -9921,6 +9921,33 @@"default": null,"title": "Tool Availability"},+ "tool_availability_warnings": {+ "anyOf": [+ {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Tool Availability Warnings"+ },+ "browser_backend_notice": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Browser Backend Notice"+ },"source": {"title": "Source","type": "string"@@ -10457,6 +10484,33 @@"default": null,"title": "Tool Availability"},+ "tool_availability_warnings": {+ "anyOf": [+ {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Tool Availability Warnings"+ },+ "browser_backend_notice": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Browser Backend Notice"+ },"desktop_protocol": {"const": "hermes-gateway-v1","title": "Desktop Protocol",diff --git a/gateway/session_local_inventory.py b/gateway/session_local_inventory.pyindex af2725843b0..e12fa9c4da1 100644--- a/gateway/session_local_inventory.py+++ b/gateway/session_local_inventory.py@@ -73,6 +73,28 @@ def _project(cwd):"id": project.id, "slug": project.slug, "name": project.name, "primary_path": project.primary_path}+def _cli_startup_notices(enabled):+ """The lines main's HermesCLI printed under its banner, computed where the tools run: the toolset+ availability warning (``cli.py::_show_tool_availability_warnings``) and the Browser Use downgrade+ notice (``_show_browser_backend_notice``). The classic CLI renders them with its own console."""+ notices: dict = {"tool_availability_warnings": [], "browser_backend_notice": None}+ with contextlib.suppress(Exception):+ from hermes_cli.tool_availability_notices import (+ current_terminal_backend, filter_to_enabled_toolsets, tool_availability_warning_lines)+ from model_tools import check_tool_availability+ from tools.terminal_tool import terminal_backend_unavailable_reason+ from toolsets import resolve_toolset+ _, unavailable = check_tool_availability()+ unavailable = filter_to_enabled_toolsets(unavailable, enabled or [], resolve_toolset)+ notices["tool_availability_warnings"] = tool_availability_warning_lines(+ unavailable, terminal_reason=terminal_backend_unavailable_reason(),+ terminal_backend=current_terminal_backend())+ with contextlib.suppress(Exception):+ from tools.browser_use_cli import default_downgrade_notice+ notices["browser_backend_notice"] = default_downgrade_notice()+ return notices++def session_inventory(authority, policy, agent, cwd):"""Main's banner/status fields for one session. Each section degrades to main's empty value onits own, so one failing builder never blanks the others (main wrapped each in ``suppress``)."""@@ -107,6 +129,8 @@ def session_inventory(authority, policy, agent, cwd):# The classic CLI banner colours lazy (yellow) / disabled (red) tools from this.from hermes_cli.banner import compute_toolset_availabilityinfo["tool_availability"] = compute_toolset_availability(enabled)+ if policy is not None and policy.source == "cli":+ info.update(_cli_startup_notices(enabled))with contextlib.suppress(Exception):from hermes_cli.banner import get_available_skillsinfo["skills"] = get_available_skills()diff --git a/tests/gateway/test_canonical_session_inventory.py b/tests/gateway/test_canonical_session_inventory.pyindex 2daa7377202..c71bbf02d1c 100644--- a/tests/gateway/test_canonical_session_inventory.py+++ b/tests/gateway/test_canonical_session_inventory.py@@ -74,3 +74,45 @@ async def test_created_session_snapshot_carries_inventory_for_frozen_toolsets(tmnarrowed = await call('session.create', request_id='narrow', source='cli', cwd=str(repo), toolsets=['terminal'])assert set(narrowed['info']['tools']) - {'other'} == {'terminal'}, narrowed['info']['tools']+++async def test_cli_surface_snapshot_carries_main_cli_toolsets_and_startup_warnings(tmp_path, monkeypatch, repo):+ """``source: cli`` is the classic CLI surface: exactly main's ``_get_platform_tools(cfg, 'cli')`` and+ the warnings main's HermesCLI printed under its banner, computed in the process that runs the tools."""+ from gateway import run+ from gateway.config import GatewayConfig+ from gateway.session import SessionStore+ from gateway.session_authority import initialize_session_authority+ from gateway.session_controls import AuthorityConnection+ from hermes_cli import banner+ from hermes_cli.tools_config import _get_platform_tools+ from tools import browser_use_cli++ home = tmp_path / 'home'+ home.mkdir()+ (home / 'config.yaml').write_text(+ 'model: {default: gpt-5.4, provider: custom, base_url: "http://127.0.0.1:9/v1"}\n')+ monkeypatch.setenv('HERMES_HOME', str(home))+ monkeypatch.setattr(run, '_hermes_home', home)+ monkeypatch.setattr(banner, '_available_skills_cache', None)+ monkeypatch.setattr(browser_use_cli, 'default_downgrade_notice', lambda: 'browser-harness is missing')+ store = SessionStore(tmp_path / 'sessions', GatewayConfig())+ runner = SimpleNamespace(session_store=store, _session_db=store._db, adapters={}, _draining=False,+ _cached_agent_for=lambda route: None)+ runner._adapter_for_source = lambda source: runner.adapters.get(source.platform)+ authority = await initialize_session_authority(runner, profile_id=str(home), instance_id='first')+ connection = AuthorityConnection(authority, object(), {'user_id': 'human'})++ async def call(method, **params):+ reply = await connection.dispatch({'id': 1, 'method': method, 'params': params})+ assert 'result' in reply, reply+ return reply['result']++ from hermes_cli.config import load_config+ cli = (await call('session.create', request_id='cli', source='cli', cwd=str(repo)))['info']+ assert cli['enabled_toolsets'] == sorted(_get_platform_tools(load_config(), 'cli'))+ assert isinstance(cli['tool_availability_warnings'], list)+ assert cli['browser_backend_notice'] == 'browser-harness is missing'+ tui = (await call('session.create', request_id='tui', source='tui', cwd=str(repo)))['info']+ assert 'tool_availability_warnings' not in tui and 'browser_backend_notice' not in tuidiff --git a/tui_gateway/contracts/canonical.py b/tui_gateway/contracts/canonical.pyindex e43917e19f6..0cd561a3433 100644--- a/tui_gateway/contracts/canonical.py+++ b/tui_gateway/contracts/canonical.py@@ -148,6 +148,9 @@ class SessionInventoryFields(Result):context_length: int | None = Noneenabled_toolsets: list[str] | None = Nonetool_availability: dict[str, JsonValue] | None = None+ # Classic CLI surface (``source: cli``) only: main's startup lines under the banner (Rich markup).+ tool_availability_warnings: list[str] | None = None+ browser_backend_notice: str | None = Noneclass CanonicalSessionInfo(SessionInventoryFields, OpenModel):