Decoding OpenClaw's memory architecture, learn how agents handle memory
Agents without a memory are just random API calls. Memory is the one superpower that makes agents and chatbots usable for daily tasks. In this blog we explore how OpenClaw does it.
- openclaw
- memory
- rag
- agents
OpenClaw is a very popular always-on agent that was all the buzz in early 2026 (damn, that sounds so far away).
We all understand that agents are just LLMs under the hood, and that an agent is just an API call without its harnessharnessEverything around the model that makes it an agent: the loop it runs in, its tools, its prompt and its memory. and memory. Honestly, memory is what makes always-on agents like OpenClaw, Groqbot, Claude Duet and Muse interesting. The memory architecture of OpenClaw is especially interesting, and in this post we will explore its components in depth.
Two kinds of memory
There are two kinds of memory: short-term and long-term.
In short-term memory (episodic memoryepisodic memoryMemory of what happened, event by event, like a chat. The opposite of a fact you just know. ) we have the current agent conversation and the daily notes. These are not persistent, so they fade away in a new session.
In long-term memory (persistent memory) we have things like MEMORY.md. It stays persistent across different chats, and it can include preferences, like how you want the AI to talk to you. OpenClaw follows a similar architecture.
| Short-term | Long-term | |
|---|---|---|
| Holds | today’s events, raw | stable facts and decisions |
| Lifetime | hours to days | months and up |
| Cost to write | near zero | must be earned |
OpenClaw also runs a background job at night that moves things from short-term memory into long-term memory. We will call it the night job. OpenClaw calls it dreaming, and Part 2 covers it.
OpenClaw’s memory components
OpenClaw’s memory fits in five boxes: three short-term and two long-term. Here they are in one place.
Short-term fades in a new session
Long-term stays
Transcripts
A transcript is the raw record of a conversation: who said what, in order. It is the most complete record the agent has, and also the least tidy.
- It contains the turns of each chat. Only the words of the user and the assistant can be searched. Tool output, the model’s reasoning and images are left out.
- It is like a log file that gets written automatically as the conversation happens. The agent does not get to choose what goes in.
- Two readers use it. A tool called
sessions_searchfinds exact words in past chats, and the agent calls it whenever it wants to find something that happened in the past. And at night, the night jobthe night jobA background run at night that moves things from short-term into long-term memory. OpenClaw calls it dreaming. Part 2 covers it. reads recent transcripts.
Know more Which tool searches chats?
Notes and chats are searched by two different tools. By default, memory_search searches the notes only, and chats go through a separate tool, sessions_search. It finds exact words only. It is plain keyword search, not hybrid RAGRAGRetrieval-augmented generation: look the text up first, then add it to the prompt so the model can answer with it. . With session indexing on, memory_search covers chats too, with meaning and keywords together.
Know more Where transcripts live on disk
In the current version, transcripts live as rows in each agent’s own SQLiteSQLiteA small database that lives in a single file, with no server to run. database, ~/.openclaw/agents/<agentId>/agent/openclaw-agent.sqlite. The agentId is the agent’s name, not the id of a conversation, so one database holds all of that agent’s chats.
Older versions kept one .jsonl file per session, and archived transcripts are still kept as files in ~/.openclaw/agents/<agentId>/sessions/.
Daily notes
If a transcript is what happened, a daily note is what the agent decided was worth writing down in a diary. There is one file per day, named by date, like memory/2026-11-21.md.
A daily note holds working notes, observations and session summaries, in plain Markdown. Usually bullets under a heading. The agent writes it.
Know more The quiet safety net
When a long chat is about to be compactedcompactionSqueezing a long chat into a short summary so it still fits in the model’s window. (squeezed so it fits the model’s window), OpenClaw first asks the agent to save what matters. That step can only add new lines to the day’s note, never rewrite old ones. It is on by default.
Today’s and yesterday’s notes are loaded when you start a fresh session. Older notes are not in the prompt, so the agent has to search for them with memory_search. OpenClaw uses hybrid RAGhybrid searchMeaning search and keyword search run together, then blended into one score. for that (the retrieval part below explains it), a mix of vector embeddings and keyword search. The night job, in contrast, reads these notes from start to finish.
A daily note is cheap, short-term storage of whatever the agent thinks might matter. Nothing here is promised to last.
MEMORY.md
A fact, or piece of memory, has to go through a long process of rank climbing to reach the pinnacle of long-term memory, which is MEMORY.md. It gives the fact a permanent seat with the higher-ups, which are present in every conversation.
Normal memory gets upgraded into MEMORY.md by a certain procedure that happens during the night job.
MEMORY.md is kept small, because everything in it competes for room in the prompt. It contains durable facts and standing decisions, written compactly. It is not a log and not a transcript.
There are a few ways a fact gets in. You can tell the agent “remember that…” and it writes the line. And the night job adds entries too.
This is the agent’s main source of background context. It is injected at the top of the prompt at the start of every session.
Take one fact: Sam uses pnpm instead of npm. Here is what it could look like once it earns a place. This is an illustration; OpenClaw does not publish a sample entry.
Daily note
memory/2026-11-21.md
- Sam uses pnpm instead of npm.
Long-term
MEMORY.md
- Sam uses pnpm instead of npm.
Source: memory/2026-11-21.md#L2-L4
An illustrationOpenClaw publishes no sample entry, so the real format of the line and its source may differ.There is also another long-term file, USER.md, an optional file for stable preferences and writing style. It is loaded at session start with its own small budget.
The dream diary
OpenClaw keeps a diary of what the night job did, in a file called DREAMS.md. Each night gets a short story, written by a background model call after the run finishes. You read it in the Dreams tab of OpenClaw’s gateway dashboard. Nothing in the memory system reads it back. It is a window for you, not a source for the agent.
The SQLite tables
Behind the files sits a small database, SQLite, which lives in a single file. It holds no memories at all. It holds the bookkeeping that search and the night job need to do their work.
How each box reaches the agent
Here is the question that ties the five boxes together: what does the agent actually have in front of it? Only two files are always in its head. Everything else is either handed over when a fresh session starts, or has to be looked up. Picture a ladder with three rungs.
The prompt is small, so only the best material may live at the top. Everything else waits to be found. If it is not in MEMORY.md or in yesterday’s notes, the agent has to go and look for it, and we explain that next.
How the agent goes and looks
When the agent needs something that is not in its context, it searches for it. This is how an agent gets information from outside its prompt, and in OpenClaw it is hybrid retrieval. Here is a quick brief, then the settings, then the one fact to take away.
The brief
- RAG
- The system first retrieves relevant text from outside the model, then adds it to the prompt so the model can answer with it.
- Vector search
- Looks up by meaning. A model turns each text into a list of numbers called an embeddingembeddingA list of numbers a model makes from a text. Texts that mean similar things get similar numbers. , and embeddings with a high cosine similaritycosine similarityA score for how closely two embeddings point the same way. Higher means closer in meaning. are close in meaning.
- Keyword search
- Looks up by exact words. BM25BM25The classic keyword score: a note ranks higher when it contains the question’s words often, and especially when those words are rare. is the classic way to score it. SQLite’s FTS5FTS5SQLite’s built-in full-text search. provides it, and OpenClaw uses it.
- Hybrid
- Runs both and blends the two scores. Meaning search misses exact names and IDs; keyword search misses rephrasings. Together they cover for each other.
- Chunks
- Before any search, the index cuts every daily note into chunkschunkA slice of a note, cut by size by the search index. , slices of about 400 tokenstokenA word-piece. In English, about four characters. .
How a search picks its chunks
Here is what happens on every memory_search:
- Two searches run side by side. Vector search scores chunks by meaning. Keyword search (BM25) scores them by exact words.
- The two lists are merged into one. A chunk found by both searches appears once, with both scores.
- Each chunk gets one final score: 0.7 × its meaning score + 0.3 × its keyword score.
- Anything under the minimum score, 0.35, is dropped.
- Older dated notes are scaled down a little (recency), and the variety filter reorders near-duplicates.
- The top 6 go to the agent, with the first 700 characters of each.
The 70 and 30 are not a quota. They say how much each score counts inside one chunk’s final score, so all six results can come from either search. Here is the maths on five chunks:
The chunks that survive go on to the recency and variety steps. At most 6 reach the agent.
The settings, in plain words
Here is one memory_search, with each setting at the step it controls. Hover a step to read it in plain words.
Before any search when the notes are indexed
On every question
What comes back
The tools the agent calls
memory_searchfinds notes by meaning and keywords and returns chunks. This is the hybrid one.memory_getreads a named file or a line range, once search has pointed to it.sessions_searchfinds exact words in past chats, using a full-text index. It is plain keyword search, not hybrid, and it is separate frommemory_search.
What the index actually sees
Before any search runs, the index cuts every daily note into chunks by size. MEMORY.md and USER.md are the exception: they are cut one bullet or heading at a time. Our example is a daily note, and it is tiny, with line numbers added:
1- Sam uses pnpm instead of npm.
2- Sam prefers TypeScript for new projects.
3- Sam maintains a research diary on agent memory.
3 facts · 1 chunk · 1 embedding
One chunkThe whole chunk gets one embedding, so it matches a question about any of the three facts.This note is far under 400 tokens, so the index keeps it as one chunk: lines 1 to 4. That chunk is a combination of three facts. It also gets one embedding for its whole text, so it matches a question about any of the three.
A real day is longer. Take a note of about 900 tokens. Chunk 1 covers tokens 0 to 400, chunk 2 covers 320 to 720, and chunk 3 covers 640 to 900. A fact that sits in tokens 320 to 400, or 640 to 720, appears in two chunks.
A fact that sits in an overlap lands in two chunks.
Know more Are those token ranges exact?
Not to the token. The index probably cuts on line boundaries, so the real ranges shift a little. We have not confirmed this, so read the numbers as an illustration.
Now run the example. Someone asks, “Which package manager does Sam use?” The search finds lines 1 to 4 of the daily note and returns that chunk. It holds three facts: pnpm, TypeScript, the research diary. The agent receives all three, even though only one of them answers the question.
The index cuts by size. A fact is not a size.
Keep this one in mind. It decides what happens to a fact later, and Part 2 shows how.
Where this leaves us
So the agent has files it reads, tables that count, and a search tool that hands back chunks. Now look at what is piling up. The agent writes a lot into its notes and only a little into MEMORY.md. Who decides what moves? That is the night job, and it is the subject of Part 2.