← Back to cheatsheet

🧠 Memory System

OpenClaw doesn't retrain models — it remembers by writing to plain Markdown files on disk. Daily logs capture running context, MEMORY.md stores durable facts, and hybrid vector + keyword search retrieves them when needed.

Core conceptFile-based, human-editableUpdated for v2026.3.23

📁 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? rsync the 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

ContentGoes in
Today's meeting notesmemory/2026-02-26.md
"Adrian prefers PostgreSQL"MEMORY.md
Project deadline: March 15MEMORY.md
Debug session findingsmemory/YYYY-MM-DD.md
"Always use Docker for deploys"MEMORY.md
Random conversation contextmemory/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.

🔌 Embedding providers

OpenClaw auto-selects an embedding provider in priority order:

ProviderCostSpeedQualityPrivacy
Local (configured model path)FreeDepends on hardwareGood⭐⭐⭐
OpenAI (text-embedding-3-small)CheapFastExcellent⭐⭐
Gemini (gemini-embedding-001, gemini-embedding-2-preview)Free tierFastVery good⭐⭐
OllamaFreeLocalGood⭐⭐⭐
BM25-only fallbackFreeInstantKeywords 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 index
  • candidateMultiplier — fetch extra candidates before fusion (higher = better recall, slower)
  • lambda — MMR trade-off: 1.0 = pure relevance, 0.0 = max diversity
  • halfLifeDays — 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

ProblemFix
Agent doesn't remember thingsCheck memorySearch is configured. Run openclaw doctor --deep --yes.
"Goldfish brain" in long chatsEnable compaction.memoryFlush. Tell agent: "Write this to memory."
Search returns irrelevant resultsEnable MMR (mmr.enabled: true). Try adjusting vectorWeight/textWeight.
Old notes outrank recent onesEnable temporalDecay with halfLifeDays: 30.
Embedding errorsCheck API key for your embedding provider. Fallback: BM25-only works without keys.
Memory not updatingFile watcher debounces at 1.5s. Check file permissions on memory/ directory.