name: Feature request
about: Suggest an idea for this project
title: 'Feature: Implement Proactive Memory System with mem0-style API'
labels: 'enhancement'
assignees: ''
Is your feature request related to a problem? Please describe.
A clear description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear description of what you want to happen.
Describe alternatives you've considered
A clear description of alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Feature Request: Proactive Memory System
Summary
Implement proactive memory system with mem0-style simple API. Librefang already has a powerful memory infrastructure (Structured + Semantic + Knowledge stores), but needs a unified API layer and proactive memory extraction.
Motivation
Currently librefang has:
MemorySubstrate with Structured, Semantic, and Knowledge stores
- Passive query model - memories must be explicitly queried
- Rich internal APIs but no unified, simple external API
mem0 (50k stars) has become the de facto standard for AI agent memory with:
- Simple
search() + add() API
- Multi-level memory (User/Session/Agent)
- LLM-powered automatic memory extraction
- +26% accuracy, 91% faster, 90% less token usage
This issue proposes bringing mem0's proven approach to librefang.
Proposed Implementation
Phase 1: Unified Memory API (mem0-style)
- Wrap existing
MemorySubstrate with simple API
memory.search(query, user_id, limit) - semantic search
memory.add(messages, user_id) - store with automatic extraction
memory.get(user_id) - retrieve user preferences
memory.list(category) - list memories by category
Phase 2: Proactive Memory Hooks
- Agent execution interceptor (before/after)
auto_memorize() - extract important info after agent runs
auto_retrieve() - proactively load context before agent runs
- LLM-powered memory extraction (similar to mem0's memorize.py)
Phase 3: Multi-level Memory
- User memory - persistent preferences across sessions
- Session memory - current conversation context
- Agent memory - learned agent behaviors
Phase 4: Optional Integration
- mem0 cloud service adapter (use mem0.ai as backend)
- Self-hosted mem0 (Qdrant + Neo4j + Ollama)
Architecture
pub trait Memory: Send + Sync {
// mem0-style simple API
async fn search(&self, query: &str, user_id: &str, limit: usize) -> Vec<MemoryItem>;
async fn add(&self, messages: &[Message], user_id: &str) -> Result<()>;
async fn get(&self, user_id: &str) -> Result<Vec<MemoryItem>>;
async fn list(&self, category: Option<&str>) -> Result<Vec<MemoryItem>>;
}
pub trait ProactiveMemory: Send + Sync {
// Called after agent execution - extract important info
async fn auto_memorize(&self, conversation: &[Message]) -> Result<()>;
// Called before agent execution - proactively load context
async fn auto_retrieve(&self, query: &str) -> Result<Vec<MemoryItem>>;
}
Librefang Existing Components
Librefang already has (reuse):
librefang-memory/src/substrate.rs - MemorySubstrate
librefang-memory/src/semantic.rs - Semantic store with recall/remember
librefang-memory/src/knowledge.rs - Knowledge graph
librefang-runtime/src/hooks.rs - Hook system for interception
librefang-runtime/src/prompt_builder.rs - Prompt injection
Acceptance Criteria
References
name: Feature request
about: Suggest an idea for this project
title: 'Feature: Implement Proactive Memory System with mem0-style API'
labels: 'enhancement'
assignees: ''
Is your feature request related to a problem? Please describe.
A clear description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear description of what you want to happen.
Describe alternatives you've considered
A clear description of alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Feature Request: Proactive Memory System
Summary
Implement proactive memory system with mem0-style simple API. Librefang already has a powerful memory infrastructure (Structured + Semantic + Knowledge stores), but needs a unified API layer and proactive memory extraction.
Motivation
Currently librefang has:
MemorySubstratewith Structured, Semantic, and Knowledge storesmem0 (50k stars) has become the de facto standard for AI agent memory with:
search()+add()APIThis issue proposes bringing mem0's proven approach to librefang.
Proposed Implementation
Phase 1: Unified Memory API (mem0-style)
MemorySubstratewith simple APImemory.search(query, user_id, limit)- semantic searchmemory.add(messages, user_id)- store with automatic extractionmemory.get(user_id)- retrieve user preferencesmemory.list(category)- list memories by categoryPhase 2: Proactive Memory Hooks
auto_memorize()- extract important info after agent runsauto_retrieve()- proactively load context before agent runsPhase 3: Multi-level Memory
Phase 4: Optional Integration
Architecture
Librefang Existing Components
Librefang already has (reuse):
librefang-memory/src/substrate.rs- MemorySubstratelibrefang-memory/src/semantic.rs- Semantic store with recall/rememberlibrefang-memory/src/knowledge.rs- Knowledge graphlibrefang-runtime/src/hooks.rs- Hook system for interceptionlibrefang-runtime/src/prompt_builder.rs- Prompt injectionAcceptance Criteria
References