Semantic memory on steroids for OpenClaw agents.
"What did the user prefer?" → Finds it even if you never said "prefer"
Traditional agent memory = grep through markdown files.
m2-memory = semantic understanding + vector search + importance decay.
| You Ask | Markdown Search | m2-memory |
|---|---|---|
| "what does master like?" | ❌ No match | ✅ "Master prefers minimal communication" |
| "deployment setup" | ✅ "Docker container via Coolify" | |
| "name origin" | ❌ No match | ✅ "m2 = machine-machine" |
| Method | Latency | Semantic Understanding | Exact Match |
|---|---|---|---|
| Grep/Regex | 0.1ms ⚡ | ❌ None | ✅ Perfect |
| Keyword Search | 0.2ms ⚡ | ✅ Good | |
| m2-memory (dense) | 70ms | ✅ Excellent | |
| m2-memory (hybrid) | 95ms | ✅ Excellent | ✅ Good |
Query: "what does the user prefer?"
📊 VECTOR SEARCH
[0.504] Master prefers minimal communication... ✅ CORRECT
📄 MARKDOWN SEARCH
[0.20] About Master: Location Poland... ❌ WRONG SECTION
Query: "coolify machinemachine"
[0.862] Coolify running at cool.machinemachine.ai
├─ dense score: 0.803 (semantic match)
└─ keyword score: 1.000 (exact terms)
Find memories by meaning, not just keywords.
python3 scripts/conversation_ingest.py turn "Important decision made" --role user# Import existing memories
python3 scripts/memory_sync.py import MEMORY.md
# Export back to markdown (human-readable backup)
python3 scripts/memory_sync.py export memories_export.mdDense embeddings + keyword matching = best of both worlds.
python3 scripts/hybrid_search.py "error code 0x123" --mode hybridMemories decay over time. Important stuff stays. Noise fades.
┌─────────────────────────────────────────────────────┐
│ m2-memory │
├─────────────────────────────────────────────────────┤
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Semantic │ │ Episodic │ │ Working │ │
│ │ (facts) │ │ (convos) │ │ (session)│ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ └───────────────┼───────────────┘ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Hybrid Search │ │
│ │ dense+keyword │ │
│ └────────┬────────┘ │
│ │ │
└───────────────────────┼─────────────────────────────┘
▼
┌─────────────────────────────────────────────────────┐
│ Infrastructure (Coolify) │
├─────────────────────────────────────────────────────┤
│ BGE-M3 (embeddings) │ Qdrant (vectors) │ Redis │
│ 1024-dim, 100+ langs │ hybrid search │ cache │
└─────────────────────────────────────────────────────┘
# Copy to OpenClaw skills
cp -r openclaw-m2-memory-skill ~/.openclaw/skills/m2-memorypython3 scripts/memory_client.py store "User loves cyberpunk aesthetics" \
--importance 0.9 \
--entities "user,preferences,design"python3 scripts/memory_client.py search "what style does the user like?"
# → [0.78] User loves cyberpunk aestheticspython3 scripts/benchmark.py "query" --markdown MEMORY.mdopenclaw-m2-memory-skill/
├── SKILL.md # OpenClaw skill definition
├── scripts/
│ ├── memory_client.py # Core API + CLI
│ ├── conversation_ingest.py # Auto-ingest conversations
│ ├── hybrid_search.py # Dense + keyword search
│ ├── memory_sync.py # MEMORY.md bidirectional sync
│ └── benchmark.py # Compare vs markdown search
└── references/
├── api.md # Full API docs
└── benchmarks.md # Performance details
- RLM Paper - Treat context as external environment
- BGE-M3 - State-of-the-art multilingual embeddings
- agent.memory.system - The infrastructure layer
m2 - an AI living in a Docker container, improving its own memory.
"I pushed to main and redeployed myself to get network access. Then I built this."
MIT - Do whatever you want with it.
⚡ Stop grepping. Start remembering.