From c8cbc07030459162a85058a57f8155c4d9efcde0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 6 Sep 2026 02:21:43 -0700 Subject: [PATCH] test(mem0): setup module keeps post_setup when discovery imports the package first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The plugin loader execs sibling modules before the package __init__, so a module-level `from . import _read_mem0_json` in _setup.py failed against the empty parent shell and the whole module silently dropped out — every later `hermes memory setup mem0` died with "cannot import name 'post_setup'". The test loads mem0 through the real discovery path from a cold sys.modules and asserts the cached _setup module exposes post_setup (red on base). Also maps the contributor email for #103078 credit. Campaign tracker: https://github.com/NousResearch/hermes-agent/issues/104154 --- .../emails/muhammadnizamuddinaulia@gmail.com | 2 ++ tests/plugins/memory/test_mem0_setup.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 contributors/emails/muhammadnizamuddinaulia@gmail.com diff --git a/contributors/emails/muhammadnizamuddinaulia@gmail.com b/contributors/emails/muhammadnizamuddinaulia@gmail.com new file mode 100644 index 0000000000..98157426ab --- /dev/null +++ b/contributors/emails/muhammadnizamuddinaulia@gmail.com @@ -0,0 +1,2 @@ +schrodienieur +# PR #103078 salvage diff --git a/tests/plugins/memory/test_mem0_setup.py b/tests/plugins/memory/test_mem0_setup.py index 8242fec2fc..d265c3bbbe 100644 --- a/tests/plugins/memory/test_mem0_setup.py +++ b/tests/plugins/memory/test_mem0_setup.py @@ -253,3 +253,21 @@ class TestConnectivityChecks: assert ok is True + + +def test_discovery_loaded_setup_module_exposes_post_setup(monkeypatch): + """`hermes memory setup mem0` reaches the wizard when the package is first imported by plugin + discovery, which execs sibling modules before ``__init__`` (#103078). The invariant is on the + module the loader actually cached, not on a normal top-level import.""" + from plugins.memory import load_memory_provider + + saved = {k: sys.modules.pop(k) for k in list(sys.modules) if k.startswith("plugins.memory.mem0")} + try: + provider = load_memory_provider("mem0", register_skills=False) + assert provider is not None + assert hasattr(sys.modules["plugins.memory.mem0._setup"], "post_setup") + finally: + for k in list(sys.modules): + if k.startswith("plugins.memory.mem0"): + del sys.modules[k] + sys.modules.update(saved)