The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(gateway): an explicit -t may name a configured MCP server before it connects
Teknium15528c6f4a06
diff --git a/gateway/session_policy.py b/gateway/session_policy.pyindex d3fdbf7319d..fead93eb761 100644--- a/gateway/session_policy.py+++ b/gateway/session_policy.py@@ -413,12 +413,15 @@ def _resolve_toolsets(params, config, source, safe_mode, coding_posture=False):*coding_posture* session runs ``focus_toolsets`` instead of the profile default while the profilestays on ``focus``; the gateway decides it, never the client."""from hermes_cli.tools_config import _get_platform_tools- from toolsets import validate_toolset+ from hermes_cli.toolset_validation import saved_toolset_resolverexplicit = params.get('toolsets')if 'toolsets' in params:if not isinstance(explicit, list):_refuse('toolsets', f'must be a list of toolset names, got {type(explicit).__name__}')- bad_toolset = next((x for x in explicit if not isinstance(x, str) or not validate_toolset(x)), None)+ # The CLI validator's rule: a configured MCP server's toolset registers only after its first+ # connect, so an offline server is inactive, not a typo (#138748, #139154).+ known = saved_toolset_resolver(config)+ bad_toolset = next((x for x in explicit if not isinstance(x, str) or not known(x)), None)if bad_toolset is not None:_refuse('toolsets', f'unknown or invalid toolset name: {bad_toolset!r}')if 'desktop_ui' in explicit and source != 'gui':diff --git a/tests/gateway/test_session_policy_refusal_fields.py b/tests/gateway/test_session_policy_refusal_fields.pyindex 29246d61956..1dc982f6142 100644--- a/tests/gateway/test_session_policy_refusal_fields.py+++ b/tests/gateway/test_session_policy_refusal_fields.py@@ -71,6 +71,17 @@ def test_an_invalid_toolset_name_reports_that_name(tmp_path):assert 'gone_plugin' in refusal.detail[email protected]('name', ['deadserver', 'mcp-deadserver'])+def test_an_explicit_pick_of_a_configured_mcp_server_builds_before_it_connects(tmp_path, name):+ """`hermes chat -t terminal,<server>` names a configured MCP server whose toolset registers only+ after its first connect; an offline server is inactive, not a typo (#138748, #139154). The gateway+ accepts what the CLI's own validator accepts, and the server's tools join when it connects."""+ cfg = {**_CFG, 'mcp_servers': {'deadserver': {'command': str(tmp_path / 'absent')}}}+ policy = build_policy({'source': 'cli', 'cwd': str(tmp_path), 'toolsets': ['terminal', name]}, cfg)+ assert name in policy.toolsets+ assert 'gone_plugin' in _refusal({'cwd': str(tmp_path), 'toolsets': ['terminal', 'gone_plugin']}, cfg).detail++def test_a_rebound_launch_key_names_api_key():"""``session.resume`` re-supplying a launch key refuses before it touches the authority."""with pytest.raises(RuntimeStoreError) as caught: