The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): install the SDKs of configured gateway platforms instead of only warning (#124228)
teknium1a153adcc2e5f
diff --git a/hermes_cli/main_install_repair.py b/hermes_cli/main_install_repair.pyindex 7fc37b82acd..958701a52fb 100644--- a/hermes_cli/main_install_repair.py+++ b/hermes_cli/main_install_repair.py@@ -227,13 +227,14 @@ def _cleanup_quarantined_exes(scripts_dir: Path | None = None) -> None:pass # still locked or in use — try again next run-def _configured_features_missing_deps() -> list[tuple[str, str]]:+def _configured_features_missing_deps() -> list[tuple[str, str, str]]:"""Check configured platforms/MCP in the fresh, selected update-build child.PM preserves recorded extras atomically, but configuration can reference anunselected SDK. Never call this in the updater's stale import graph (#10651).+ Rows are ``(label, hint, candidate extra)``: a platform's SDK is the extra named after it."""- missing: list[tuple[str, str]] = []+ missing: list[tuple[str, str, str]] = []try:from gateway.config import load_gateway_configfrom gateway.platform_registry import platform_registry@@ -241,7 +242,8 @@ def _configured_features_missing_deps() -> list[tuple[str, str]]:for platform in load_gateway_config().get_connected_platforms():entry = platform_registry.get(platform.value)if entry is not None and not entry.check_fn():- missing.append((entry.label, entry.install_hint or "Run `hermes setup` to install support."))+ missing.append((entry.label, entry.install_hint or "Run `hermes setup` to install support.",+ entry.name))except Exception as exc:logger.debug("configured-platform dependency check skipped: %s", exc)try:@@ -249,17 +251,36 @@ def _configured_features_missing_deps() -> list[tuple[str, str]]:from hermes_cli.config import load_config_readonlyif (load_config_readonly().get("mcp_servers") or {}) and importlib.util.find_spec("mcp") is None:- missing.append(("MCP servers", "Run `hermes pm install` to install MCP support."))+ missing.append(("MCP servers", "Run `hermes pm install` to install MCP support.", "mcp"))except Exception as exc:logger.debug("configured-MCP dependency check skipped: %s", exc)return missing-def _warn_configured_features_missing_deps() -> None:+def _install_configured_features_missing_deps(project_root: Path) -> None:+ """Add the extras configured features need to the dependency environment (#124228).++ Recorded extras never follow config, so an enabled platform whose SDK is not+ selected would come up without its adapter after the gateway restart.+ """+ import pm+ from pm.extras import extra_supported+ from pm.features import declared_extras+missing = _configured_features_missing_deps()+ declared = set(declared_extras(project_root))+ extras = sorted({extra for *_, name in missing+ if (extra := name.replace("_", "-")) in declared and extra_supported(extra)})+ if extras:+ try:+ pm.sync_venv(extras, explicit=True, project_root=project_root, evict_incompatible_plugins=True)+ except Exception as exc: # noqa: BLE001 — a feature install never fails the update; warn below+ print(f" ⚠ Could not install {', '.join(extras)} for configured features: {exc}")+ else:+ missing = [row for row in missing if row[2].replace("_", "-") not in extras]if missing:print(" ⚠ Configured features whose dependencies are still missing — the gateway will fail to load them on restart:")- for feature, hint in missing:+ for feature, hint, _extra in missing:print(f" - {feature}: {hint}")diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.pyindex b6cccfb37cd..e9eae057937 100644--- a/hermes_cli/source_build.py+++ b/hermes_cli/source_build.py@@ -103,10 +103,10 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:"""Prepare the selected union once; a failed product aborts the update."""# Both current updates and historical takeover reach this in a fresh target# interpreter, never in the updater's pre-sync import graph.- from hermes_cli.main_install_repair import _warn_configured_features_missing_deps+ from hermes_cli.main_install_repair import _install_configured_features_missing_depsfrom hermes_cli.update_stage import publish_stage- _warn_configured_features_missing_deps()+ _install_configured_features_missing_deps(project_root)frontends = source_frontends(project_root)if not frontends:returndiff --git a/tests/e2e/core/upgrade/pm/test_configured_features.py b/tests/e2e/core/upgrade/pm/test_configured_features.pyindex 82d9721ac16..d24a24d3be4 100644--- a/tests/e2e/core/upgrade/pm/test_configured_features.py+++ b/tests/e2e/core/upgrade/pm/test_configured_features.py@@ -9,8 +9,8 @@ imports in the generation selected after it:* an extra the user installed with the documented command (``hermes pm install --extra telegram``);* the MCP client (an HTTP MCP server in config.yaml must still connect: ``hermes mcp test``against a real local streamable-HTTP server);-* a gateway platform enabled in config.yaml (Discord) — gated on #124228: PM never reads- ``platforms:`` from config, so the rebuilt environment has no SDK and the updater only warns;+* a gateway platform enabled in config.yaml (Discord): the update installs the platform's extra+ instead of only warning that the SDK is missing (#124228);* extras a main-era venv carried (``[all]`` plus ``[messaging]``) across thelegacy-venv migration to the first PM generation.@@ -28,7 +28,6 @@ from pathlib import Pathimport pytest-from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.mcp_plugins._helpers import HttpMcpServerfrom tests.e2e.core.upgrade import _helpers as Hfrom tests.e2e.core.upgrade import _install_helpers as I@@ -120,11 +119,9 @@ def test_repair_keeps_installed_extra_and_mcp(rebuilt):def test_configured_gateway_platform_has_its_sdk_after_update(rebuilt):sb, up, after = rebuilt["sb"], rebuilt["update"], rebuilt["after_update"]assert up.returncode == 0, P.diagnostics(sb, up)- with known_failure(r"configured discord platform has no SDK after `hermes update`: ModuleNotFoundError",- "gated on #124228: PM builds ignore configured gateway platforms"):- assert after["imports"]["discord"] == "ok", (- f"configured discord platform has no SDK after `hermes update`: {after['imports']['discord']}\n"- + P.diagnostics(sb, up))+ assert after["imports"]["discord"] == "ok", (+ f"configured discord platform has no SDK after `hermes update`: {after['imports']['discord']}\n"+ + P.diagnostics(sb, up))# ---------------------------------------------------------------------------diff --git a/tests/hermes_cli/test_update_missing_configured_deps.py b/tests/hermes_cli/test_update_missing_configured_deps.pyindex a5a1db17093..45c3480f2f3 100644--- a/tests/hermes_cli/test_update_missing_configured_deps.py+++ b/tests/hermes_cli/test_update_missing_configured_deps.py@@ -114,3 +114,23 @@ def test_unconfigured_or_disabled_features_are_quiet(configured_update, capfd):assert "MCP servers" not in outassert "Feishu / Lark:" not in outassert not (root / ".update-incomplete").exists()+++def test_update_installs_the_extras_configured_features_need(monkeypatch, tmp_path, capsys):+ """#124228: an enabled platform's SDK joins the environment instead of only a warning."""+ from hermes_cli import main_install_repair as repair++ (tmp_path / "pyproject.toml").write_text(+ '[project]\nname = "x"\nversion = "0"\n'+ "[project.optional-dependencies]\ndiscord = []\ngoogle-chat = []\nmcp = []\n", encoding="utf-8")+ monkeypatch.setattr(repair, "_configured_features_missing_deps", lambda: [+ ("Discord", "discord hint", "discord"), ("Google Chat", "chat hint", "google_chat"),+ ("IRC", "irc hint", "irc"), ("MCP servers", "mcp hint", "mcp")])+ calls = []+ monkeypatch.setattr(pm, "sync_venv", lambda extras, **kwargs: calls.append((extras, kwargs)))+ repair._install_configured_features_missing_deps(tmp_path)+ assert calls == [(["discord", "google-chat", "mcp"],+ {"explicit": True, "project_root": tmp_path, "evict_incompatible_plugins": True})]+ out = capsys.readouterr().out+ assert "IRC: irc hint" in out+ assert "Discord" not in out and "MCP servers" not in out