fix: expand legacy Hermes CLI toolset alias

This commit is contained in:
Michael Lam
2026-05-15 13:08:22 -07:00
parent 2170846031
commit 2fdc1d99e2
2 changed files with 54 additions and 2 deletions
+24 -2
View File
@@ -596,6 +596,28 @@ _DEFAULT_TOOLSETS = [
"web",
"webhook",
]
_LEGACY_CLI_TOOLSET_ALIASES = {
# Older Hermes configs used "hermes" as the CLI composite toolset. Modern
# Hermes Agent exposes that split as these two registered composites; keep
# WebUI sessions usable when pointed at an older shared config.yaml.
"hermes": ("hermes-cli", "hermes-api-server"),
}
def _normalize_cli_toolsets(toolsets):
"""Expand legacy CLI toolset aliases while preserving order and de-duping."""
normalized = []
seen = set()
for name in toolsets or []:
replacements = _LEGACY_CLI_TOOLSET_ALIASES.get(name, (name,))
for replacement in replacements:
if replacement and replacement not in seen:
seen.add(replacement)
normalized.append(replacement)
return normalized
def _resolve_cli_toolsets(cfg=None):
"""Resolve CLI toolsets using the agent's _get_platform_tools() so that
MCP server toolsets are automatically included, matching CLI behaviour."""
@@ -603,10 +625,10 @@ def _resolve_cli_toolsets(cfg=None):
cfg = get_config()
try:
from hermes_cli.tools_config import _get_platform_tools
return list(_get_platform_tools(cfg, "cli"))
return _normalize_cli_toolsets(_get_platform_tools(cfg, "cli"))
except Exception:
# Fallback: read raw list from config (MCP toolsets will be missing)
return cfg.get("platform_toolsets", {}).get("cli", _DEFAULT_TOOLSETS)
return _normalize_cli_toolsets(cfg.get("platform_toolsets", {}).get("cli", _DEFAULT_TOOLSETS))
CLI_TOOLSETS = _resolve_cli_toolsets()
+30
View File
@@ -0,0 +1,30 @@
"""Regression coverage for issue #2232 legacy CLI toolset aliases."""
from unittest import mock
def test_normalize_cli_toolsets_expands_legacy_hermes_alias():
from api.config import _normalize_cli_toolsets
assert _normalize_cli_toolsets(["hermes", "web"]) == [
"hermes-cli",
"hermes-api-server",
"web",
]
def test_normalize_cli_toolsets_deduplicates_expanded_aliases():
from api.config import _normalize_cli_toolsets
assert _normalize_cli_toolsets(["hermes", "hermes-cli", "hermes-api-server"]) == [
"hermes-cli",
"hermes-api-server",
]
def test_resolve_cli_toolsets_fallback_expands_legacy_hermes_alias():
import api.config as config
cfg = {"platform_toolsets": {"cli": ["hermes", "web"]}}
with mock.patch("builtins.__import__", side_effect=ImportError("no hermes cli")):
assert config._resolve_cli_toolsets(cfg) == ["hermes-cli", "hermes-api-server", "web"]