Memory Engine
MemGPT-style persistent memory for OpenClaw agents. Five-layer architecture with 20 tools.
Why
Agents wake up blank every session. Memory Engine fixes this with structured, searchable, self-maintaining memory that scales to tens of thousands of facts.
Architecture
Layer 1: Core Memory → core.json (~500 tokens, always loaded)
Layer 2: Archival Memory → archival.jsonl (unlimited facts, hybrid search)
Layer 3: Knowledge Graph → graph.jsonl (entity relations, auto-extracted)
Layer 4: Episodic Memory → episodes.jsonl (conversation summaries)
Layer 5: Reflective Memory → pattern analysis (topic trends, mood shifts)
Install
# Install the plugin (provides all 20 tools)
openclaw plugins install @icex-labs/openclaw-memory-engine
# Run setup (interactive: core memory, config, crons, legacy migration)
bash ~/.openclaw/extensions/memory-engine/setup.sh
# Restart gateway
openclaw gateway restart
Setup auto-detects existing MEMORY.md and daily logs, migrates them into archival, runs a quality pass (entity classification + importance scoring), and registers maintenance crons.
Tools (20)
Core Memory — Your Identity
core_memory_read— load identity block at session startcore_memory_replace— update a field by dot-path (auto-parses JSON strings)core_memory_append— append to array fields (e.g., current_focus)
Archival Memory — Your Facts
archival_insert— store fact with entity + tags + importance (1-10). Auto-extracts graph triples.archival_search— hybrid search: keyword (2×) + embedding (5×) + recency + access decay + importancearchival_update— correct an existing recordarchival_delete— remove outdated factsarchival_stats— record count, entity/tag distribution, embedding coverage
Knowledge Graph — Your Relationships
graph_query— traverse entity relations with depth controlgraph_add— manually add relation triples
Episodic Memory — Your Conversations
episode_save— save conversation summary with decisions, mood, topicsepisode_recall— search past conversations by topic/keyword
Intelligence — Self-Improvement
memory_reflect— analyze behavioral patterns over configurable time windowarchival_deduplicate— find/remove near-duplicates via embedding cosine similaritymemory_consolidate— extract structured facts from text blocksmemory_quality— re-classify entities, re-rate importance, extract missing graph triples
Backup & Admin
memory_export— full snapshot to JSONmemory_import— restore with merge or replace modememory_migrate— JSONL → SQLite with FTS5memory_dashboard— generate browsable HTML dashboard
Search Scoring
Five-signal hybrid ranking:
| Signal | Weight | Description |
|---|---|---|
| Keyword | 2× | Term match in content + entity + tags |
| Semantic | 5× | OpenAI text-embedding-3-small cosine similarity |
| Recency | 0–1 | Decays over 1 year |
| Access | 0–0.5 | Recently accessed records rank higher |
| Importance | 0.5× | Forgetting curve: importance × e^(-0.01 × days) |
Falls back to keyword-only without OpenAI key. Cost: ~$0.001/session.
Multi-Agent
Each agent gets isolated memory based on its configured workspace. Uses ToolFactory pattern — resolved from session key at registration time. Privacy flag sharing: false for multi-user setups.
Self-Healing
- Missing embeddings auto-backfilled on gateway restart (batch, rate-limited)
- Legacy data auto-migrated during setup
- Data quality auto-improved post-migration (entity + importance + graph)
- Near-duplicates cleaned weekly by cron
- Dashboard refreshed daily
Automated Maintenance
| Schedule | Job |
|---|---|
| Every 6h | Consolidate daily logs into archival |
| Daily 9am | Behavioral reflection + pattern analysis |
| Daily 9:30am | Dashboard refresh |
| Weekly Sunday | Deduplication pass |
Platform Support
macOS (LaunchAgent), Linux (systemd timer), Windows (schtasks guided setup).
Links
- npm: @icex-labs/openclaw-memory-engine
- GitHub: icex-labs/openclaw-memory-engine
- License: MIT
