feat: pluggable MemoryProvider interface for persistent memory integrations#3462
feat: pluggable MemoryProvider interface for persistent memory integrations#3462shuruheel wants to merge 1 commit intoNousResearch:mainfrom
Conversation
…ations Introduces a MemoryProvider abstract interface that standardizes how persistent memory systems hook into the agent lifecycle. This makes it straightforward for third-party memory providers (MindGraph, Mem0, Zep, custom RAG, etc.) to integrate without modifying core agent code. The interface has 4 lifecycle hooks: - on_session_start() — new conversation - get_session_context() — system prompt enrichment (once) - get_turn_context() — per-turn semantic retrieval (ephemeral) - on_session_end() — cleanup + transcript ingestion These hooks mirror the patterns already established by Honcho's integration — the same injection points, the same non-fatal error handling, the same cache-stable ephemeral injection approach. A documented HonchoProvider stub shows how the existing Honcho integration maps to this interface as a future migration path. New files: - memory_provider.py — ABC, registry, factory, injection helper - providers/ — MindGraphProvider + HonchoProvider stub - tests/ — 35 unit + integration tests Modified: - run_agent.py — generic registry hooks alongside existing Honcho code - gateway/run.py — lazy registry + session cleanup hooks - AGENTS.md — developer guide: Adding a Memory Provider All calls are non-fatal. Failing providers never break conversations. Existing Honcho integration is completely untouched.
Update: Refactored as a native v0.5.0 pluginAfter reviewing the v0.5.0 release, the plugin lifecycle hooks ( Rather than maintaining a parallel
Published as pip-installable: Source: https://github.com/shuruheel/hermes-mindgraph-plugin This approach has a few advantages over the original PR:
Happy to close this PR in favor of the plugin approach. The plugin also serves as a reference implementation for anyone building memory integrations on the new hook system. |
Summary
Introduces a
MemoryProviderabstract interface that standardizes how persistent memory systems hook into the agent lifecycle. This makes it straightforward for third-party memory providers (MindGraph, Mem0, Zep, custom RAG, etc.) to integrate without modifying core agent code.Interface
The interface has 4 lifecycle hooks:
on_session_start()— new conversationget_session_context()— system prompt enrichment (once, cached)get_turn_context()— per-turn semantic retrieval (ephemeral injection)on_session_end()— cleanup + transcript ingestionThese hooks mirror the patterns already established by Honcho's integration — the same injection points, the same non-fatal error handling, the same cache-stable ephemeral injection approach.
What's included
New files:
memory_provider.py—MemoryProviderABC,MemoryProviderRegistry,create_default_registry(),inject_provider_context()providers/mindgraph_provider.py— MindGraph semantic graph memory providerproviders/honcho_provider.py— Documented stub showing how Honcho maps to this interface (Phase 2 migration path)Modified:
run_agent.py— Generic registry hooks added alongside existing Honcho codegateway/run.py— Lazy registry with_get_memory_providers()helper + session cleanup hooksAGENTS.md— Developer guide: "Adding a Memory Provider"Tests: 35 new tests (unit + integration), zero regressions
Design decisions
tools/registry.py(for explicit actions) AND a provider (for invisible lifecycle hooks). Both independently toggleable.AIAgentgets its own registry. No shared state across concurrent gateway conversations.HonchoProviderstub documents the Phase 2 migration path.How to add a provider
Then register in
create_default_registry()inmemory_provider.py.