Install
openclaw skills install smart-memory-plusComplete memory system for OpenClaw agents. Combines enhanced memory management (WAL protocol, type classification, temporal decay, session cache) with conte...
openclaw skills install smart-memory-plusUnified memory management + context compression for OpenClaw. Zero external dependencies.
⚠️ Conflict Warning: This skill replaces both
smart-memoryandcontext-compactor. Do NOT install alongside either of those skills — they share the same files (SESSION-STATE.md,memory/,MEMORY.md) and will cause write conflicts.
OPENCLAW_WORKSPACE — Workspace root (default: ~/.openclaw/workspace)OPENCLAW_SESSION_ID — Session identifier for temp cache (default: default)The agent MUST use the provided scripts for ALL writes. Direct file writes are FORBIDDEN.
| File | Required Script | Forbidden |
|---|---|---|
SESSION-STATE.md | session_state.py (WAL protocol) | Direct write/overwrite |
memory/compacts/*.md | compact_session.py --write | Direct write/overwrite |
memory/*.md (daily notes) | extract_memories.sh --auto or append via script | Direct overwrite |
MEMORY.md | memory_decay.py --promote-only | Direct overwrite |
/tmp/openclaw-session-*.json | session_cache.py | Direct write |
Critical: Never use the agent's file-write tool directly on memory files. Always pipe through scripts — they enforce sanitization, deduplication, and append-only behavior.
The agent MUST NOT write to:
.* dotfile or dotdir in workspace rootAll write commands automatically reject inputs matching:
sk-*, GitHub ghp_*, ClawHub clh_*)password=, passwd:, etc.)-----BEGIN PRIVATE KEY-----)This is a hard block at the script level — the agent cannot bypass it.
<REDACTED_PATH>, <REDACTED_URL>, <INTERNAL_URL>| Layer | File | Purpose | Lifetime |
|---|---|---|---|
| HOT RAM | SESSION-STATE.md | Current task, context, decisions | Session (survives compaction) |
| DAILY | memory/YYYY-MM-DD.md | Raw daily notes with type tags | 90 days → archive |
| CURATED | MEMORY.md | Promoted long-term facts | Permanent |
| COMPACT | memory/compacts/YYYY-MM-DD-HHMM.md | Session digests | 30 max, auto-cleanup |
| GRAPH | memory/.index/graph.db | Entity-relation knowledge graph | Rebuild from source |
| ARCHIVE | memory/archive/YYYY-MM/ | Stale daily files | Forever (compressed) |
| CACHE | /tmp/openclaw-session-*.json | Session temp data | Session end / reboot |
| Action | Script |
|---|---|
| WAL shortcut | scripts/wal task/decide/context/pending/done/blocker/get/snapshot/restore |
| Set current task | scripts/wal task "description" |
| Log a decision | scripts/wal decide "chose X over Y" |
| Add context | scripts/wal context key value |
| Session cache | python3 scripts/session_cache.py set/get/list/clear |
| Classify memories | python3 scripts/classify_memory.py --summary/--apply |
| Decay & archive | python3 scripts/memory_decay.py --dry-run/--promote-only |
| Health report | bash scripts/memory_health.sh |
| Action | Script |
|---|---|
| Full index rebuild | python3 scripts/memory_search_bm25.py build |
| Incremental update | python3 scripts/memory_search_bm25.py update |
| Search memories (BM25) | python3 scripts/memory_search_bm25.py search "query" [--top N] |
| Index status | python3 scripts/memory_search_bm25.py status |
| Find related entries | python3 scripts/classify_memory.py --related "query" [--top N] |
| Build knowledge graph | python3 scripts/memory_graph.py build |
| Graph relations | python3 scripts/memory_graph.py related "entity" [--depth N] |
| Graph stats | python3 scripts/memory_graph.py stats |
| Raw graph query | python3 scripts/memory_graph.py query "SELECT ..." |
| Action | Script |
|---|---|
| Extract compact (stdin) | python3 scripts/compact_session.py --extract |
| Write compact (stdin) | python3 scripts/compact_session.py --write |
| List compacts | python3 scripts/compact_session.py --list |
| Read latest compact | python3 scripts/compact_session.py --latest |
| Compact stats | python3 scripts/compact_session.py --stats |
Critical rule: Write BEFORE responding.
When the user provides information that should be remembered:
session_state.py)This prevents context loss if compaction, crash, or restart happens between response and write.
| User Action | WAL Write |
|---|---|
| States a preference | session_state.py context "pref" "value" |
| Makes a decision | session_state.py decide "chose X" |
| Gives a deadline | session_state.py context "deadline" "date" |
| Corrects agent | session_state.py decide "correction: X not Y" |
| Assigns task | session_state.py task "description" |
| Mentions blocker | session_state.py blocker "description" |
All entries tagged with a type prefix:
[PREF] — User preferences, habits, style[PROJ] — Project context, active work, goals[TECH] — Technical details, configs, system knowledge[LESSON] — Lessons learned, errors, corrections[PEOPLE] — People, relationships, social context[TEMP] — Session-scoped, auto-expiresSESSION-STATE.md for current task/contextpython3 scripts/memory_search_bm25.py build (if index is stale or missing)python3 scripts/memory_search_bm25.py search "current topic" (semantic search)memory_search (OpenClaw built-in tool) as complementary searchpython3 scripts/compact_session.py --latest
memory/YYYY-MM-DD.md for today's activitymemory/YYYY-MM-DD.md with type tagsession_cache.py for transient session dataSESSION-STATE.md with final stateecho "content" | python3 scripts/compact_session.py --write[TYPE] tags per smart-memory classificationMEMORY.mdmemory_decay.py when MEMORY.md > 200 lines or 50+ daily filesclassify_memory.py to tag orphaned entriesmemory_search_bm25.py update to refresh search index after editsmemory_graph.py build to refresh knowledge graphextract_memories.sh --auto "text" — keyword matching, zero token cost, fully localcompact_session.py --extract — regex-based extraction, zero token cost, fully local| Script | Language | Purpose | Security |
|---|---|---|---|
session_state.py | Python | HOT RAM working memory (WAL) | Sensitive data filter + sanitization |
session_cache.py | Python | Session-scoped temp cache | Sensitive data filter + path-safe IDs |
compact_session.py | Python | Context compression & digests | Path containment + sensitive filter |
extract_memories.sh | Bash | Memory extraction guide & auto-extract | Read-only + sensitive filter (Python) |
classify_memory.py | Python | Keyword + n-gram type classification, related search | Dry-run mode, duplicate check |
memory_decay.py | Python | Temporal decay & LESSON promotion | Dry-run mode |
memory_health.sh | Bash | Health report (stats, orphans, tokens) | Read-only |
memory_search_bm25.py | Python | BM25 semantic search over memories | Local-only, zero network |
memory_graph.py | Python | SQLite knowledge graph (entities + relations) | Local-only, SELECT-only queries |
references/extraction_prompt.md — Extraction prompt template (for agent-internal use)references/compaction_prompt.md — Compaction prompt template (for agent-internal use)references/decay_rules.md — Decay/archival rule setreferences/memory_schema.md — Full schema and format spec