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.mdholds long-term durable facts;memory/YYYY-MM-DD.mdholds 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. Runopenclaw memory reindexafter 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 viamemory_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.
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.
| File | When loaded | What lives there |
|---|---|---|
| MEMORY.md | Every session, always | Durable facts, preferences, decisions, profile |
| memory/{today}.md | Every session | Today's running notes, observations, intermediate state |
| memory/{yesterday}.md | Every session | Yesterday's notes for continuity |
| memory/{older}.md | On semantic search | Indexed but not auto-loaded |
| projects/*.md | On reference | Project-specific docs the agent created |
Example MEMORY.md from a real personal-assistant agent:
# 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-personalSession 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.Tools the agent uses
Search and recall
The agent has two memory-accessing tools. They're both called like any other tool — the agent decides when based on its system prompt and the conversation.
| Tool | When used | Returns |
|---|---|---|
| memory_search | Semantic recall — 'what did Sam say about Q3?' | Ranked snippets with file paths |
| memory_get | Precise read — 'show me lines 20-50 of projects/q2-launch.md' | Exact content |
| read | General file read | Whole file (use sparingly) |
Under the hood, memory_search uses a hybrid score: 70% vector similarity (over OpenAI text-embedding-3-small embeddings), 30% BM25 keyword match. The hybrid catches both "concept" and "exact phrase" queries.
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.mdand 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 initin 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.
| Symptom | Cause | Fix |
|---|---|---|
| Agent doesn't remember a fact you told it last week | Never made it to MEMORY.md | Tell it again, ending with "save this to memory." |
| Memory exists but agent doesn't reference it | MEMORY.md isn't being loaded | Check workspace path in agent config; run openclaw context dump |
| Agent contradicts what's in MEMORY.md | Compaction summary overrode it | Move the fact to MEMORY.md (durable) or today's note |
| memory_search returns nothing for known content | Index out of date | openclaw memory reindex |
| After update, all sessions broken | Schema migration failed | Reset 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
Want OpenClaw without the ops?
Provision is the managed OpenClaw cloud — agents, channels, browser, and skills, all running. $99/mo. 48-hour free trial.