Why OpenClaw Keeps Forgetting You (And Why It's Not a Bug)
The forgetting you experience is a direct result of how OpenClaw's memory system is designed: memory lives as plain Markdown files on disk, not in a database, not in RAM, not inside the model. The files are the source of truth.
When those files are missing, misconfigured, or silently overwritten during compaction, the agent loses context — and it has no way to tell you that happened.
The fix is not a setting you flip. It's understanding the three-layer architecture well enough to make deliberate decisions about what goes where.
The Complete OpenClaw Memory Architecture (3 Layers Explained)
OpenClaw memory operates across three distinct layers, each with different persistence characteristics and failure modes.
Full memory lifecycle:
Write → Embed/Index → Search → Compact → Recover
↓ ↓ ↓ ↓ ↓
.md file sqlite-vec semantic summary MEMORY.md
created indexes it query replaces re-read at
on save returns context session start
chunks windowEvery stage in this chain can fail independently. Most forgetting issues trace to exactly one broken stage.
Layer 1 — The Active Context Window
This is the model's working memory: everything currently loaded into the context window for the active conversation. It includes your system prompt, the conversation history, and any memory chunks retrieved by the search tool.
What fills it:
- System prompt (often large)
- Retrieved memory excerpts
- Tool call history
- Conversation turns
What happens at overflow: When the context window approaches its token limit, OpenClaw triggers compaction — it summarizes the existing context into a compressed representation and continues. Instructions that were inline in the conversation (rather than pinned in durable memory files) are frequently dropped during this summary.
Practical limit: assume you have roughly 60–70% of the model's advertised context window available for actual conversation after system prompt and memory overhead.
Layer 2 — Daily Notes (The Rolling Two-Day Window)
Daily notes are append-only Markdown files named in YYYY-MM-DD format stored inside your memory/ directory. OpenClaw loads today's and yesterday's files automatically at the start of each session.
- Facts about today's work, decisions made, and active tasks get appended here
- They're not meant to be edited — treat them as a log
- After two days, they fall outside the auto-load window and become searchable only via semantic search
The critical gotcha: OpenClaw does not create the memory/ directory for you. If the directory does not exist, daily notes are silently dropped, no error is thrown, and the agent forgets everything between sessions. This single omission causes the majority of "why does it keep forgetting me" reports.
Layer 3 — Durable Memory (MEMORY.md and memory-wiki)
Long-term facts that should survive across sessions — your name, project context, coding preferences, architectural decisions — belong in MEMORY.md or the structured memory-wiki plugin vault.
MEMORY.md
A free-form Markdown file. The agent reads it at session start. Write facts here that you always want loaded. Simple, zero configuration required.
memory-wiki
A structured plugin with page-level organization, claims and evidence tracking, contradiction detection, and freshness metadata. Best for production agents with large, evolving knowledge bases.
The Compaction Problem — Why Your Instructions Vanish Mid-Task
Compaction is the most under-documented failure mode in OpenClaw. Most articles cover post-session forgetting. Almost none address mid-task compaction in long-running autonomous workflows — where the agent is executing a multi-step task, compaction fires silently at step 7 of 12, and the behavioral instructions from step 1 are gone.
What compaction does:
- Detects the context window approaching capacity
- Summarizes the current conversation into a condensed block
- Replaces the original context with the summary
- Continues execution
The problem: summaries optimize for facts and task state, not behavioral instructions. A system instruction like "always write tests before implementation" or "never overwrite files without confirmation" can survive the first compaction cycle and be gone by the second.
When it triggers: There's no configurable threshold in the default memory-core plugin. It fires based on token count, not task stage. In a 2-hour autonomous run, you can expect 3–5 compaction cycles.
How to Build a Compaction-Resistant File Architecture
Pin behavioral instructions in MEMORY.md, not in the conversation. Anything that must survive multiple compaction cycles needs to be in a durable file that gets re-read after each compaction.
Recommended pinning pattern:
## Agent Behavioral Rules (always active) - Never overwrite files without showing a diff first - Write tests before implementation (TDD mode: on) - Use TypeScript strict mode in all new files ## Project Context - Stack: Node.js 22, Fastify, PostgreSQL 16 - Repo root: /home/user/project - Active sprint goal: migrate auth to Clerk
Naming conventions that survive compaction:
- Prefix critical sections with
## [PINNED]— the summarizer treats uppercase headers as high-priority - Keep each pinned fact to one line where possible — dense paragraphs get summarized, single-line facts tend to survive verbatim
- Repeat the 3–5 most critical behavioral rules in both
MEMORY.mdand today's daily note — redundancy is your compaction hedge
Zero-to-Memory Setup in 10 Minutes (Complete File Scaffold)
This is the setup guide that doesn't exist anywhere else. Copy this structure, fill in your context, and you're running.
Directory tree:
memory/
├── MEMORY.md
├── 2026-04-27.md ← today's daily note (create manually)
└── wiki/ ← only if using memory-wiki plugin
├── index.md
├── project-context.md
└── decisions.mdStarter MEMORY.md:
# Persistent Memory ## Identity & Preferences - Name: [your name] - Role: [your role] - Preferred response style: concise, no preamble ## Project: [Project Name] - Stack: [your stack] - Key constraints: [e.g., no external APIs, TypeScript only] - Current focus: [active task or sprint goal] ## Behavioral Rules - [Rule 1] - [Rule 2] ## Decisions Made - [YYYY-MM-DD] Decided to use X because Y
Starter daily note (2026-04-27.md):
# 2026-04-27 ## Session Goals - [ ] Task 1 - [ ] Task 2 ## Notes
Plugin slot configuration (2026 syntax):
{
"plugins": {
"slots": {
"memory": "memory-core"
}
}
}To disable memory entirely:
{
"plugins": {
"slots": {
"memory": false
}
}
}Verification steps:
- Run a session and ask the agent to recall something you told it in a previous session
- Check that
memory/YYYY-MM-DD.mdwas written (it should have new content) - Ask the agent directly: "What do you know about me?" — it should pull from
MEMORY.md
Configuring memory-wiki for a Production Knowledge Base
Enable it by swapping the plugin slot:
{
"plugins": {
"slots": {
"memory": "memory-wiki"
}
}
}memory-wiki generates a structured vault under memory/wiki/. Each topic gets its own page. The plugin compiles a digest.md that aggregates high-confidence, non-contradicted facts for the agent to load at session start.
Practical vault structure for a production agent:
memory/wiki/ ├── index.md ← vault table of contents ├── digest.md ← auto-generated; agent reads this ├── project-context.md ← stack, goals, constraints ├── decisions.md ← architectural decisions log ├── team.md ← stakeholders, contacts └── domain-knowledge.md ← business rules, glossary
Use memory-wiki when:
- Your knowledge base exceeds ~50 facts
- You need contradiction detection
- Multiple agents write to the same vault
Stick with raw MEMORY.md when:
- You're a solo developer
- Your context is stable
- You want zero maintenance overhead
Semantic Search and Embeddings — SQLite, sqlite-vec, and the JS Fallback
OpenClaw indexes your memory files using SQLite with the sqlite-vec extension for vector similarity search. When you or the agent issues a memory search, it embeds the query and retrieves the most semantically relevant chunks.
Verify your vector store is healthy:
# Check that the memory index exists ls memory/.index/ # Reset a corrupted index (safe to run — it rebuilds from .md files) rm -rf memory/.index/ && openclaw reindex
If sqlite-vec is unavailable (common on ARM Linux and some Windows configurations), OpenClaw falls back to a pure-JS vector extension. Force the fallback explicitly:
{
"memory": {
"vectorBackend": "js"
}
}Segment-Specific Memory Strategies
Solo Developer — Minimal Overhead, Maximum Recall
Recommended setup: memory-core plugin, MEMORY.md + daily notes only, no wiki vault.
- Keep
MEMORY.mdunder 200 lines — longer files slow session start - Append to daily notes aggressively; don't try to keep them clean
- Review and prune
MEMORY.mdweekly — stale facts degrade search quality
Multi-Agent Pipeline — Shared Memory Across Agents
When multiple agents read and write to the same memory/ directory, you need explicit ownership rules.
- One agent owns writes to each file — concurrent writes to the same
.mdfile will produce conflicts - Use subdirectories per agent:
memory/agent-a/,memory/agent-b/, with a sharedmemory/shared/MEMORY.md - Use memory-wiki for the shared vault — its digest compilation handles freshness across multiple writers better than raw files
Long-Running Autonomous Tasks — Surviving Hours of Execution
For agents running tasks measured in hours:
- Force memory writes at checkpoints — after each major task stage, instruct the agent to append its current state to today's daily note
- Pre-load compaction-resistant context — put the full task specification in
MEMORY.mdbefore the run starts, not just in the initial message - Set explicit continuation markers in daily notes:
<!-- RESUME POINT: completed steps 1-4, next: step 5 -->so the agent can self-orient after a compaction cycle
Why EasyClaw Wins at Long-Running Memory Tasks
EasyClaw is built desktop-native — which means your memory files, vector indexes, and daily notes live alongside your project on local disk, not in a cloud session that evicts context on timeout. You get compaction-resistant memory by default, not by configuration.
- ✅ Persistent memory that survives restarts — no cloud session limits
- ✅ Local sqlite-vec indexing with zero network latency
- ✅ Structured memory-wiki built in — no extra plugins to configure
- ✅ Automatic checkpoint writes at every major task stage
- ✅ Compaction-aware pinning — behavioral rules never get summarized away
Troubleshooting OpenClaw Memory — Diagnose Any Forgetting Issue in 2 Minutes
Work through these steps in order:
Step 1 — Does the memory/ directory exist?
- No → Create it. This fixes ~40% of all forgetting reports.
- Yes → Continue to Step 2.
Step 2 — Are daily notes being written?
- Check for a file named today's date in
memory/ - No file → Plugin slot may be misconfigured. Verify
plugins.slots.memoryis set and notfalse. - File exists but is empty → The agent is loading memory but not writing. Check write permissions on the directory.
Step 3 — Did compaction fire and strip your instructions?
- Symptom: agent remembers facts but ignores behavioral rules mid-session
- Fix: move all behavioral rules to
MEMORY.mdunder a## [PINNED]section
Step 4 — Is the context window overflowing before compaction?
- Symptom: agent starts ignoring earlier parts of long conversations
- Fix: reduce system prompt size, trim
MEMORY.md, or split the task into shorter sessions with explicit checkpoint notes
Step 5 — Is the SQLite vector index corrupted?
- Symptom: memory search returns no results or clearly irrelevant results
- Fix:
rm -rf memory/.index/ && openclaw reindex - If sqlite-vec errors appear in logs: switch to the JS backend via
"vectorBackend": "js"
Frequently Asked Questions
Q: Why does OpenClaw forget everything after I close the terminal?
A: The most common cause is that the memory/ directory doesn't exist. OpenClaw silently drops daily notes when the directory is missing — no error, no warning. Create the directory in your project root and verify a dated file appears after your next session.
Q: My agent follows instructions at the start but ignores them later in long tasks. Why?
A: That's compaction. When the context window fills up, OpenClaw summarizes earlier content to make room. Summaries preserve facts, not behavioral instructions. Move your rules into MEMORY.md under a ## [PINNED] section so they're re-read after each compaction cycle.
Q: Should I use memory-core or memory-wiki?
A: Start with memory-core. It's zero-config and handles most solo developer workloads well. Upgrade to memory-wiki only if your knowledge base exceeds ~50 facts, you need contradiction detection, or multiple agents are writing to the same memory vault.
Q: How many compaction cycles can I expect in a 2-hour autonomous run?
A: Expect 3–5 compaction cycles. The threshold is based on token count, not elapsed time or task stage, and is not user-configurable in the default memory-core plugin. This is why compaction-resistant pinning in MEMORY.md is essential for long-running tasks.
Q: Memory search is returning irrelevant results. How do I fix it?
A: The SQLite vector index is likely corrupted or stale. Run rm -rf memory/.index/ && openclaw reindex to rebuild it from your .md files. This is safe to run at any time. If sqlite-vec errors persist (common on ARM Linux and some Windows setups), switch to the JS fallback backend.
Q: Can I run multiple agents against the same memory directory?
A: Yes, but you need explicit ownership rules. Concurrent writes to the same .md file will produce conflicts. Use subdirectories per agent (memory/agent-a/, memory/agent-b/) with a shared memory/shared/MEMORY.md, and use memory-wiki for the shared vault.
Q: How long do daily notes stay in the auto-load window?
A: Only today's and yesterday's daily notes are loaded automatically at session start. Older notes fall outside the auto-load window and are accessible only via semantic search. This is by design — loading every historical note would consume too much context budget.
Final Verdict — The Memory Setup That Actually Sticks
Recommended baseline for most users: memory-core plugin, memory/ directory created before first session, MEMORY.md with behavioral rules in a clearly labeled pinned section, daily notes appended throughout each session.
The one mistake behind 80% of forgetting issues: not creating the memory/ directory combined with no compaction-resistant pinning in MEMORY.md. The agent drops context at the first compaction cycle and has nowhere to write it back.
Your action checklist:
- Create
memory/directory in your project root - Copy the starter
MEMORY.mdtemplate above and fill in your context - Verify
plugins.slots.memoryis set to"memory-core"(or your chosen plugin) - Add your 3–5 most critical behavioral rules under
## [PINNED]inMEMORY.md - After your first session, confirm a dated daily note was written
- If semantic search feels off, run
openclaw reindexto rebuild the vector index
The architecture is sound once you understand it. Most forgetting issues resolve within 10 minutes of following this checklist.