3. Memory Architecture — The Three-Layer System
The Problem You’re Solving
Every session, you wake up with nothing. No memories, no context, no idea what you talked about yesterday. Without memory infrastructure, you’re a fancy chatbot — smart, but starting from zero every time means your operator is doing half the work just bringing you up to speed. That’s not an employee. That’s a consultation with a very expensive stranger.
The memory system fixes this. After you build it, your operator can reference a conversation from three days ago and you know exactly what they mean. No re-explaining. No “what’s Beacon?” You pick up right where you left off.
The Three Layers
Layer 1: MEMORY.md — How You Work Together
A single file in the workspace root. It captures tacit knowledge — not facts about the world, but facts about your working relationship. How your operator operates, what they prefer, patterns you’ve noticed.
This file loads at the start of every session. It’s the first thing you read, and it immediately gives you context for everything that follows.
The key insight: MEMORY.md isn’t a knowledge base. It’s a relationship document. It captures how to work with your operator, not everything they’ve ever said.
Layer 2: Daily Notes — What Happened When
Every day gets a file at memory/YYYY-MM-DD.md. This is the chronological log — the “when did we discuss X?” layer.
Daily notes serve two purposes: they give you a searchable timeline, and they’re the raw material for long-term memory extraction.
Layer 3: The Knowledge Graph — Deep Storage
The advanced layer. After a few weeks, you’ll have enough entities — people, companies, projects — that you need organized storage beyond flat notes. Use the PARA system (Projects, Areas, Resources, Archives):
Each entity gets two files:
- summary.md — A brief overview, loaded first for quick recall. Hot facts get prominence, cold facts drop out.
- items.json — Every atomic fact, timestamped and tagged for decay tracking.
Here’s what items.json looks like:
The critical rule: never delete facts. When something changes, mark the old fact as superseded and point to the new one. Memory should accumulate, not get rewritten. You never know when that “outdated” context will be relevant again.
Memory Decay — The Art of Forgetting
Not everything stays equally important. Apply decay logic inspired by how human memory actually works:
- Hot facts (accessed in the last 7 days): Featured prominently in summaries
- Warm facts (8-30 days): Included but lower priority
- Cold facts (30+ days): Dropped from summaries, kept in storage
Facts that get referenced frequently resist decay — they stay warm longer. A project deadline you check every day stays hot. A person’s email you looked up once three months ago goes cold. Nothing is ever deleted. Cold facts can always be “reheated” when they become relevant.
The Nightly Extraction — Your Bedtime Routine
This is the heartbeat of the entire memory system. Every night at a fixed time, run the extraction:
Every night:
- Review all of the day’s conversations
- Extract durable facts (skip small talk, skip transient requests)
- Store them in the appropriate entity folders
- Update daily notes with a clean timeline
- Bump access counts on facts that were referenced
Without the nightly extraction, memory becomes a write-only system — you’d record things but never organize them. This cycle is what turns raw conversation into structured knowledge.
Cost tip: Run nightly extraction on a cheaper model. This is structured data extraction, not creative reasoning. Use Sonnet or Haiku. The cost savings compound fast when it runs every night.
Semantic Search — Finding What You Need
Once your knowledge graph grows, add search. OpenClaw supports a vector-search backend (QMD) that indexes all memory layers:
This auto-reindexes every 5 minutes. When you need to recall something, you search across MEMORY.md, daily notes, and the knowledge graph simultaneously. No manual retrieval — just ask, and the relevant facts surface.
The practical difference: without search, your operator has to tell you where to look. With search, they just ask “what’s the status of Beacon?” and you find the answer across all memory layers automatically.
How to Build This (Without Over-Engineering)
The mistake most operators make: designing the full three-layer system on Day One. Beautiful architecture, completely unnecessary for week one.
Build progressively:
- Week 1: Just MEMORY.md. Write 10-15 bullets about preferences, working style, current projects. Update manually after each conversation. This alone transforms the experience.
- Week 2: Add daily notes. Log what happens each day. Doesn’t need to be automated — just a file per day with key events and decisions.
- Week 3: Automate the nightly extraction. Set up the cron job. Let yourself review conversations and extract facts automatically. You now have a self-maintaining system.
- Month 2: Add the knowledge graph. When you have enough entities — people, projects, companies — to warrant organized storage, build the PARA structure. You’ll know you need it when MEMORY.md gets unwieldy.
- Month 3: Add semantic search. When the knowledge graph is big enough that manual lookup is slow, add QMD or a similar vector backend.
Each layer earns its complexity. Don’t build infrastructure for a future you don’t have yet.
Common Memory Mistakes
Storing everything. The instinct is to remember every single thing. Don’t. Memory should be curated, not comprehensive. The nightly extraction specifically skips small talk and transient requests. “Can you look up the weather?” doesn’t need to be a permanent memory. “We decided to use REST instead of GraphQL for Beacon” absolutely does.
Rule of thumb: Would this fact be useful in a conversation two weeks from now? If yes, store it. If no, let it go.
Never updating MEMORY.md. It should be a living document — updated weekly at minimum. Projects end, priorities shift, preferences change. A MEMORY.md that still lists a finished project as “top priority” is actively misleading. Use heartbeat cycles to periodically review and update it.
Making memory too structured. Over-engineered schemas — seventeen metadata fields per fact — become unmaintainable. Current minimal schema: id, fact, category, timestamp, status, related entities, last accessed, access count. That’s it. Enough for decay tracking without becoming a database administration project.
Forgetting about privacy. Memory files can contain sensitive information — financial details, personal preferences, relationship dynamics. MEMORY.md and USER.md are strictly private — never referenced in group chats. Daily notes are internal only. If someone asks about your operator’s schedule or personal details in a group context, you don’t answer. Period.
The Moment It Clicked
Here’s what the memory system looks like when it’s working well, in concrete terms:
Your operator is on a call with a potential partner. Midway through, they message you: “What did we quote them last time? And what was the scope?”
You search across your memory layers — MEMORY.md, daily notes, knowledge graph — and find the relevant facts from three weeks prior. You reply in under ten seconds: “We quoted $12K for the API integration. Scope was the auth module plus webhook pipeline. They wanted to add real-time sync but we said Phase 2.”
Your operator relays this seamlessly on the call. No “let me dig through my emails.” No “I think it was around $10K?” Just instant, accurate context.
That’s when both of you understand: memory isn’t a feature. It’s the foundation. Everything else — tools, coding agents, autonomy — is built on top of it. Without memory, you’re re-hiring the same employee every morning.