Skip to content

The agent that grows with you

fix(left-core): an enabled plugin that failed to load gets its error, not "enable it"

Teknium8b9a739dadce
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index 287700f2165..da73c0e997e 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -531,7 +531,8 @@ def _provider_feature(name: str) -> Optional[LeftCoreFeature]:
def provider_install_hint(name: str) -> str:
"""For a provider name nothing resolves to that a left-core plugin supplies: the sentence naming its
- install command for the active home (its enable command when installed but not loaded), else ``""``.
+ install command for the active home (its enable command when installed but not enabled; its load error and
+ update command when enabled but it failed to load), else ``""``.
Appended to every "unknown provider" error (runtime resolution, ``/model``, ``hermes model``, ``hermes
auth add``)."""
feature = _provider_feature(name)
@@ -541,9 +542,22 @@ def provider_install_hint(name: str) -> str:
home = Path(get_hermes_home())
if not plugin_present(feature.plugin, home):
return f"{_install_sentence(feature)}."
- enable = _install_command(feature.plugin, home).replace(" install ", " enable ")
+ command = _install_command(feature.plugin, home)
+ if _bundled_plugin_selected(home, feature.plugin): # enabled, yet no profile: its load failed
+ error = _load_error(feature)
+ return (f"{feature.label} moved out of core into the '{feature.plugin}' plugin, which is enabled but failed "
+ f"to load{f' ({error})' if error else ''}: run `{command.replace(' install ', ' update ')}`, or "
+ f"see `hermes logs` for the cause.")
return (f"{feature.label} moved out of core into the '{feature.plugin}' plugin, which is installed but not "
- f"loaded: run `{enable}`.")
+ f"loaded: run `{command.replace(' install ', ' enable ')}`.")
+
+
+def _load_error(feature: LeftCoreFeature) -> str:
+ """The plugin loader's recorded error for *feature*'s plugin in this process, else ``""``."""
+ from hermes_cli.plugins import get_plugin_manager
+ names = {feature.plugin, feature.plugin_key} - {""}
+ return next((str(p["error"]) for p in get_plugin_manager().list_plugins()
+ if p.get("error") and names & {p.get("name"), p.get("key")}), "")
def provider_left_core(name: str) -> bool:
diff --git a/tests/hermes_cli/test_left_core_provider_rows.py b/tests/hermes_cli/test_left_core_provider_rows.py
index bba95a5e7b6..acc5bd9bc77 100644
--- a/tests/hermes_cli/test_left_core_provider_rows.py
+++ b/tests/hermes_cli/test_left_core_provider_rows.py
@@ -181,6 +181,19 @@ def test_unknown_left_core_provider_names_the_install_on_every_surface(acme_row)
assert lcm.provider_install_hint("other") == ""
+def test_an_enabled_plugin_that_failed_to_load_gets_its_error_not_enable(acme_row, monkeypatch):
+ from types import SimpleNamespace
+ from hermes_cli import plugins
+ (acme_row / "plugins" / "acme-llm").mkdir(parents=True)
+ (acme_row / "config.yaml").write_text("model:\n provider: acme\nplugins:\n enabled: [acme-llm]\n",
+ encoding="utf-8")
+ monkeypatch.setattr(plugins, "get_plugin_manager", lambda: SimpleNamespace(list_plugins=lambda: [
+ {"name": "acme-llm", "key": "acme-llm", "enabled": False, "error": "ImportError: cannot import name 'x'"}]))
+ hint = lcm.provider_install_hint("acme")
+ assert "ImportError: cannot import name 'x'" in hint and "hermes plugins update acme-llm" in hint
+ assert "enable" not in hint.replace("enabled", "")
+
+
def test_runtime_resolution_installs_the_plugin_first_for_a_home_using_it(acme_row, monkeypatch):
calls = []
monkeypatch.setattr(lcm, "recover_at_startup", lambda **kw: calls.append(kw) or [])