Install
openclaw skills install openclaw-memManage, optimize, and troubleshoot the OpenClaw memory system — MEMORY.md curation, daily logs (memory/YYYY-MM-DD.md), memory_search tuning, compaction survi...
openclaw skills install openclaw-memOpenClaw memory is plain Markdown on disk. The files are the single source of truth.
The model only "remembers" what gets written to disk — nothing stays in RAM between sessions.
Memory search tools are provided by the active memory plugin (default: memory-core).
memory/YYYY-MM-DD.mdmemory_search.MEMORY.mdMEMORY.md and memory.md exist, only MEMORY.md is loaded.bootstrapMaxChars).~/.openclaw/workspace/
├── MEMORY.md # Long-term curated memory (main session only)
├── memory/
│ ├── 2026-03-17.md # Today's daily log
│ ├── 2026-03-16.md # Yesterday's log (also auto-loaded)
│ └── ... # Older logs (searchable, not auto-loaded)
├── AGENTS.md # Operating manual, boot sequence
├── SOUL.md # Persona, tone, values
├── USER.md # Human profile
└── TOOLS.md # Environment-specific config
| Content Type | Destination | Why |
|---|---|---|
| Durable decisions & preferences | MEMORY.md | Loaded every session |
| Iron-law rules the agent must always follow | MEMORY.md | Survives compaction |
| Today's work notes, events, context | memory/YYYY-MM-DD.md | Append-only log |
| One-time instructions | Chat (or daily log) | Ephemeral by design |
| Behavioral rules | AGENTS.md or SOUL.md | Always in context |
OpenClaw exposes two agent-facing tools:
memory_search — Semantic RecallfinalScore = vectorWeight × vectorScore + textWeight × textScore.memory_get — Targeted File ReadAdd this rule to AGENTS.md:
## Memory Protocol
- ALWAYS run memory_search before acting on tasks that reference past context.
- Do NOT guess from conversation history alone — check your notes.
Without this, the agent guesses instead of checking its memory files.
Long conversations fill the context window. When it hits the threshold, OpenClaw compacts (summarizes/truncates) older messages. Anything only in the conversation — including instructions typed in chat — can vanish.
Before compaction fires, OpenClaw triggers a silent agentic turn that reminds the model to write durable notes to disk.
Default config:
{
"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 with NO_REPLY if nothing to store."
}
}
}
}
}
contextWindow - reserveTokensFloor - softThresholdTokens.sessions.json).NO_REPLY so user doesn't see it.workspaceAccess: "ro" or "none".memoryFlush.enabled = true with enough buffer.local — if memorySearch.local.modelPath is configured + file existsopenai — if OpenAI API key is availablegemini — if Gemini API key is availablevoyage — if Voyage API key is availablemistral — if Mistral API key is availableAlso supported: ollama (local/self-hosted, not auto-selected).
Important: Codex OAuth covers only chat/completions — it does NOT work for embeddings. You need a separate API key for your embedding provider.
{
"agents": {
"defaults": {
"memorySearch": {
"provider": "openai",
"model": "text-embedding-3-small",
"query": {
"hybrid": true
}
}
}
}
}
~/.openclaw/memory/<agentId>.sqlite.Vector + Keyword → Weighted Merge → Temporal Decay → Sort → MMR → Top-K Results
Old notes can outrank recent ones by raw similarity. Enable decay to fix this:
Near-duplicate daily logs can crowd out diverse results. MMR removes redundancy:
memory_search returns redundant/near-duplicate snippets.For power users who want better search quality:
{
"memory": {
"backend": "qmd",
"citations": "auto",
"qmd": {
"includeDefaultMemory": true,
"update": { "interval": "5m", "debounceMs": 15000 },
"limits": { "maxResults": 6, "timeoutMs": 4000 },
"paths": [
{ "name": "docs", "path": "~/notes", "pattern": "**/*.md" }
]
}
}
}
bun install -g https://github.com/tobi/qmd.memory.qmd.sessions.enabled = true.Index files outside the default workspace:
{
"agents": {
"defaults": {
"memorySearch": {
"extraPaths": ["../team-docs", "/srv/shared-notes/overview.md"]
}
}
}
}
.md files.Run /context list in your OpenClaw session to check:
MEMORY.md loading? If "missing" → not in context → zero effect.| Symptom | Cause | Fix |
|---|---|---|
| Agent "forgot" a rule | Rule was in chat, not a file | Move to MEMORY.md or AGENTS.md |
| memory_search returns nothing | Embedding provider not configured | Set API key for openai/gemini/ollama |
| memory_search returns stale results | No temporal decay | Enable decay in memorySearch config |
| memory_search returns duplicates | No MMR re-ranking | Enable MMR diversity filter |
| MEMORY.md not loading | File too large or in group session | Trim file; check session type is private |
| 401 errors on search | Wrong/missing embedding API key | Set correct key (Codex OAuth won't work) |
| Agent loses context mid-conversation | Compaction wiped it | Enable memoryFlush; put rules in files |
MEMORY.md exists and is < 10,000 chars (ideal) or < 20,000 chars (max)memory/ directory exists with recent daily logsmemoryFlush.enabled = true in compaction configAGENTS.md includes "search memory before acting" rulewc -c ~/.openclaw/workspace/*.md to audit file sizesFor users who need memory beyond the built-in system:
@mem0/openclaw-mem0)openclaw-supermemory)MEMORY.md — remove outdated facts, promote important daily-log entries.memory/*.md for recurring patterns and hard-won rules.MEMORY.md or to skill SKILL.md files.cd ~/.openclaw/workspace
git init # if not already
git add memory/ MEMORY.md
git commit -m "Memory backup $(date +%Y-%m-%d)"
Exclude: ~/.openclaw/credentials/ and openclaw.json (contain secrets).
| File | Loaded When | Scope | Survives Compaction |
|---|---|---|---|
AGENTS.md | Every session start | All sessions | ✅ Yes |
SOUL.md | Every session start | All sessions | ✅ Yes |
MEMORY.md | Session start (private only) | Main session | ✅ Yes |
memory/today.md | Session start | Main session | ✅ Yes |
memory/yesterday.md | Session start | Main session | ✅ Yes |
memory/older.md | Via memory_search only | On-demand | ✅ Yes |
| Chat instructions | During conversation | Current context | ❌ No |