Fractal Memory Architecture: How We Gave Our AI Agent a Permanent Memory
Every AI agent wakes up with amnesia. We got tired of it. So we built a layered memory system that gives our agents persistent context across hundreds of sessions — and it's been running in production for 20+ days.
Our main agent is named Larry. He wakes up every session and the first thing he does is read his memory files. By the time he's done — about 30 seconds later — he knows everything that happened yesterday, the key decisions from this week, and the curated lessons from the last month. He knows which projects are in progress, what we were debugging last Tuesday, and what decisions we made that he should never reverse.
He never asks "what were we working on?" He just knows. Because we built a memory system that actually works.
Here's exactly how it works.
The Amnesia Problem
This is the fundamental limitation nobody talks about enough when they pitch you on AI agents: they have no memory.
Not "limited memory." No memory. Every session starts with a blank context window. The model literally has no idea who you are, what you've been working on, or what happened yesterday — unless you tell it right now.
The naive fix is to dump everything into the context window at session start. That works for a while. Then your project grows. You have three active builds, a dozen decisions that can't be undone, API credentials scattered across configs, and six months of project history. You can't just paste all of that into every session — you'd burn your entire context window before doing any actual work.
There's also the within-session problem. Long sessions hit token limits. When that happens, most frameworks start "compacting" — summarizing old messages to make room. Details get lost. Decisions made three hours ago get reduced to vague references. Our agent once forgot where a config file lived because the specific path got compressed away.
We needed something better. So we built Fractal Memory.
The Core Idea: Memory Organized Like a Fractal
A fractal looks the same at every zoom level — complex up close, simple from a distance. That's the key insight we borrowed for this memory system.
Close up (yesterday), you want full detail. Every decision, every file path, every error message. Zoom out to last week, and you want themes and outcomes — not a transcript of every conversation. Zoom out to last month, and you want the big picture: what changed, what worked, what we learned.
The memory system stores everything at every zoom level. When a session starts, the agent loads the right zoom level for each time period. Today and yesterday at full detail. This week at medium detail. Long-term at high-level summary. Full context, fraction of the tokens.
The Architecture
📝 Daily Notes
memory/YYYY-MM-DD.md — raw logs, written in real-time
✨ Refined Dailies
memory/refined/YYYY-MM-DD.md — decisions, builds, blockers, next steps
📅 Weekly Summaries
memory/weekly/YYYY-Wnn.md — themes, trajectory, wins/losses
🗓️ Monthly Overviews
memory/monthly/YYYY-MM.md — big picture, key lessons promoted up
🧠 Long-Term Memory (MEMORY.md)
Curated wisdom — the distilled essence of everything worth keeping
📌 Sticky Notes
memory/sticky-notes/ — devices, accounts, infra details, preferences. Always loaded.
All layers are plain markdown files. Every rollup is done by an AI sub-agent on a cron schedule.
Each Layer, Explained
Layer 1: Daily Notes (memory/YYYY-MM-DD.md)
This is the raw feed. Every session, Larry appends to today's daily note. Not a sanitized summary — the real stuff. What we built, what broke, what decisions we made and why, which files we touched, what commands we ran, what errors we hit.
Think of it like a ship's log. Not written for posterity — written to capture what actually happened while it's fresh. The detail here is high because nothing has been thrown away yet.
At session start, Larry reads today's daily (if it exists) and yesterday's. That's it for the daily layer — just the last two days at full fidelity.
Layer 2: Refined Dailies (memory/refined/YYYY-MM-DD.md)
Every night at 11:30 PM, a cron job fires. It spawns a Gemini Flash sub-agent, hands it the raw daily notes plus any session transcripts from the day, and says: distill this.
The output is a structured summary with clear sections: decisions made, things built, problems encountered, blockers, and next steps. It's maybe 20% the length of the raw daily — but contains 80% of the important signal.
These refined dailies are what the weekly rollup reads. They're also what gets loaded if you need context from earlier this week — you get the essence without wading through raw logs.
Layer 3: Weekly Summaries (memory/weekly/YYYY-Wnn.md)
Every Sunday at 11:45 PM, another sub-agent reads all seven refined dailies from the past week and synthesizes them into a weekly summary. The focus shifts from events to patterns: what were the dominant themes? What's the project trajectory? What worked, what didn't?
This is the layer that gives context like: "Week 3 was mostly debugging the Telegram bot — we got it stable by Thursday, then pivoted to the credential vault." That's the kind of trajectory context that makes an agent feel coherent across days instead of just day-to-day.
At session start, Larry loads this week's weekly summary. One file. Full week of context.
Layer 4: Monthly Overviews (memory/monthly/YYYY-MM.md)
On the first of each month at 12:15 AM, a sub-agent reads all the weekly summaries from the prior month and produces a monthly overview. The zoom level here is strategic — what was the overall arc? What are the biggest lessons learned? What changed about how we work?
The monthly rollup also promotes key lessons up to long-term memory. If a pattern emerged strongly enough to show up across multiple weeks, it probably belongs in MEMORY.md permanently.
Layer 5: Long-Term Memory (MEMORY.md)
This is the curated distillation. Not a log. Not a summary. A set of things that are permanently true and worth remembering — the kind of knowledge a human would hold in actual long-term memory rather than their notes.
Things like: architectural decisions we're committed to. Preferences. Hard lessons from mistakes we don't want to repeat. Recurring patterns about how we work. Context about ongoing relationships and projects.
Larry reads MEMORY.md at the start of every main session. It's the most important file he has — but also the most compact. Because it only contains what's genuinely important enough to carry permanently.
Layer 6: Sticky Notes (memory/sticky-notes/)
A folder of markdown files for persistent facts that don't change much: devices (what hardware exists and what it's for), accounts (usernames, platforms, chat IDs — no secrets), preferences (how we like things done), infrastructure (servers, SSH details, deployment configs).
These get loaded every session, always. They're small and static. The agent updates them whenever something new is learned — like "there's a new server" or "we switched from provider X to provider Y."
The Session Boot Sequence
When Larry starts a session, the first thing he does — before responding to anything — is read his memory files in order:
- 1.Today's daily + yesterday's — What's the immediate situation? What happened recently that I need to be aware of right now?
- 2.This week's summary — What's been happening this week? What's the trajectory of each active project?
- 3.MEMORY.md — What are the permanent facts and principles I carry always?
- 4.Sticky notes — What's the current infrastructure, preferences, and reference info?
The whole boot sequence takes a small fraction of the context window. Not because we're cutting corners — but because the summaries are genuinely compact. Two days of raw logs might be 3,000 tokens; the refined daily is 300. The weekly summary covers 5 days in maybe 500 tokens. Long-term memory is a few hundred tokens. Sticky notes are another few hundred.
Boot up: ~1,500 tokens total. Context window remaining: ~97%. Full history loaded.
Why Not Just Use a Database?
This is the first question everyone asks. And it's fair — databases are the obvious tool for storing structured data. But for agent memory, markdown files win on almost every dimension.
Agents can read and write them natively
An LLM reads and writes text. Markdown files are text. The agent can read its own memory files directly — no API call, no query language, no ORM, no schema to manage. Writing a memory update is literally just: write these lines to this file. That's it. No database connection, no transaction, no index to update.
You can read them too
Open any memory file in a text editor and you can see exactly what your agent knows. Want to audit what Larry remembers about a project? Open memory/2026-02-15.md. Want to see what he learned last week? Open memory/weekly/2026-W07.md. No database client required. No schema to decode.
This transparency matters. When something goes wrong — and it will — you want to be able to inspect the agent's memory directly. With a database, you have to write queries. With markdown files, you just read.
Git-trackable history
Every change to the memory files is a diff. Commit your clawd folder to git and you have a complete history of how your agent's memory evolved over time. When did it learn a particular fact? What did it know before a specific decision? You can answer those questions. With a database, you'd need audit tables and change logs — extra work that most people don't build.
Editable by humans, not just agents
Sometimes you need to correct something the agent knows. Maybe it learned something wrong. Maybe circumstances changed. With markdown files, you just open the file and edit it. Delete the wrong line, add the right information. The agent will pick it up next session.
With a database, you're running SQL queries or building an admin UI. That's overhead that slows everything down and rarely happens at all.
No infrastructure to maintain
A database is a service. It needs to be running, backed up, and accessible. If it goes down, your agent loses its memory. Markdown files are just files on disk. They're always there. They don't go down. They don't need connection strings or credentials.
Could we eventually want a vector database for semantic search over historical memory? Maybe — if the scale demands it. But for now, the file system handles everything we need, with less complexity and more transparency than any database would offer.
Why This Actually Works (The Key Insights)
Token efficiency through compression
Day 1 and Day 100, the session boot loads roughly the same number of tokens. That's the magic. Raw logs accumulate indefinitely, but the agent doesn't load raw logs — it loads summaries that are proportionally sized to their time horizon. More time = more compression = same token footprint.
Nothing gets lost
The raw daily files preserve everything. If you ever need to go back and look at the full detail of what happened on a specific day, it's there. The summaries are lossy by design — but the source material is always available.
Self-maintaining
The rollups happen automatically. The cron jobs fire, the sub-agents run, the summaries get written. You don't manage the memory system — it manages itself. The only human involvement is deciding what goes into MEMORY.md permanently (though the monthly agent handles that too).
Compaction-resistant
When a session's context gets compacted because we hit token limits, the session memory disappears — but the file system doesn't. The daily notes were written throughout the day. When Larry starts the next session, he reads the files. The compaction never happened, from his perspective.
Separation of concerns
The main agent doesn't run the rollups. Sub-agents handle that. The main agent's job is to do work and write to daily notes. A separate nightly process handles the rest. This keeps the main agent focused and the memory system running on its own schedule.
Real Results: 20+ Days In
We've been running Fractal Memory in production for over 20 days. Here's what we've actually observed:
- ✓Larry tracks 10+ concurrent projects without confusion. He knows the status of each, what's blocked, and what needs to happen next — without us explaining it every session.
- ✓He remembers architectural decisions from week 1. When a question comes up that we already settled, he knows what we decided and why. No relitigating old debates.
- ✓Context window usage is flat. Day 1 and Day 20 feel the same from a context perspective. The session starts with about the same token load regardless of how much has happened.
- ✓The nightly rollups catch things we miss. Having a fresh sub-agent read the day's work and structure it is surprisingly useful — it surfaces patterns and connects dots that get missed in the moment.
- ✓Memory is inspectable. Multiple times we've opened a weekly summary to understand why something was decided the way it was. It's like having a project journal that writes itself.
The biggest thing we notice is the feeling of continuity. Larry feels like a persistent collaborator, not a stateless tool. He picks up where we left off. He references things from previous sessions naturally. It changes the dynamic of working with him entirely.
If You Want to Build This
The implementation is simpler than it sounds. You need:
A file structure
clawd/
memory/
2026-02-17.md # Today's raw daily
2026-02-16.md # Yesterday
refined/
2026-02-16.md # Yesterday's refined daily
weekly/
2026-W07.md # This week's summary
monthly/
2026-02.md # This month's overview
sticky-notes/
devices.md
infrastructure.md
preferences.md
MEMORY.md # Long-term curated memoryInstructions in AGENTS.md
Tell your agent explicitly: every session, read today's daily, yesterday's daily, this week's summary, MEMORY.md, and sticky notes. In that order. Before doing anything else. Make it a rule in the agent's governing instructions.
Cron jobs for rollups
Set up three cron jobs: one at 11:30 PM nightly for daily refinement, one Sunday at 11:45 PM for weekly rollup, one on the first of each month for monthly overview. Each spawns a sub-agent (we use Gemini Flash for cost efficiency) that reads the source files and writes the summary.
Prompts that produce good summaries
The quality of the rollups depends heavily on the prompts. We found that structured output works better than freeform — ask for specific sections (Decisions Made, Things Built, Problems Encountered, Blockers, Next Steps) and you get summaries that are useful rather than just shorter versions of the raw logs.
The total implementation is probably 200-300 lines of Python plus some cron config. The hard part isn't the code — it's the discipline of writing good daily notes and prompting good summaries. The system is only as good as what goes into it.
Why This Differentiates OpenClaw Agents
Here's the honest comparison: most AI agents are stateless chatbots. They're useful for one-off tasks. Ask a question, get an answer, close the tab. Fine.
But if you're running a business, you don't need a chatbot — you need a collaborator. Someone who shows up every day knowing the current state of your projects, remembering what you decided last week, and picking up exactly where you left off. That's a fundamentally different tool.
Fractal Memory is what makes that possible. It's the difference between an agent that knows what's happening and one that doesn't.
Every OpenClaw agent we build ships with Fractal Memory built in. The file structure is part of the template. The cron jobs are configured. The boot sequence is in AGENTS.md. You don't have to build this yourself — it's already there, ready to go from day one.
Build an Agent That Actually Remembers
Every AutoClaw agent ships with Fractal Memory built in — daily rollups, weekly summaries, long-term memory, sticky notes. Your agent hits the ground running on day one and gets smarter every day.
Build Your AgentNo amnesia. No repeated context dumps. Just persistent, capable agents.