Three-layer persistent memory for agents. No more starting from zero every session.
LayerWhatWhereWhenCoreAlways in contextmemory/core.mdEvery session, auto-loadedArchivalSearchable storagememory/archival/*.mdOn demand, semantic searchRecallSession transcriptsOpenClaw session filesWhen needed via memory_search
memory/core.md)#Compact (~500-1000 words), always loaded. The agent's "working memory".
markdown
# Core Memory
## Identity
- Agent name, personality, role
## User
- Name, preferences, communication style, key facts
## Active Context
- Current projects, recent events, pending tasks
## Quick Reference
- Frequently needed info (medications, schedule, credentials refs)
memory/archival/)#Long-term storage organized by topic. Searched, not loaded.
text
memory/archival/
├── people/ # People and relationships
├── projects/ # Project details and decisions
├── decisions/ # Important decisions made
├── learnings/ # Lessons learned
└── reference/ # Facts, procedures, how-tos
markdown
# [Topic] — YYYY-MM-DD
## Summary
One-line description
## Details
Full context
## Tags
comma, separated, tags
Use memory_search to find relevant archival entries. Never load all archival files at once.
memory/core.mdmemory/YYYY-MM-DD.md if existsmemory/YYYY-MM-DD.md filesWhen core grows too large or items become stale:
When archival info is needed repeatedly:
At natural breakpoints or heartbeat:
First run? Set up the structure:
bash
mkdir -p memory/archival/{people,projects,decisions,learnings,reference}
Create memory/core.md if it doesn't exist:
markdown
# Core Memory
## Identity
- [Agent fills this in]
## User
- [Agent fills this in]
## Active Context
- [Agent fills this in]
## Quick Reference
- [Agent fills this in]
scripts/consolidate.py#Consolidates daily notes into archival entries. Run during heartbeats or manually.
text
python3 scripts/consolidate.py --days 7 --workspace /path/to/workspace
Options:
--days N — look back N days of daily notes (default: 7)--workspace PATH — workspace root (default: current dir)--dry-run — show what would be written without writingscripts/core-trim.py#Trims core.md when it exceeds the word limit.
text
python3 scripts/core-trim.py --max-words 1000 --workspace /path/to/workspace
Options:
--max-words N — maximum words for core.md (default: 1000)--workspace PATH — workspace root--dry-run — show what would be demoted without editing