The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): recover catalog provider once per profile
wangtao2cad86502d45
diff --git a/hermes_cli/memory_provider_migration.py b/hermes_cli/memory_provider_migration.pyindex 2fec8417f3b..ebe3f461300 100644--- a/hermes_cli/memory_provider_migration.py+++ b/hermes_cli/memory_provider_migration.py@@ -22,7 +22,7 @@ from typing import Callable, Optionallogger = logging.getLogger(__name__)-_attempted: set[str] = set()+_attempted: set[tuple[str, str]] = set()def configured_provider(home: Path) -> str:@@ -109,15 +109,17 @@ def migrate_all_homes(*, say: Callable[[str], None] = print) -> list[str]:def recover_at_startup(name: str) -> bool:"""Agent-init hook for a configured provider that resolved nowhere. One attempt per process per- name; honours ``security.allow_lazy_installs`` because it installs code. True when installed."""- if name in _attempted:+ home and name; honours ``security.allow_lazy_installs`` because it installs code. True when installed."""+ from hermes_constants import get_hermes_home, hermes_home_key++ home = get_hermes_home()+ key = (hermes_home_key(home), name)+ if key in _attempted:return False- _attempted.add(name)+ _attempted.add(key)from tools.lazy_deps import _allow_lazy_installsif not _allow_lazy_installs():logger.warning("Memory provider '%s' is not installed; security.allow_lazy_installs is off — ""run `hermes plugins install %s`.", name, name)return False- from hermes_constants import get_hermes_home- home = Path(get_hermes_home())return migrate_home(home, install=_install_into(home), say=logger.warning) == namediff --git a/tests/hermes_cli/test_memory_provider_migration.py b/tests/hermes_cli/test_memory_provider_migration.pyindex a2fbc6dec3d..9374cd42d8d 100644--- a/tests/hermes_cli/test_memory_provider_migration.py+++ b/tests/hermes_cli/test_memory_provider_migration.py@@ -56,3 +56,40 @@ def test_provider_unknown_to_catalog_is_reported_not_installed(home, monkeypatchsaid: list[str] = []assert mig.migrate_home(home, install=lambda n: pytest.fail("must not install"), say=said.append) is Noneassert "not in the plugin catalog" in said[0] and "memory.provider" in said[0]+++def test_startup_recovery_attempts_each_profile_home(tmp_path, monkeypatch):+ """One multiplexed process can start agents for two homes missing the same provider."""+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ from tools import lazy_deps++ homes = [tmp_path / "a", tmp_path / "b"]+ for profile_home in homes:+ profile_home.mkdir()+ (profile_home / "config.yaml").write_text("memory:\n provider: twin\n", encoding="utf-8")+ monkeypatch.setattr(mig, "_attempted", set())+ monkeypatch.setattr(mig, "catalog_source", lambda name: name)+ monkeypatch.setattr(lazy_deps, "_allow_lazy_installs", lambda: True)+ installed = []++ def fake_installer(profile_home):+ def install(name):+ plugin_dir = profile_home / "plugins" / name+ plugin_dir.mkdir(parents=True)+ (plugin_dir / "__init__.py").write_text("class Twin(MemoryProvider): ...\n", encoding="utf-8")+ installed.append(profile_home)+ return {"ok": True}++ return install++ monkeypatch.setattr(mig, "_install_into", fake_installer)+ outcomes = []+ for profile_home in (homes[0], homes[1], homes[0]):+ token = set_hermes_home_override(profile_home)+ try:+ outcomes.append(mig.recover_at_startup("twin"))+ finally:+ reset_hermes_home_override(token)++ assert outcomes == [True, True, False]+ assert installed == homes