How to Give Your OpenClaw Agent Long-Term Memory (The MEMORY.md System Explained)
Every AI assistant has the same dirty secret: it wakes up dumb every session.
You spend an hour giving your agent context. It does great work. Next time you open it? Gone. You start over.
This is the #1 frustration in the OpenClaw community — and it’s completely solvable. OpenClaw has a built-in memory architecture that most users never fully use. Here’s how it works, and how to set it up properly.
Why AI Agents Forget (The Real Reason)
Language models are stateless. They have no persistent memory between conversations — each session starts with a blank context window. Whatever you discussed yesterday isn’t in there unless something puts it there.
This isn’t a bug. It’s how transformers work. The fix isn’t magic — it’s just file I/O. You write things down, and the agent reads them at the start of the next session.
OpenClaw formalizes this into a system.
The Three Layers of OpenClaw Memory
Layer 1: MEMORY.md — Your Long-Term Store
This is the most important file. Think of it as a curated knowledge base your agent maintains about itself, your preferences, ongoing projects, and key decisions.
The agent reads this file at the start of every session. It should contain:
- Active projects — what’s currently in flight
- Key decisions — choices you’ve made and why
- Your preferences — how you like things done
- Useful patterns — things that worked, things that didn’t
- Ongoing context — deadlines, waiting-on items, recurring tasks
What it should NOT contain:
- Raw conversation logs
- Temporary tasks that are done
- Trivia that won’t matter next week
Keep it scoped. The agent can only act on what it can actually read — a bloated MEMORY.md is worse than a focused one.
Example structure:
# MEMORY.md
## Active Projects
- MarketMai blog: posting daily, topics queued in post-queue.json
- OpenClaw skill: "xcellent" installed, testing in progress
## Key Decisions
- Use Cloudflare Pages for all static deployments
- Buttondown for email, 'free-prompts' tag for lead magnet subscribers
## My Preferences
- No fluff in responses. Get to the point.
- Prefer bullet lists over prose in Discord
- Always use trash instead of rm
## What's Working
- Daily cron posts blog → tweets automatically
- Memory files updated after each meaningful session
Layer 2: Daily Notes — memory/YYYY-MM-DD.md
These are the raw session logs. More informal, more detailed, more ephemeral.
Each day (or each session), your agent can append notes about what happened:
- What tasks were completed
- What was discovered
- Decisions made in this session
- Anything that might matter tomorrow
Your AGENTS.md should instruct the agent to read today’s and yesterday’s daily notes on startup. Two days of context is usually enough without overwhelming the context window.
Why separate from MEMORY.md?
Daily notes are noisy. They capture everything so nothing is lost. MEMORY.md is curated — you distill the important stuff into it and let daily notes age out.
Layer 3: Domain-Specific Files
For complex setups, you’ll want additional files:
USER.md— who you are, your preferences, how to communicate with youSOUL.md— the agent’s personality and operating principlesAGENTS.md— what each agent is responsible for in a multi-agent setupTOOLS.md— environment-specific notes (device names, SSH hosts, etc.)
These don’t change often, but they’re critical. An agent that knows you prefer direct communication and central timezone behaves very differently than one that doesn’t.
How to Structure Your MEMORY.md for Maximum Recall
The biggest mistake: writing MEMORY.md like a journal. Your agent isn’t reading it for narrative — it’s scanning for usable context.
Use headers. The agent can jump to relevant sections.
Use short, scannable bullets. Dense prose gets skimmed. Bullets get parsed.
Date important entries. “Decided to use Cloudflare Pages (2026-02-15)” is more useful than “we use Cloudflare Pages” — it tells the agent this was a deliberate, recent decision.
Prune ruthlessly. Every session, look at MEMORY.md and delete things that no longer matter. A focused 200-line file beats a bloated 2000-line one.
Think: what would I want to know if I woke up with no memory? That’s what goes in.
Setting Up Automatic Memory Updates
The system only works if the agent actually writes things down. You need two things:
1. Instructions in AGENTS.md
Tell your agent explicitly:
## Memory
You wake up fresh each session. These files are your continuity:
- **Daily notes:** `memory/YYYY-MM-DD.md` — raw logs of what happened
- **Long-term:** `MEMORY.md` — curated key context
Always read MEMORY.md on startup.
Update it after meaningful work with key decisions and outcomes.
2. A trigger at the end of sessions
Train yourself (and your agent) to end sessions with memory updates. A simple prompt like “Update memory files with anything important from this session” takes 30 seconds and compounds massively over time.
Supermemory Integration (Optional)
OpenClaw also supports supermemory — an external service that stores semantic memories and injects relevant context into each session automatically.
You’ll see it appear in your system context as a block of recalled context. It works differently from file-based memory:
- File memory = you control exactly what’s stored, agent reads it explicitly
- Supermemory = semantic search over past conversations, injected automatically
Both have a place. File memory is great for structured, curated context. Supermemory is great for surfacing relevant past conversations you didn’t explicitly save.
For most users, file memory alone is powerful enough to start.
Common Mistakes (And How to Fix Them)
Mistake: Relying on the model to “remember” without files Fix: It won’t. Write it down.
Mistake: Writing MEMORY.md in dense paragraphs Fix: Bullets and headers. Always.
Mistake: Never pruning Fix: Outdated memory is noise. Remove completed projects. Remove stale context. Keep it current.
Mistake: Not reading memory at startup Fix: Add explicit instructions in AGENTS.md: “Read MEMORY.md before doing anything else.”
Mistake: One giant MEMORY.md for everything Fix: In multi-agent setups, scope each agent’s memory to their domain. Your creative agent doesn’t need to know about your devops setup.
The Compound Effect
Here’s the thing about this system: it compounds.
Week one, your agent knows your basic preferences. Week four, it knows your entire project stack, your communication style, what’s worked and what hasn’t. Month three, it behaves like someone who’s been working with you for years — because in a sense, it has.
The agents that feel dumb are usually the ones with empty memory files. The ones that feel almost eerily good at their job? They have someone maintaining their memory carefully.
This is the unsexy secret to AI agent productivity: it’s not the model, it’s the files.
Start simple. Create a MEMORY.md in your workspace, add the five most important things about your current projects, and tell your agent to read it at startup.
Then at the end of today’s session — write something down.
Your future self (and your future agent) will thank you.
OpenClaw is a self-hosted AI agent platform. Learn more at openclaw.ai or follow @marketmai_ai for daily automation insights.
Suggested
Want the full MarketMai stack?
Get all 7 digital products in one premium bundle for $49.
View Bundle