Adding memory to OpenClaw

it keeps a log and can resume one session; nothing reads the others back

OpenClaw writes every session to disk — one JSONL file per session under ~/.openclaw/agents/<agent>/sessions/ — and openclaw chat --session <key> reopens one. That is resumption, not memory: a new session knows nothing about the last one, and nothing about what you did in Claude Code, Codex or Cursor on the same machine the week before. This page is about adding that.

What OpenClaw already has

The session log, per agent, and a session key to resume by. Its default backend is claude-cli, so a Claude Code hook already reaches it there; the other providers get nothing between sessions unless a plugin puts it in front of the model.

Adding recall

deja install openclaw-auto

Three things are written, and all three are reversible with deja uninstall openclaw:

  • The MCP server, so the model can call the deja tool itself — search past sessions, read one in full, see a file's history, ask what fixed an error, ask how a command is really run here, store a decision.
  • A hook pack under ~/.openclaw/hooks — a directory with HOOK.md and handler.js, which is OpenClaw's own format, so no openclaw plugins install step. It answers the agent:bootstrap event by appending a digest of this machine's relevant history to the Project Context set, without writing anything into the workspace.
  • A plugin under extensions/, with the package.json and openclaw.plugin.json pair OpenClaw validates. It answers before_prompt_build with the history the prompt you just typed is about, and it fires under openclaw agent --local too, where the bootstrap event never does.

Two things learned by running it against OpenClaw 2026.7.1, which the installer prints but are worth knowing before you test:

  • Internal hooks are off wholesale until hooks.internal.enabled is set. A pack listed as "ready" still never runs until then.
  • The bootstrap event fires in gateway mode, and only when the agent workspace is first bootstrapped — not once per session. Tested under openclaw agent --local, the pack looks dead; that is what the plugin half is for.

plugins.allow is left alone: it is advisory, leaving it costs one warning at startup, and writing to it would be deja deciding what you trust.

What arrives

At bootstrap, a short digest of what this machine has done on the project — decisions, the commands that worked, the errors that recurred — as one more entry in the Project Context. On each prompt, when your history already answers it, the plugin says so in front of the model; silence is the common case, and an injection is capped at about 1.5 KB per prompt and 4 KB per tool call. What memory costs has the measured comparison.

The part that is not about OpenClaw

The index covers every agent's transcripts on the machine — twenty-two of them, each in its own format — so a fix found in Claude Code answers a question asked in OpenClaw, including sessions from before any of this was installed. A transcript a client later deletes stays searchable; only deja forget drops one on purpose. Nothing here writes memories, so there is nothing to hallucinate into your history; indexing and search are local, and credentials are stripped as the index is built (privacy).

Getting started · Switching between agents · The OpenClaw session format