10 min read

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-termLong-term
Holdstoday’s events, rawstable facts and decisions
Lifetimehours to daysmonths and up
Cost to writenear zeromust 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

Transcripts the raw chat TranscriptsThe raw chat, turn by turn. Written by OpenClaw as you talk.
Daily notes memory/YYYY-MM-DD.md Daily notesThe agent's own log of the day. Written by the agent.
SQLite tables bookkeeping, no memories inside SQLite tablesExtra bookkeeping that search and the night job need. Search uses it by day, the night job by night.
night job

Long-term stays

MEMORY.md facts that earned a place MEMORY.mdThe facts that earned their place. Written by the night job, or by the agent when you ask it to remember.
Dream diary what the night job did Dream diaryA readable story of what happened each night, for you. Written by a background model call after each night run.
HoverTap a part to read it in plain words.
Figure 1 OpenClaw's memory in five boxes: three short-term, two long-term.

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_search finds 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.
You Which package manager does Sam use? searchable SearchableThe words of the user can be found again later with an exact-word search.
Agent Sam uses pnpm. searchable SearchableSo can the words of the assistant.
Skipped tool output · reasoning · images left out Left outTool output, the model's reasoning and images are in the transcript, but not in what can be searched.
HoverTap a part to read it in plain words.
Figure 2 What a transcript keeps searchable, and what it leaves out.
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.

the night job Part 2 The night jobIt reads the notes and decides which facts earn a place. Part 2 covers how.

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.
HoverTap a part to read it in plain words.
Figure 3 One fact before and after it earns a place in MEMORY.md. An illustration.

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.

1

Always in the prompt

loaded at the start of every session

MEMORY.md MEMORY.mdThe agent's main source of background context. It is injected at the top of the prompt in every session.
USER.mdoptional USER.mdStable preferences and writing style, loaded at session start with its own small budget.

2

Handed over on a fresh session

when you run /new or /reset

Today's and yesterday's notes Daily notesLoaded when a fresh session starts. Anything older is not in the prompt.

3

Looked up on demand

the agent has to go and search

Older daily notesmemory_search, memory_get Older daily notesFound with memory_search, which uses meaning and keywords. memory_get then reads the file or line range.
Transcriptssessions_search TranscriptsFound by exact words with sessions_search. With session indexing on, memory_search covers them too.
SQLite tablesused behind the scenes SQLite tablesThe agent never opens these. The search tool uses them for you.
Dream diary never reaches the agent you, in the Dreams tab Dream diaryIt is a window for you, not a source for the agent. Nothing in the memory system reads it back.
HoverTap a part to read it in plain words.
Figure 4 How each box reaches the agent: 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:

  1. Two searches run side by side. Vector search scores chunks by meaning. Keyword search (BM25) scores them by exact words.
  2. The two lists are merged into one. A chunk found by both searches appears once, with both scores.
  3. Each chunk gets one final score: 0.7 × its meaning score + 0.3 × its keyword score.
  4. Anything under the minimum score, 0.35, is dropped.
  5. Older dated notes are scaled down a little (recency), and the variety filter reorders near-duplicates.
  6. 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:

1memory/2026-11-21.mdlines 1 to 4 0.82 × 0.7 = 0.57 0.70 × 0.3 = 0.21 0.78 KeptThe note that holds the answer. It matches the question in meaning and in exact words, so both parts add up.
2memory/2026-11-12.mdlines 1 to 9 0.64 × 0.7 = 0.45 0.30 × 0.3 = 0.09 0.54 KeptClose in meaning, because it is about setting up a project, but few exact words match, so the keyword part adds little.
3MEMORY.mdpreferences 0.56 × 0.7 = 0.39 0.40 × 0.3 = 0.12 0.51 KeptSome words match and the meaning is fairly close. The two parts still add up past 0.35, but it ranks lower.
minimum score 0.35: below this, a chunk is dropped Minimum score0.35 is the cut-off. Everything below the line is thrown away before the other steps run.
–memory/2026-10-30.mdlines 3 to 8 0.41 × 0.7 = 0.29 0.00 × 0.3 = 0.00 0.29 DroppedFound by meaning, but no words match, so the keyword part is 0. 0.7 × 0.41 is only 0.29, under the minimum.
–memory/2026-11-03.mdlines 1 to 5 0.00 × 0.7 = 0.00 0.50 × 0.3 = 0.15 0.15 DroppedFound by keyword search only, so it has no meaning score. 0.3 × 0.50 is only 0.15, under the minimum.

