Skip to content

feat: add Mem0 memory integration CLI commands and client support#2933

Open
kartik-mem0 wants to merge 6 commits intoNousResearch:mainfrom
kartik-mem0:feat/mem0-integration
Open

feat: add Mem0 memory integration CLI commands and client support#2933
kartik-mem0 wants to merge 6 commits intoNousResearch:mainfrom
kartik-mem0:feat/mem0-integration

Conversation

@kartik-mem0
Copy link

@kartik-mem0 kartik-mem0 commented Mar 25, 2026

What does this PR do?

Adds Mem0 Platform integration to Hermes, enabling persistent cross-session memory. The agent extracts facts from conversations, stores them via Mem0's API, and recalls relevant context in future
sessions through semantic search and system prompt injection.

All search and retrieval uses the Mem0 v2 filter API with proper entity scoping. Memories stored with a run_id (from session strategies) are correctly retrieved using OR filters that combine bare
user_id matching with a run_id: "*" wildcard branch — without this, session-scoped memories are invisible to search. The rerank and keyword_search config settings are respected across all search
paths (manager, prefetch, tools, CLI). Mem0 is a fully independent plugin with its own turn context injection (_inject_mem0_turn_context), separate from Honcho.

Related Issue

Fixes #2942

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

  • mem0_integration/client.py — Config dataclass (Mem0ClientConfig) with resolution from $HERMES_HOME/mem0.json~/.hermes/mem0.json → env vars. Singleton MemoryClient factory.
  • mem0_integration/manager.pyMem0MemoryManager with add(), search(), get_profile(), store_fact(), and background prefetch() for system prompt injection.
  • mem0_integration/cli.pyhermes mem0 {setup|status|search|memories|clear} subcommands for interactive setup, connection health check, and memory management from the terminal.
  • tools/mem0_tools.py — Four agent tools: mem0_search, mem0_context, mem0_profile, mem0_conclude. Visible only when Mem0 is enabled.
  • run_agent.py — Mem0 lifecycle hooks: config loading, prefetch on session start, memory ingestion on conversation end, tool registration.
  • hermes_cli/main.py — Registered mem0 subcommand in the CLI argument parser.
  • hermes_cli/doctor.py — Added Mem0 connection health check to hermes doctor.
  • pyproject.toml — Added mem0ai as optional dependency.
  • tests/mem0_integration/test_client.py — 13 tests for config resolution, env fallback, singleton behavior.
  • tests/mem0_integration/test_cli.py — 5 tests for CLI status/search/memories commands.
  • tests/mem0_integration/test_manager.py — 14 tests for add, search, get_profile, store_fact, prefetch, shutdown.
  • tests/tools/test_mem0_tools.py — 15 tests for tool availability, search, context, profile, conclude handlers.

How to Test

  1. Install dependency: uv pip install mem0ai
  2. Run setup wizard: hermes mem0 setup — enter API key from app.mem0.ai
  3. Verify connection: hermes mem0 status
  4. Start a conversation with hermes, mention some personal facts, then end the session
  5. Start a new session — the agent should recall facts from the previous session via prefetch
  6. Search from CLI: hermes mem0 search "programming languages"
  7. List all stored memories: hermes mem0 memories
  8. Run unit tests: pytest tests/mem0_integration/ tests/tools/test_mem0_tools.py -v (47 tests, all passing)

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 (47 tests across 4 test files)
  • I've tested on my platform: macOS 15 (Apple Silicon)

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

Screenshots / Logs

Screenshot 2026-03-25 at 1 59 12 PM

@kartik-mem0 kartik-mem0 marked this pull request as draft March 25, 2026 08:30
@kartik-mem0 kartik-mem0 marked this pull request as ready for review March 25, 2026 08:35
@kartik-mem0 kartik-mem0 marked this pull request as draft March 25, 2026 08:35
kartik-mem0 and others added 4 commits March 25, 2026 14:05
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds comprehensive user-facing docs for the Mem0 integration, following
the same structure as the Honcho Memory docs. Covers setup, configuration,
tools, CLI commands, troubleshooting, warnings, and a Mem0 vs Honcho
comparison table. Adds mem0 to the sidebar under Integrations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kartik-mem0 kartik-mem0 marked this pull request as ready for review March 25, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Mem0 Platform integration — persistent cross-session memory

1 participant