Skip to content

The agent that grows with you

fix(gateway): declare config_warning on session.create's snapshot info

unsupportedpastels07e603e092c7
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index edfcf0f8317..e396fbc1a04 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -4960,6 +4960,7 @@ export interface CanonicalSnapshotInfo {
api_mode?: string | null
tool_count?: number | null
credential_hint?: string | null
+ config_warning?: string | null
}
export interface CanonicalResumeParams {
profile?: string | null
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index 8e4ed54657a..cf1695a543c 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -10923,6 +10923,18 @@
],
"default": null,
"title": "Credential Hint"
+ },
+ "config_warning": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "title": "Config Warning"
}
},
"required": [
diff --git a/tests/gateway/test_project_plugins_warning.py b/tests/gateway/test_project_plugins_warning.py
index 0d92f6f2c15..efb998e29ff 100644
--- a/tests/gateway/test_project_plugins_warning.py
+++ b/tests/gateway/test_project_plugins_warning.py
@@ -61,6 +61,35 @@ async def test_an_opted_in_session_is_told_project_plugins_do_not_load(tmp_path,
owner.db.close()
+async def test_session_create_carries_the_notice_through_its_strict_wire_contract(tmp_path, monkeypatch):
+ """The notice also rides the snapshot ``session.create`` returns: it must pass that method's declared
+ result contract (strict here, as under ``HERMES_TEST_ISOLATION``), for both session-start notices."""
+ from tui_gateway.contracts import registry
+ monkeypatch.setattr(registry, 'STRICT', True)
+ home, repo = tmp_path / 'home', tmp_path / 'repo'
+ home.mkdir()
+ (home / 'config.yaml').write_text(
+ 'platform_toolsets: {cli: []}\nmodel: {provider: custom, default: m, base_url: http://x.invalid/v1}\n')
+ (repo / '.hermes' / 'plugins' / 'mine').mkdir(parents=True)
+ monkeypatch.delenv('HERMES_ENABLE_PROJECT_PLUGINS', raising=False)
+ owner, connection = await _owner(home, monkeypatch)
+
+ async def create(request_id, local):
+ connection.native_owner = local # the gateway's own ticketed attach, or a remote client
+ reply = await connection.dispatch({'id': 1, 'method': 'session.create', 'params': {
+ 'request_id': request_id, 'source': 'cli', 'cwd': str(repo), 'toolsets': [],
+ 'client_env': {'HERMES_ENABLE_PROJECT_PLUGINS': '1'}}})
+ assert 'result' in reply, reply
+ return reply['result']['info'].get('config_warning') or ''
+ try:
+ assert 'not loaded' in await create('local', True)
+ assert 'not attached to this gateway locally' in await create('remote', False)
+ finally:
+ await connection.close()
+ owner.db.close()
+
+
@pytest.mark.asyncio
async def test_an_unlistable_plugins_folder_never_blocks_the_session(tmp_path, monkeypatch):
"""``is_dir`` can pass while listing fails (no read permission): the optional notice is skipped and
diff --git a/tui_gateway/contracts/canonical_sessions.py b/tui_gateway/contracts/canonical_sessions.py
index 225ad99c473..947c756bb2b 100644
--- a/tui_gateway/contracts/canonical_sessions.py
+++ b/tui_gateway/contracts/canonical_sessions.py
@@ -118,6 +118,8 @@ class CanonicalSnapshotInfo(SessionInventoryFields):
api_mode: str | None = None
tool_count: int | None = None
credential_hint: str | None = None
+ # ``session.info``'s session-start notice: ``session.create`` returns the same projection.
+ config_warning: str | None = None
class CanonicalSnapshot(Result):