The chunks that survive go on to the recency and variety steps. At most 6 reach the agent.

HoverTap a part to read it in plain words.
Figure 5 A worked example: five chunks found for “Which package manager does Sam use?”

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

Chunk sizeabout 400 tokensChunk sizeRoughly 1,600 characters, a few paragraphs.
Overlap80 tokensOverlapEach chunk starts by repeating the last 80 tokens of the one before it, so a sentence cut at the edge still appears whole in one of them.

On every question

The question“Which package manager does Sam use?”
Vector searchby meaning · weight 0.7Vector searchFinds notes that mean the same thing, even in different words. Its weight is 0.7: meaning counts for 70% of the final score.
Keyword searchexact words · weight 0.3Keyword searchFinds notes with the same exact words (SQLite FTS5 does this side). Its weight is 0.3: exact words count for 30% of the final score.
Blend0.7 vector + 0.3 keywordBlendBoth searches run on every question. Each note gets one final score: 0.7 × its meaning score + 0.3 × its keyword score.
Minimum score0.35Minimum scoreA result scoring below 0.35 is dropped, even if it would have made the top six. It is checked before recency decay.
Recency decay30-day half-lifeRecency decayOlder dated notes score lower: a note from a month ago counts for about half. It changes the order, not who qualifies.
Variety filter (MMR)lambda 0.7Variety filter (MMR)Reorders the results to drop near-duplicates, so the six returned are not six copies of one note. 0.7 leans toward relevance over variety.

What comes back

Results returnedat most 6Results returnedThe agent never sees more than six chunks.
Text per resultfirst 700 charactersText per resultThe agent sees only the start of a chunk. memory_get reads the rest.
HoverTap a part to read it in plain words.
Figure 6 One memory_search, with every setting where it acts.

The tools the agent calls

  • memory_search finds notes by meaning and keywords and returns chunks. This is the hybrid one.
  • memory_get reads a named file or a line range, once search has pointed to it.
  • sessions_search finds exact words in past chats, using a full-text index. It is plain keyword search, not hybrid, and it is separate from memory_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:

memory/2026-11-21.md

1## Tooling
2- Sam uses pnpm instead of npm.1 Fact 1The package manager.
3- Sam prefers TypeScript for new projects.2 Fact 2The language.
4- Sam maintains a research diary on agent memory.3 Fact 3The research diary.

one chunk · lines 1 to 4

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.
HoverTap a part to read it in plain words.
Figure 7 The index cuts the note by size: one chunk, 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 long daily note · about 900 tokens
chunk 1 Chunk 1Tokens 0 to 400.
chunk 2 Chunk 2Tokens 320 to 720. It starts by repeating the last 80 tokens of chunk 1.
chunk 3 Chunk 3Tokens 640 to 900. It starts by repeating the last 80 tokens of chunk 2.
0 320 400 640 720 900

A fact that sits in an overlap lands in two chunks.

HoverTap a part to read it in plain words.
Figure 8 A 900-token note cut into 400-token chunks that overlap by 80 tokens.
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.

ChatSam mentions pnpm ChatThe fact first shows up in a conversation. The transcript keeps the words.
Daily notethe agent writes it down Daily noteShort-term. Cheap to write, and nothing here is promised to last.
The night jobPart 2 The night jobIt decides which facts earn a place in long-term memory. Part 2 covers it.
MEMORY.mdin every session MEMORY.mdLong-term. Loaded at the top of the prompt, every session.
HoverTap a part to read it in plain words.
Figure 9 One fact's journey, and the step we have not covered yet.