Operate guide11 minUpdated 2026-05-06

How OpenClaw memory actually works.

OpenClaw doesn't have hidden memory. It's a Markdown folder you can open in a text editor. Once you understand which files load when, what gets indexed, and where memory_search and memory_get fit in, you can audit it, version it, and fix the "why does it keep forgetting" complaint for good.

Quick answers

  • Where is OpenClaw memory stored?

    Plain Markdown files at ~/.openclaw/agents/{agentId}/workspace/. MEMORY.md holds long-term durable facts; memory/YYYY-MM-DD.md holds daily notes. A SQLite vector index powers semantic recall.
  • Why does my OpenClaw agent keep forgetting?

    Three usual causes: (1) the fact never made it into MEMORY.md, (2) MEMORY.md isn't being loaded because the workspace path is wrong, or (3) compaction discarded it before the memory flush could save it. Tell the agent to save explicitly and edit MEMORY.md by hand if needed.
  • Can I edit OpenClaw's MEMORY.md by hand?

    Yes — and you should. It's plain Markdown. Add headings, sharpen phrasing, delete stale facts. Run openclaw memory reindex after big edits so the SQLite index catches up.
  • What loads automatically when a session starts?

    Three things: MEMORY.md, today's daily note, and yesterday's daily note. Older daily notes are searched on demand via memory_search. Project files load only when the agent references them.
  • What is the OpenClaw memory flush?

    A silent agent turn that runs before context compaction. It prompts the agent: "You're about to lose history. Save anything important." The agent reviews recent conversation and writes durable facts to MEMORY.md so they survive the upcoming summary.

Architecture

The shape of memory

OpenClaw doesn't use a hidden vector store, mysterious embeddings, or any "magic." It writes Markdown files. Once you internalize this, the rest of memory becomes obvious.

Memory is a folder. The folder lives at ~/.openclaw/agents/{agentId}/workspace/. You can cd into it. You can grep. You can git init if you want version-controlled memory.

~/.openclaw/agents/main/workspace/
workspace/
├── MEMORY.md              # Long-term, durable facts
├── memory/
│   ├── 2026-05-01.md     # Daily notes
│   ├── 2026-05-02.md
│   ├── 2026-05-03.md
│   └── 2026-05-04.md
├── recipients.md          # Custom files agents reference
├── projects/
│   └── q2-launch.md
└── .openclaw/
    └── memory.sqlite      # Vector index (regenerable)

The two key files

MEMORY.md + daily notes

Two files do most of the work. The rest is project-specific context the agent decides to keep.

