Skip to content

The agent that grows with you

fix: review findings on update-disabled plugins

Teknium8c7cbd37d420
diff --git a/agent/agent_init_memory_provider.py b/agent/agent_init_memory_provider.py
index 432e11003ee..bbcbabb6aec 100644
--- a/agent/agent_init_memory_provider.py
+++ b/agent/agent_init_memory_provider.py
@@ -59,16 +59,11 @@ def resolve_memory_provider(name: str, say=None):
return None
# The provider left core for the catalog (or was never installed): fetch it once.
from hermes_cli.memory_provider_migration import recover_at_startup
- reported: list[str] = []
- def relay(message: str) -> None:
- reported.append(message)
- if say is not None:
- say(message)
-
- if recover_at_startup(name, say=relay):
+ if recover_at_startup(name, say=say):
provider = load_memory_provider(name)
- if provider is None and not reported and find_provider_dir(name) is not None:
+ # Installed (now or before) yet still not loading: an install notice does not explain that.
+ if provider is None and find_provider_dir(name) is not None:
_warn_once(name, f"⚠ Memory provider '{name}' is installed but failed to load, so external memory is off "
"for this session (built-in memory still works). The log names the error; "
"`hermes memory status` shows the plugin's state.", say=say)
diff --git a/plugins/memory/__init__.py b/plugins/memory/__init__.py
index 24627e3deec..e36df7bfb24 100644
--- a/plugins/memory/__init__.py
+++ b/plugins/memory/__init__.py
@@ -531,14 +531,9 @@ def _explicitly_disabled(name: str, provider_dir: Path) -> bool:
return False
if not isinstance(disabled, list):
return False
- names = {name, provider_dir.name}
- try:
- import hermes_yaml as yaml
- with open(provider_dir / "plugin.yaml", encoding="utf-8-sig") as f:
- names.add(str((yaml.safe_load(f) or {}).get("name") or ""))
- except Exception:
- pass
- return bool(names & {v for v in disabled if isinstance(v, str)})
+ from pm.plugins_state import plugin_spellings
+
+ return bool(plugin_spellings(provider_dir, name) & {v for v in disabled if isinstance(v, str)})
def _prune_inactive_memory_provider_skills(active_provider: Optional[str] = None) -> None:
diff --git a/pm/plugin_eviction.py b/pm/plugin_eviction.py
index 5cba16e529b..f90229e239d 100644
--- a/pm/plugin_eviction.py
+++ b/pm/plugin_eviction.py
@@ -144,16 +144,20 @@ def _prune_record(plugins) -> None:
def recorded_evictions() -> list[Entry]:
- """Plugins an earlier update disabled that their home still has disabled: retried each update."""
- from pm.plugins_state import dependency_homes, read_home_selection
+ """Plugins an earlier update disabled that their home still has disabled: retried each update.
+ A provider-only record (never in plugins.enabled) is retried only while memory.provider still
+ names it, so a rejoin never installs a provider the user has since switched away from."""
+ from pm.plugins_state import dependency_homes, plugin_spellings, read_home_selection
from pm.workspace import selected_plugin_dir
entries: list[Entry] = []
for home in dependency_homes():
try:
- plugins = (read_home_selection(home) or {}).get("plugins") or {}
+ selection = read_home_selection(home) or {}
except ValueError:
continue # sync_evicting already reports an unreadable profile
+ plugins = selection.get("plugins") or {}
+ provider = str((selection.get("memory") or {}).get("provider") or "").strip()
record, disabled = plugins.get(RECORD), plugins.get("disabled") or []
for name in record if isinstance(record, dict) else ():
if not isinstance(name, str) or name not in disabled:
@@ -162,7 +166,9 @@ def recorded_evictions() -> list[Entry]:
plugin_dir = selected_plugin_dir(home / "plugins", name)
except InstallError:
continue # a hand-edited key that names no plugin tree
- if plugin_dir is not None:
+ earlier = record.get(name)
+ was_enabled = isinstance(earlier, dict) and bool(earlier.get("enabled"))
+ if plugin_dir is not None and (was_enabled or provider in plugin_spellings(plugin_dir, name)):
entries.append((home / "plugins", name, plugin_dir))
return entries
diff --git a/pm/plugins_state.py b/pm/plugins_state.py
index e58242352d3..21007c09c89 100644
--- a/pm/plugins_state.py
+++ b/pm/plugins_state.py
@@ -178,14 +178,14 @@ def _parked(plugin_dir: Path, config: dict[str, Any]) -> bool:
def plugin_spellings(plugin_dir: Path, key: str | None = None) -> set[str]:
"""Every name a plugins list may use for this plugin: the selection key and its bare leaf, the
directory name and the manifest ``name:``. Read from the plugin itself, so it holds in any home."""
- import hermes_yaml
- from ruamel.yaml.error import YAMLError
+ from pm.plugin_declarations import native_manifest_file, read_native_manifest
names = {plugin_dir.name} | ({key, key.rsplit("/", 1)[-1]} if key else set())
try:
- manifest = hermes_yaml.safe_load((plugin_dir / "plugin.yaml").read_text(encoding="utf-8-sig")) or {}
- names.add(str(manifest.get("name") or ""))
- except (OSError, UnicodeError, YAMLError, AttributeError):
+ manifest_file = native_manifest_file(plugin_dir)
+ if manifest_file is not None:
+ names.add(str(read_native_manifest(manifest_file).get("name") or ""))
+ except ValueError:
pass # no readable manifest: the other spellings still hold
names.discard("")
return names
diff --git a/tests/agent/test_memory_provider_unavailable_warning.py b/tests/agent/test_memory_provider_unavailable_warning.py
index e1d8e9e0bff..869a5dbadbb 100644
--- a/tests/agent/test_memory_provider_unavailable_warning.py
+++ b/tests/agent/test_memory_provider_unavailable_warning.py
@@ -70,3 +70,27 @@ def test_parked_provider_is_reported_and_never_reinstalled(monkeypatch):
assert agent_init.resolve_memory_provider("parkedmem", say=said.append) is None
assert len(said) == 1
assert "hermes plugins enable parkedmem" in said[0] and "requires Python <3.14" in said[0]
+
+
+def test_provider_that_still_fails_after_recovery_is_reported(monkeypatch):
+ """An install notice from startup recovery does not explain a provider that still cannot load:
+ the user is told external memory is off."""
+ from hermes_cli import memory_provider_migration
+ from hermes_constants import get_hermes_home
+
+ plugin = get_hermes_home() / "plugins" / "brokenmem"
+
+ def recover(name, say=None):
+ plugin.mkdir(parents=True)
+ (plugin / "__init__.py").write_text(
+ "from agent.memory_provider import MemoryProvider\nimport hermes_missing_package_for_test\n", encoding="utf-8")
+ say(f"Installed memory provider '{name}'.")
+ return True
+
+ monkeypatch.setattr(memory_provider_migration, "recover_at_startup", recover)
+ agent_init._warned_unavailable_providers.clear()
+ said: list[str] = []
+
+ assert agent_init.resolve_memory_provider("brokenmem", say=said.append) is None
+ assert len(said) == 2 and "failed to load" in said[1]
+
diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.py
index 22b2f699b95..115acf36a7c 100644
--- a/tests/pm/test_plugin_survival_contract.py
+++ b/tests/pm/test_plugin_survival_contract.py
@@ -447,6 +447,22 @@ def test_plugin_the_user_disables_after_an_update_stays_disabled(admission_env):
assert plugins["disabled"] == ["plug-b"] and "disabled_by_update" not in plugins
+def test_provider_only_record_is_retried_only_while_it_is_still_the_provider(admission_env):
+ """A provider an update parked that was never in plugins.enabled rejoins only as the provider:
+ once the user picks another provider, updates stop installing it (its rejoin would leave the
+ environment holding a plugin no selection names)."""
+ from pm.plugin_eviction import recorded_evictions
+
+ _, home = admission_env
+ (home / "plugins" / "parked").mkdir(parents=True)
+ record = "plugins:\n disabled: [parked]\n disabled_by_update:\n parked: {enabled: false, reason: r}\n"
+ (home / "config.yaml").write_text(record + "memory:\n provider: parked\n", encoding="utf-8")
+ assert [name for _, name, _ in recorded_evictions()] == ["parked"]
+
+ (home / "config.yaml").write_text(record + "memory:\n provider: other\n", encoding="utf-8")
+ assert recorded_evictions() == []
+
+
@pytest.mark.skipif(not _uv_available(), reason="uv not on PATH")
def test_update_sync_disables_later_plugin_of_unresolvable_union(admission_env):
"""Core moved under two admitted plugins that no longer co-resolve: the update keeps the