Tools
Jinstronda Memory
Self-hosted OpenClaw memory plugin powered by Mem0. Free alternative to Supermemory.
Install
pip install mem0ai
Configuration Example
{
"plugins": {
"entries": {
"openclaw-mem0-memory": {
"enabled": true,
"config": {
"mem0Url": "http://localhost:8080",
"autoRecall": true,
"autoCapture": true
}
}
}
}
}
README
# AI Memory That Actually Works
Every AI memory product tells the same story: "we store your conversations and retrieve them when needed." What they actually do is extract `User prefers dark roast coffee` and throw away the conversation where you said you tried both and the dark roast was way better. The comparison, the timing, the conviction. Gone. They kept a label and threw away the signal.
I run a WhatsApp AI assistant and use Claude Code daily. Both kept forgetting things I'd already told them. So I went looking for solutions. Everything I found was either garbage or paid. Supermemory wants you to pay for an API. mem0 is open source but barely works. I couldn't find a single benchmark comparing them, so I built one. 500 questions, 115k tokens of real conversation history, LLM judge with ground truth answers. No vibes.
## The numbers
| Provider | Accuracy | Notes |
|----------|----------|-------|
| Supermemory | 85.9% | Paid API |
| **RAG v1.7 (this repo)** | **82.8%** | Open source, runs locally, free |
| mem0 | 72.1% | Cloud API |
| OpenClaw QMD | 58.3% | |
| Filesystem | 54.2% | Naive baseline |
### Per-category breakdown
| Question type | Accuracy | What it tests |
|---|---|---|
| Single-session user facts | 97.1% | "How many bass did I catch?" |
| Single-session assistant recall | 94.6% | "What recipe did you suggest?" |
| Knowledge updates | 83.3% | "Where do I work now?" (changed jobs) |
| Multi-session synthesis | 78.2% | Connecting info across conversations |
| Temporal reasoning | 69.2% | "When did I start running?" |
| Preferences | 63.3% | "What's my favorite coffee?" |
Retrieval quality: 97.2% Hit@K with 0.912 MRR. The right information is almost always found. The remaining errors are reasoning failures, not retrieval failures. That's a fundamentally different problem to solve.
## What's in this repo
Two systems, one repo:
```
openclaw-mem0-memory/
index.ts, hooks/, tools/ # OpenClaw mem0 plugin (v1, still works)
server/ # Mem0 backend (FastAPI + ChromaDB)
memorybench/ # RAG v1.7 system + benchmark
src/
mcp-server.ts # Claude Code MCP server
rag-server.ts # RAG HTTP server
providers/rag/ # The actual RAG pipeline
benchmarks/ # LongMemEval benchmark runner
scripts/
ensure-rag-server.sh # Auto-start hook for Claude Code
migrate-openclaw-memories.ts # Migrate existing memories to RAG
setup.sh # One-command setup for Claude Code + OpenClaw
```
The **mem0 plugin** (root level) is the v1 system. Simple fact extraction with ChromaDB. It works, 72.1% accuracy.
The **RAG system** (`memorybench/`) is v1.7. Hybrid search (BM25 + vector), entity graphs, atomic facts with parent chunk injection, query rewriting, LLM reranking, user profiles. Six retrieval signals fused together. 82.8% accuracy.
## The architecture
```
Query -> Rewrite (gpt-5-nano) -> Embed (text-embedding-3-large)
|
+---------------------------------------+
| Parallel Search |
| BM25 keywords + Vector similarity |
| Atomic fact matching |
| Entity graph (2-hop BFS) |
+-----------------+---------------------+
|
Fact -> Parent Chunk Injection
|
Session Boost (+0.1 for fact-matched sessions)
|
LLM Rerank (gpt-5-nano, query-type aware)
|
Entity + Relationship context
|
User Profile injection
|
Answer (GPT-5, reasoning)
```
When atomic facts match a query, the system looks up the full parent chunk containing that fact. The fact finds the needle; the chunk gives you the haystack around it. This is why preference questions work (63.3% vs ~40% without parent chunks). Preferences need nuance that single-line facts can't capture.
## Quick start
```bash
git clone https://github.com/Jinstronda/openclaw-mem0-memory.git
cd openclaw-mem0-memory
./setup.sh
```
The setup script does everything:
1. Installs memorybench dependencies (bun)
2. Registers the MCP server in Claude Code settings
3. Adds the SessionStart hook (auto-starts RAG server)
4. Installs the Claude Code skill (teaches Claude when to use memory)
5. Copies the OpenClaw plugin if OpenClaw is installed
You need `OPENAI_API_KEY` in your environment for embeddings and LLM inference.
### Manual setup
If you want to set things up yourself:
```bash
# RAG server (the backend)
cd memorybench
bun install
bun run src/rag-server.ts
# Test it
curl localhost:3847/health
```
### Claude Code only
The RAG system ships as an MCP server. Five tools:
| Tool | Purpose |
|---|---|
| `memory_search` | Search memories (personal + repo) |
| `memory_store` | Store new memories |
| `memory_use_repo` | Set active repo memory |
| `memory_list_repos` | List all memory containers |
| `memory_profile` | Get user's biographical profile |
Two memory layers:
- **Personal**: user bio, preferences, opinions, relationships. Always searched.
- **Per-repo** (`repo-<name>`): project-specific decisions, architecture, debugging. Isolated per project.
### OpenClaw only
The mem0 plugin (root level) hooks into OpenClaw's lifecycle:
- **before_agent_start**: queries memory, injects context into the prompt
- **agent_end**: captures the conversation, extracts facts, stores them
See the [mem0 setup section](#mem0-plugin-setup) below.
## Mem0 plugin setup
The original v1 system. Still works if you prefer simpler.
```bash
cp -r . ~/.openclaw/plugins/openclaw-mem0-memory
cd ~/.openclaw/plugins/openclaw-mem0-memory && bun install
# start mem0 backend
pip install mem0ai fastapi uvicorn chromadb aiohttp
cd server && python server.py
```
Add to `~/.openclaw/openclaw.json`:
```json
{
"plugins": {
"entries": {
"openclaw-mem0-memory": {
"enabled": true,
"config": {
"mem0Url": "http://localhost:8080",
"autoRecall": true,
"autoCapture": true
}
}
}
}
}
```
## Configuration
```bash
OPENAI_API_KEY= # Required (embeddings + LLM)
RAG_PORT=3847 # RAG server port (default: 3847)
RAG_CACHE_DIR= # Cache directory (default: ./data/cache/rag)
RAG_CONTAINER= # Personal memory namespace (default: "default")
MEM0_PORT=8080 # Mem0 server port (default: 8080)
```
## Migration
From Supermemory or existing OpenClaw memories:
```bash
# mem0 migration (markdown files -> mem0)
cd server && python migrate.py
# RAG migration (markdown files -> RAG system)
cd memorybench && bun run scripts/migrate-openclaw-memories.ts
```
## License
MIT
tools
Comments
Sign in to leave a comment