Skip to content

Persistent memory in OpenClaw: how it works and where it lives

OpenClaw's memory layer is a stack — editable Markdown bootstrap files, dated daily notes, JSONL session transcripts, and optional vector backends like LanceDB, Honcho, or QMD. This article walks through what each layer stores, where on disk it lives, and how the agent stitches them together at the start of every session.

You send your OpenClaw agent a message on Monday: “I prefer concise replies, no preamble.” On Tuesday you send a different question — and the agent opens with “Of course! Let me help you with…” You frown, you check the docs, you find the word “memory” used twelve different ways across a dozen pages, and you still do not know whether the preference you set yesterday is supposed to survive at all. This article is the mental model. Memory in OpenClaw is a stack of layers, each of which stores a different shape of state in a different place. Once you know what is in each layer, the gaps stop being mysterious.

What it is

OpenClaw’s “memory” is not one thing. It is a layered persistence stack composed of:

  1. Editable bootstrap files — AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, BOOTSTRAP.md — that the runtime injects into the system prompt at the start of each session (OpenClaw docs — agent runtime).
  2. A long-term memory file — MEMORY.md — that stores durable facts, preferences, and decisions, loaded at session start (OpenClaw docs — memory concept).
  3. Daily working notes — memory/YYYY-MM-DD.md — that capture working context, with today’s and yesterday’s files auto-loaded.
  4. Session transcripts — JSONL files at ~/.openclaw/agents/<agentId>/sessions/<SessionId>.jsonl — that preserve the message-by-message history of each session.
  5. Optional memory engines — the built-in SQLite store, plus pluggable backends like Honcho (cross-session AI-native), QMD (local-first with reranking), and LanceDB (vector store with Ollama support) — that add semantic search and embedding-based retrieval.

All of these live under ~/.openclaw/. None of them require a cloud service or an external database to function. The optional layers are opt-in upgrades, not defaults.

Mental model

Think of OpenClaw’s memory as three orthogonal axes:

Persistence layer. Working memory (today’s note) versus long-term memory (MEMORY.md, edited persona files). Working memory is high-detail and short-lived; long-term memory is curated and durable.

Format layer. Markdown files for human-editable state, JSONL for session history, SQLite or a vector store for semantic search. The Markdown files are the contract — you can cat, edit, version-control, and audit them. The JSONL and SQLite are derived state.

Retrieval layer. Auto-loaded at session start (the editable files plus today’s and yesterday’s daily notes), or queried on demand via memory_search and memory_get tools the agent can call mid-session (OpenClaw docs — memory concept).

When the agent does not remember something, the question is always: which axis failed? Was the fact never written down? Was it written down in a daily note that has aged out of the auto-load window? Was it written into MEMORY.md but never re-indexed for semantic search?

How it works on the Stack Harbor stack

On a healthy deployment, memory works like this on the wire.

When a session starts, the runtime reads the workspace and injects into the system prompt:

  • AGENTS.md — the operating instructions
  • SOUL.md — the persona, boundaries, and tone
  • TOOLS.md — the user-maintained tool conventions
  • IDENTITY.md — the agent’s name and emoji
  • USER.md — the user profile
  • MEMORY.md — the curated long-term facts
  • memory/<today>.md and memory/<yesterday>.md — the recent working notes

Blank files are skipped. Files past a size threshold are trimmed and marked, so the system prompt stays lean (OpenClaw docs — memory concept). The BOOTSTRAP.md is the one-shot exception — it runs only on the very first session and is deleted by the agent afterward.

While the session runs, every turn — user message, model response, tool call, tool result — is appended to the session transcript at ~/.openclaw/agents/<agentId>/sessions/<SessionId>.jsonl. The session ID is stable across restarts, so you can stop the Gateway, restart it, and the next message lands in the same session as before.

If the agent decides it needs to recall something not currently in context, it calls memory_search (semantic-plus-keyword hybrid search) or memory_get (a specific file or line range). The semantic side requires embeddings, which work out of the box with OpenAI, Gemini, Voyage, or Mistral API keys (OpenClaw docs — memory concept).

The default backing store is SQLite. If you want stronger semantic recall or cross-session reasoning, you can swap in a different backend:

  • LanceDB — local vector store with Ollama support, configured under the LanceDB plugin block (OpenClaw docs — LanceDB memory plugin).
  • Honcho — an AI-native memory service designed for cross-session continuity.
  • QMD — a local-first store with reranking.

Each is opt-in. The default install does not require any of them; the Markdown stack plus SQLite is enough for personal use.

The optional “Dreaming” feature runs scheduled consolidation passes that promote high-signal items from daily notes into long-term MEMORY.md — and writes a human-readable diary in DREAMS.md so you can review what got promoted (OpenClaw docs — dreaming). This is the opt-in that turns “I have to manually curate MEMORY.md” into “the agent curates it for me, but I can audit the changes.”

When to use vs not

The built-in memory stack — Markdown plus SQLite plus JSONL transcripts — is the right answer for personal use, single-user deployments, and any case where you want to be able to read and edit memory by hand. It is auditable, portable, and survives a daemon restart cleanly.

Add LanceDB or QMD when semantic recall starts to matter. The signal is the agent failing to surface obviously-relevant past context: you mentioned a person three weeks ago, the agent has no idea who they are, and a manual grep of ~/.openclaw/workspace/memory/ finds the reference instantly. That is the moment to install a vector backend.

Add Honcho when you are running a multi-surface deployment and the cross-session reasoning is the differentiator — for example, the agent should treat a chat on Telegram, a voice call, and an iMessage thread as continuations of the same relationship.

Skip optional engines entirely when you cannot tolerate the operational footprint. They are extra moving parts. They want their own upgrade cycle, their own backup, their own observability. For most personal installs they are unnecessary.

Common misconceptions

“OpenClaw remembers everything I have ever said.” No. The auto-loaded set is the editable files plus today’s and yesterday’s daily notes. Anything older requires explicit retrieval via memory_search or memory_get, and memory_search only works well if you have embeddings configured.

“I should never edit MEMORY.md by hand.” You should edit MEMORY.md by hand. It is a Markdown file, the agent reads it as English, and direct edits are the most reliable way to tell the agent something durable. Dreaming-style auto-promotion is a convenience layer over the same file.

“Session transcripts are the source of truth for memory.” Transcripts are an audit trail. They preserve what happened, but the agent does not auto-load old transcripts at session start — only the editable files and the most recent daily notes. If you need a fact to persist, it goes into MEMORY.md or the relevant editable file, not into a transcript.

“Dreaming silently rewrites my persona.” Dreaming consolidates working memory into long-term memory and writes a diary entry to DREAMS.md that you can review. Edits to SOUL.md, IDENTITY.md, and AGENTS.md are by you or by the agent in response to your direct instruction; they are not part of the dreaming pass.

“Switching memory backends is a one-way door.” It is not. The Markdown stack is the canonical store regardless of which optional backend you run. Swapping LanceDB for QMD means re-indexing, not data loss.

Sources


Last verified on OpenClaw current. The memory subsystem has shipped meaningful changes in recent releases — verify the paths and backend names against the live docs before automating around them.

Talk to a senior operator about your OpenClaw deployment.