Three-layer anti-amnesia memory system for OpenClaw. SQLite FTS5, BM25 + CJK bigram search, temporal decay. 0-token search cost. No embedding API needed.
Repo ZackO2o/memory-engine, read from GitHub 17 min ago. ZackO2o has not joined Take My Repo.
--user "preference" writes to USER.md with 1500 char capmemory/snapshots/, keeps last 10--consolidate command — analyze and deduplicate MEMORY.md entries with snapshot safety--snapshot command — manual MEMORY.md snapshot📊 MEMORY XX%)clawhub install memory-engine-3layer
# or
git clone https://github.com/ZackO2o/memory-engine.gitInspired by Hermes Agent bounded memory design + OpenClaw Dreaming separation.
Full changelog: CHANGELOG.md
All 6 items from memory-engine-feedback-v2.9.md implemented:
New Scripts:
memory-resume.js — Zero-latency session recovery (<2000 tokens)memory-auto-extract.js — Mine session transcripts for events (OpenClaw format)New Features:
search --last N [--today] [--tag T] — Time-ordered recent entries without FTS5maintain --gc [--apply] — MEMORY.md stale entry detection & cleanup| Operation | Current | After 6 months |
|---|---|---|
| boot.js (full) | ~854 tokens | ~5900 ❌ |
| boot.js (default, max-chars=1500) | ~520 | ~372 ✅ |
| search --max 3 | ~251 | ~251 |
| write --today | ~21 | ~21 |
| Typical session (boot + 5 writes + 3 searches) | ~1176 | ~1176 ✅ |
| vs. reading all daily files | ~7928 | ~50000+ |
--max-chars (default 1500), outputs all section headers + most recent entries per section. Saves 94% tokens at 18KB file size.--max-chars N on boot.js and search.js; --full for no truncationMemory search costs ~251 tokens for 3 results.
Reading all daily files costs ~7928 tokens (and growing).
That's 97% savings today, 99.5% savings at 6 months.
memory-backup.sh: Auto-backup workspace to GitHub private repo. Runs every 6h via cron (integrated into memory-cron.sh Step 6). Only pushes if changes exist. Backs up: MEMORY.md, daily logs, SOUL.md, USER.md, AGENTS.md, openclaw.json, crontab.memory-restore.sh: One-command disaster recovery after OpenClaw reinstall. Clones backup, restores openclaw.json, restores crontab, rebuilds search index. Interactive safety prompt if workspace already exists.# One-time: init git in workspace and push cd ~/.openclaw/workspace git init && git branch -M main git remote add origin https://<token>@github.com/<user>/openclaw-workspace.git bash skills/memory-engine/scripts/memory-backup.sh
bash memory-restore.sh https://<token>@github.com/<user>/openclaw-workspace.git
agents.defaults.userTimezone to compute dates, but our scripts used TZ env var (often unset → UTC in cron environments). This caused cross-day mismatches:
memory/2026-04-09.md, but scripts (UTC) would write memory/2026-04-10.mduserTimezone from openclaw.json_timezone.js shared module: All 6 scripts use the same timezone sourceOPENCLAW_TZ env > openclaw.json > TZ env > /etc/timezone > /etc/localtime symlink > UTCmemory-cron.sh also reads from openclaw.jsonformatDateStampInTimezone() output exactlySQLITE_NOTADB/SQLITE_CORRUPT and auto-rebuild the index instead of crashing with an unhandled exception.memory-boot.js retries with --force rebuild if initial index update fails