FileWhen loadedWhat lives there
MEMORY.mdEvery session, alwaysDurable facts, preferences, decisions, profile
memory/{today}.mdEvery sessionToday's running notes, observations, intermediate state
memory/{yesterday}.mdEvery sessionYesterday's notes for continuity
memory/{older}.mdOn semantic searchIndexed but not auto-loaded
projects/*.mdOn referenceProject-specific docs the agent created

Example MEMORY.md from a real personal-assistant agent:

MEMORY.mdmarkdown
# About Sam

Sam is a product manager at a 50-person SaaS company. They prefer short,
direct messages and don't like preamble. Default to brief unless they
ask for detail.

## Standing rules

- Don't draft Slack messages with emoji unless asked
- For meeting requests, default to 30 min in their morning slot
- They check Telegram more reliably than email; route urgent stuff there

## Active projects

- Q2 launch: see projects/q2-launch.md
- Hiring: 2 PM roles open, full pipeline in projects/hiring.md

## Recurring tasks

- Daily digest at 09:00 weekdays only
- Weekly review every Friday 16:00 → posted to Slack #sam-personal

Session lifecycle

What loads when

Three triggers load memory automatically. Anything beyond these the agent has to look up explicitly.

  • Session start. MEMORY.md, today's daily note, yesterday's daily note, and the system prompt all flow into the agent's context as the first messages.
  • memory_search call. Agent decides "I don't remember the Q1 results, let me look" → vector search returns ranked snippets from older daily notes.
  • Memory flush before compaction. Before history gets summarized, a silent turn prompts the agent to save anything new and important.

Inspecting context

openclaw context dump --agent main prints exactly what's in the agent's window right now, including which memory files are loaded. Use this when memory feels off — you'll see whether the file the agent should be reading is actually loaded.

Why it matters

The memory flush

Without it, conversations evaporate when context fills up. With it, durable facts survive arbitrary numbers of compactions. The flush is one of OpenClaw's best ideas.

The flow:

  • Agent's context approaches limit (default 80%)
  • OpenClaw triggers a silent turn: "You're about to compact. Save anything important."
  • Agent reviews recent history and writes to MEMORY.md or today's daily note
  • Compaction summarizes the conversation history
  • Next turn starts with summary + freshly-saved memory still intact

You almost never want to disable this. The cost is one extra turn per compaction (cheap); the benefit is the agent doesn't forget what you told it 30 messages ago.

Field-tested

Patterns that work

From running OpenClaw agents in production:

  • Edit MEMORY.md by hand. The agent's decisions about what to save aren't always great. Open the file weekly, prune what's stale, sharpen what's vague.
  • Use headings aggressively. Each section becomes a memory_search anchor. "## Active projects" beats a wall of paragraphs.
  • Move project-specific stuff to its own file. Don't bloat MEMORY.md with project details. Create projects/q2-launch.md and let memory_search find it.
  • Keep a "rules" section. Standing preferences (no emoji, prefer Telegram, default meeting length) belong at the top of MEMORY.md so they're always-loaded.
  • Version it. git init in the workspace. Every change becomes auditable. Disasters become recoverable.

Debug

When memory breaks

The "my agent keeps forgetting" complaint usually has one of three causes.

SymptomCauseFix
Agent doesn't remember a fact you told it last weekNever made it to MEMORY.mdTell it again, ending with "save this to memory."
Memory exists but agent doesn't reference itMEMORY.md isn't being loadedCheck workspace path in agent config; run openclaw context dump
Agent contradicts what's in MEMORY.mdCompaction summary overrode itMove the fact to MEMORY.md (durable) or today's note
memory_search returns nothing for known contentIndex out of dateopenclaw memory reindex
After update, all sessions brokenSchema migration failedReset sessions, memory survives

Compaction can lose work

The memory flush is best-effort. If the agent mid-task gets compacted and the flush misses a critical detail, that detail is gone. For high-stakes runs (like multi-step browser flows), save state to a project file proactively rather than relying on the flush.

FAQ

Where does OpenClaw memory actually live?
On disk, in plain Markdown. Each agent gets a workspace at ~/.openclaw/agents/{agentId}/workspace/ with MEMORY.md (long-term) and memory/YYYY-MM-DD.md (daily notes). A SQLite database at ~/.openclaw/memory/{agentId}.sqlite indexes them for semantic search.
Why is my agent forgetting things?
Three usual culprits: (1) the fact never made it into MEMORY.md — the agent treated it as transient. (2) Memory wasn't loaded at session start because the file path is wrong. (3) Compaction discarded it before the memory flush could save it. The 'when memory breaks' section walks each one.
Can I edit MEMORY.md by hand?
Yes, and you should. It's just Markdown. Add headings, edit phrasing, delete stale facts. Run `openclaw memory reindex` after big edits so the SQLite index catches up.
How does the memory flush work?
Before context compaction, OpenClaw runs a silent agent turn that says: 'You're about to lose history. Save anything important to memory.' The agent decides what's worth saving and writes to MEMORY.md or the daily note. It runs every time, not just when context is tight.
Can I share memory between agents?
Yes — set workspace paths to point at the same directory in multiple agents' configs. They share files; each writes its own daily notes. Useful for sub-agent setups where the orchestrator and workers need the same project context.
What's the difference between memory_search and memory_get?
memory_search does semantic recall over the SQLite index — 'find me anything about Q3 OKRs' returns ranked snippets. memory_get is a precise read of a specific file/line range when the agent already knows where to look. Both are agent-callable tools.

Want OpenClaw without the ops?

Provision is the managed OpenClaw cloud — agents, channels, browser, and skills, all running. $99/mo. 48-hour free trial.