Skip to content

fix: make _is_memory_provider_dir detect re-exported MemoryProvider s… - #53393

Open
j-zly wants to merge 2 commits into
NousResearch:mainfrom
j-zly:fix/memory-provider-dir-heuristic
Open

fix: make _is_memory_provider_dir detect re-exported MemoryProvider s…#53393
j-zly wants to merge 2 commits into
NousResearch:mainfrom
j-zly:fix/memory-provider-dir-heuristic

Conversation

@j-zly

@j-zly j-zly commented Jun 27, 2026

Copy link
Copy Markdown

…ubclasses

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Jun 27, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Clean simplification of the memory provider detection logic. Removes the synthetic _USER_NAMESPACE package registration in favor of direct importlib-based detection. The code removal is net-negative (22 additions, 51 deletions) which is a good sign — simplification.

Looks Good

  • Removes unnecessary complexity (synthetic package registration)
  • Simpler detection logic for re-exported MemoryProvider
  • No security concerns

Reviewed by Hermes Agent

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for identifying the re-export discovery gap; current plugins/memory/__init__.py:74-85 does only a literal text scan, so a thin provider root can be missed.

Problems

  • The patch removes the synthetic _hermes_user_memory package registrations. Current plugins/memory/__init__.py:253-256 and :395-406 install those parents before loading user-provider modules and cli.py. Their removal would reintroduce the relative-import failure guarded by tests/agent/test_memory_provider.py:540-571 and :610-640.
  • Please add a regression that has neither MemoryProvider nor register_memory_provider in the root __init__.py. The current nested-reexport test at tests/agent/test_memory_provider.py:573-607 still contains register_memory_provider, so it takes the existing fast path.

Suggested changes

  • Preserve _USER_NAMESPACE / _register_synthetic_package() and their provider/CLI call sites while adding the fallback detection.
  • Cover discovery and loading for the marker-free re-export layout.

Automated hermes-sweeper review.


# Fallback: import and check for MemoryProvider subclass
try:
provider = _load_provider_from_dir(path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fallback needs to retain the synthetic _hermes_user_memory parent-package setup removed elsewhere in this patch. _load_provider_from_dir() executes user providers under that namespace; without the registrations, relative imports regress (tests/agent/test_memory_provider.py:540-571 covers this on current main).

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 15, 2026
…ports

- Restore _USER_NAMESPACE / _register_synthetic_package() removed in
  previous iteration
- Call _register_synthetic_package before loading user provider modules
  in _load_provider_from_dir and discover_plugin_cli_commands
- Add regression test for _is_memory_provider_dir fallback path when
  __init__.py lacks literal MemoryProvider/register_memory_provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants