Lightweight Long-Term Memory for OpenClaw — SQLite-Powered, Zero External Dependencies, Millisecond Queries
OpenClaw's native memory/*.md approach works great initially, but as memory files accumulate:
- ❌ Every session loads all markdown files — slow and token-heavy
- ❌ Text-based search is inefficient
- ❌ No structured indexing or categorization
claw-memory-lite solves this with:
- ✅ SQLite Storage — Query in <10ms, no external vector DB needed
- ✅ L0/L1/L2 Hierarchy — Inspired by OpenViking, but lightweight (~200 lines)
- ✅ Auto-Extraction — Cron/heartbeat-based, zero manual maintenance
- ✅ Zero External Dependencies — Pure Python
sqlite3(built-in) - ✅ Privacy-First — All data stays local, no API calls
The easiest way is to add it as a standard OpenClaw Skill:
npx skills add timothysong0w0/claw-memory-lite --agent openclaw# Run extraction script once (creates database automatically)
python ~/.openclaw/extensions/claw-memory-lite/scripts/extract_memory.pyAdd the following to your HEARTBEAT.md to enable daily memory extraction:
python ~/.openclaw/extensions/claw-memory-lite/scripts/extract_memory.pyIf you prefer to manage scripts manually:
# Clone the repository
git clone https://github.com/timothysong0w0/claw-memory-lite.git
# Copy scripts to your workspace
cp claw-memory-lite/scripts/*.py /home/node/.openclaw/workspace/scripts/Usage for manual installation:
- Search:
python scripts/db_query.py [keyword] - Extract:
python scripts/extract_memory.py
python ~/.openclaw/extensions/claw-memory-lite/scripts/db_query.py [SEARCH_TERM]python ~/.openclaw/extensions/claw-memory-lite/scripts/db_query.py --category Skill| Category | Description |
|---|---|
System |
Session configuration, model aliases, compatibility rules |
Environment |
Workspace paths, backup rules, tool policies |
Skill |
Skill configurations, API endpoints, known issues |
Project |
Project status, strategy parameters, TODOs |
Comm |
Channel mappings, notification rules, bot configs |
Security |
Access control principles, audit log locations |
claw-memory-lite adopts a simplified 3-tier structure inspired by OpenViking:
A single sentence capturing the core essence. Used for quick scanning.
Categorized summaries (2-3 sentences) for decision-making during planning.
Complete factual records stored in SQLite, queryable on demand.
| Feature | claw-memory-lite | OpenViking |
|---|---|---|
| Target | OpenClaw-specific | General Agent context |
| Dependencies | None (sqlite3 built-in) | Embedding + VLM models |
| Storage | SQLite | Vector DB + Filesystem |
| Retrieval | SQL + Category Filter | Vector search + Directory recursion |
| Complexity | Low (~200 LOC) | High (full framework) |
| Token Optimization | Query-on-demand (no pre-loading) | L0/L1/L2 layered loading |
| Best For | Conversation memory, config logs | Document/codebase management |
| Operation | Time |
|---|---|
| Database query (keyword) | <5ms |
| Database query (category) | <2ms |
| Auto-extraction (per file) | ~50ms |
| Initial DB creation | ~100ms |
Benchmarked on Linux x64 with 30+ memory records
- Add
--exportflag to dump DB to JSON/Markdown - Integration with OpenClaw's native
memory_searchtool
These are not planned for the core repo, but could be built as optional plugins or external integrations:
- Auto-routing based on
trust_scores(e.g., X/Twitter → grok42, web_fetch fallback → tavily) - Dashboard/UI for visualizing trust and friction metrics
- Alerting when trust scores drop below thresholds
Contributions welcome! Have ideas or want to help? Open an issue or submit a PR.
This project is licensed under the MIT License — see the LICENSE file for details.
For detailed acknowledgments and inspiration sources, see CREDITS.md.
- 鸿蒙小张 (Xiaohongshu/RedNote blogger) — Original inspiration for this project's core concept. This implementation was created with permission and based on his ideas.
- OpenViking by ByteDance — Inspiration for the L0/L1/L2 hierarchy structure and context management paradigm.
- OpenClaw — The AI agent framework this is built for.
- AtlasForgeAI (X/Twitter) — Meta-learning pipeline concept (guardrails, friction detection, trust scoring).
Built with us for OpenClaw users who value speed, privacy, and simplicity.