On this page
📁 How memory works
OpenClaw's memory is deliberately simple: Markdown files are the source of truth. The vector database is just a derived index — like a search index that can be dropped and rebuilt anytime.
~/.openclaw/workspace/
├── MEMORY.md # Long-term curated facts
└── memory/
├── 2026-02-26.md # Today's daily log
├── 2026-02-25.md # Yesterday's log
└── ... # Older logs
Key principles:
- Files on disk = truth. The agent only remembers what gets written down.
- Human-editable. Open any file in a text editor, change it, done.
- Git-friendly. Track changes with version control. Diff, blame, revert.
- No vendor lock-in. Switch machines?
rsyncthe folder. Switch embedding models? Re-index.
💡 Context vs Memory: Context is everything the agent sees in one session (system prompt, conversation history, current message). Memory is what persists across sessions — the files on disk. They're different layers.
📅 Daily logs
Daily logs (memory/YYYY-MM-DD.md) are append-only files that capture day-to-day activities, decisions, and running context.
- Today + yesterday are loaded at every session start
- Older logs are searchable via semantic search but not loaded by default
- The agent appends to today's log during conversations
What goes in daily logs
# 2026-02-26
## Tasks Completed
- Deployed v2.3 of the cheatsheet site
- Fixed broken nav links in guide-channels.html
## Decisions Made
- Using Telegram as primary channel, WhatsApp as backup
- Chose PostgreSQL over MySQL for the new project
## Notes
- Adrian mentioned 1-2 hours/day constraint — keep suggestions actionable
- Next priority: build playbooks section
✅ Tip: If you want something to stick, explicitly tell your agent: "Remember this" or "Write this to memory." The agent will know what to do.
📌 MEMORY.md — long-term curated memory
MEMORY.md holds durable facts, preferences, and decisions that should persist for weeks or months. It's loaded in main/private sessions only — never in group chats (to protect sensitive information).
What goes in MEMORY.md vs daily logs
| Content | Goes in |
|---|---|
| Today's meeting notes | memory/2026-02-26.md |
| "Adrian prefers PostgreSQL" | MEMORY.md |
| Project deadline: March 15 | MEMORY.md |
| Debug session findings | memory/YYYY-MM-DD.md |
| "Always use Docker for deploys" | MEMORY.md |
| Random conversation context | memory/YYYY-MM-DD.md |
⚠️ Keep MEMORY.md curated. If it turns into a diary, it gets noisy and less useful. Think of daily logs as a journal and MEMORY.md as a reference card — small, stable, high-signal.
🔍 Hybrid search — vector + BM25
When the agent needs to recall something, OpenClaw searches memory using two complementary methods:
| Method | Default weight | Good at | Weak at |
|---|---|---|---|
| Vector search | 70% | Conceptual matches ("gateway host" ≈ "machine running the gateway") | Exact tokens, error codes, IDs |
| BM25 keyword | 30% | Exact matches (error strings, env vars, function names) | Paraphrased content |
The final score combines both: vectorWeight × vectorScore + textWeight × textScore
OpenClaw uses union, not intersection — results from either method contribute to ranking. A chunk scoring high on vectors but zero on keywords is still included.
Advanced: MMR & temporal decay
- MMR (Maximal Marginal Relevance) — reduces redundant results. If five daily logs mention the same router config, MMR ensures you get diverse results instead of five near-duplicates.
- Temporal decay — exponentially reduces scores of old memories so recent notes rank higher. A half-life of 30 days works well for daily-note-heavy workflows.
🔌 Embedding providers
OpenClaw auto-selects an embedding provider in priority order:
| Provider | Cost | Speed | Quality | Privacy |
|---|---|---|---|---|
| Local (configured model path) | Free | Depends on hardware | Good | ⭐⭐⭐ |
| OpenAI (text-embedding-3-small) | Cheap | Fast | Excellent | ⭐⭐ |
| Gemini (gemini-embedding-001, gemini-embedding-2-preview) | Free tier | Fast | Very good | ⭐⭐ |
| Ollama | Free | Local | Good | ⭐⭐⭐ |
| BM25-only fallback | Free | Instant | Keywords only | ⭐⭐⭐ |
💡 Ollama (v2026.3.2+): Set memorySearch.provider = "ollama" for fully local, private embeddings — no API calls. Uses your existing models.providers.ollama settings. See changelog for details.
{
"agents": {
"defaults": {
"memorySearch": {
"provider": "openai",
"model": "text-embedding-3-small"
}
}
}
}
💡 Switching providers: If you change the embedding model, OpenClaw automatically detects the mismatch and reindexes everything. No manual intervention needed.
♻️ Memory flush before compaction
Long conversations eventually hit the context window limit. When this happens, OpenClaw "compacts" (summarizes) older messages. But before compacting, it runs a memory flush — giving the agent a chance to save important facts to disk before they're compressed away.
{
"agents": {
"defaults": {
"compaction": {
"reserveTokensFloor": 20000,
"memoryFlush": {
"enabled": true,
"softThresholdTokens": 4000,
"systemPrompt": "Session nearing compaction. Store durable memories now.",
"prompt": "Write any lasting notes to memory/YYYY-MM-DD.md; reply NO_REPLY if nothing to store."
}
}
}
}
}
This is one of OpenClaw's most innovative features — it prevents the "goldfish brain" problem where important context evaporates during long sessions.
⚙️ Configuration reference
{
"agents": {
"defaults": {
"memorySearch": {
"provider": "openai",
"model": "text-embedding-3-small",
"extraPaths": ["../team-docs"],
"query": {
"hybrid": {
"enabled": true,
"vectorWeight": 0.7,
"textWeight": 0.3,
"candidateMultiplier": 4,
"mmr": { "enabled": true, "lambda": 0.7 },
"temporalDecay": { "enabled": true, "halfLifeDays": 30 }
}
}
}
}
}
}
extraPaths— add external Markdown directories to the search indexcandidateMultiplier— fetch extra candidates before fusion (higher = better recall, slower)lambda— MMR trade-off: 1.0 = pure relevance, 0.0 = max diversityhalfLifeDays— temporal decay: 30 = daily-heavy workflows, 90 = reference-heavy
🧹 Maintenance
- Review MEMORY.md monthly. Remove stale facts, fix inaccuracies, merge duplicates.
- Archive old daily logs. After 3-6 months, move old logs to an archive folder. They'll still be searchable if in
extraPaths. - Edit directly. If the agent remembered something wrong — open the file, fix it. That's the whole point of plaintext.
- Git-track your memory:
openclaw memory status # Check index stats
openclaw memory index # Reindex if needed
cd ~/.openclaw/workspace
git init && git add MEMORY.md memory/
git commit -m "memory snapshot"
✅ For stronger behavior changes, put preferences in USER.md or SOUL.md (always loaded) rather than MEMORY.md (search-dependent). Direct instructions beat hoping the agent recalls a memory at the right time.
🔧 Troubleshooting
| Problem | Fix |
|---|---|
| Agent doesn't remember things | Check memorySearch is configured. Run openclaw doctor --deep --yes. |
| "Goldfish brain" in long chats | Enable compaction.memoryFlush. Tell agent: "Write this to memory." |
| Search returns irrelevant results | Enable MMR (mmr.enabled: true). Try adjusting vectorWeight/textWeight. |
| Old notes outrank recent ones | Enable temporalDecay with halfLifeDays: 30. |
| Embedding errors | Check API key for your embedding provider. Fallback: BM25-only works without keys. |
| Memory not updating | File watcher debounces at 1.5s. Check file permissions on memory/ directory. |