Add Memory to OpenClaw: The Complete Mem0 Integration Guide (2026)

Add Memory to OpenClaw: The Complete Mem0 Integration Guide (2026)

Engineering Team

April 17, 2026

We recently built memory for OpenClaw and received a large number of people testing OpenClaw with Mem0.

If you haven't tried that setup yet, this tutorial is for you.

When you run OpenClaw for the first time, it collects information about you and writes it into memory files that the agent can reference during conversations. The agent may ask about your work, your preferences, or how you want it to behave. As you keep using it, responses may begin to reflect that information, which makes the agent feel like it is learning over time.

But as conversations grow longer or span multiple sessions, that expectation starts to break down. Details you shared earlier stop showing up in responses. Information that felt important to the task is no longer recalled. In some cases, the agent behaves as if the information was never provided at all.

This happens because OpenClaw's default memory system does not guarantee persistence or memory recall. Memory storage and retrieval are left to the LLM, guided by prompts, heuristics, and a small set of markdown files.

The model decides what to save, when to search memory, and whether previously stored information is relevant enough to be loaded back into the current context. There is simply no guarantee that information will be persisted or reloaded when needed.

This article shows how to add enforced, persistent memory to OpenClaw using the Mem0 plugin, @mem0/openclaw-mem0.

TLDR

What persistent memory means in OpenClaw agents

In OpenClaw, persistent memory refers to memory that is stored outside the agent's execution lifecycle and can be reintroduced after a session ends or the process restarts.

Agents do not run forever. Sessions end. Context gets trimmed. Processes restart. If memory only lives inside the active prompt, it will disappear. Persistent memory solves that by living outside the agent lifecycle and being reintroduced when needed.

Without it, agents rely on short term context and best effort recall. With it, agents can actually build on past interactions over time.

How OpenClaw's memory system works, and why it fails for long-term recall

Out of the box, OpenClaw stores memory as markdown files on disk.

ls ~/.openclaw/workspace

You will see files like:

As you talk to your agent, OpenClaw gives the LLM access to memory tools such as memory_search and memory_get. At first glance, this looks reasonable. Memory exists and tools exist.

The problem is how those tools are used.

User:I usually build backend APIs in Python

Agent: Okay, noted

[new session]

User: Suggest a project idea for me

Agent: You could build a mobile app or a game

By now the pattern is obvious. Information may exist on disk, but there is no guarantee it will be saved, searched, or reintroduced when needed.

For short demos, the built-in memory is usually fine. But once you start doing real work, long sessions, agents that run across days all things fall apart quickly.

How Mem0 adds persistent memory to OpenClaw agents

@mem0/openclaw-mem0 moves memory control out of the agent loop and into the system layer. It does this through two mechanisms that run on every turn, silently, with no manual configuration required.

User:I usually build backend APIs in Python

→ Auto-Capture: detects user preference, stores as user-scoped memory

→ Auto-Recall: next turn, that memory is already in context before the agent responds

Short-term vs long-term memory

The plugin organizes memory into two scopes, and understanding the difference matters for how you use the tools.

During auto-recall, both scopes are searched and presented separately i.e, long-term memories first, then session memories, so the agent has full context before it reasons.

Setting up @mem0/openclaw-mem0 step by step

You no longer need manual config editing to get started. Everything happens inside the OpenClaw chat itself.

Note: Requires OpenClaw >= 2026.4.15 . Check your version with openclaw --version.

Step 1: Get the setup command

Setup Mem0 from mem0.ai/claw-setup

Step 2: Send it to your OpenClaw agent

Open any OpenClaw channel including, Telegram, WhatsApp, your default chat, wherever your agent lives. Paste and send the command from the previous step.

OpenClaw responds with a Mem0 setup card and immediately asks:

"What's your email address? I'll send you a verification code to connect your Mem0 account."

Step 3: Enter your email

Type your email address and send it. Mem0 sends back:

"Check your email for a 6-digit code and paste it here."

Step 4: Paste the OTP

Copy the 6-digit code from your inbox and paste it into the chat:

223716

You'll see the confirmation:

"Connected to Mem0."

That's it. No API key. No config file editing. No environment variables. The plugin is now active and auto-capture and auto-recall are running on every turn.

Prefer to self-host? Use open-source mode

If you want to run everything locally without connecting to Mem0 Cloud, you can still use open-source mode. This path does require a manual config edit.

Open your config file:

nano ~/.openclaw/openclaw.json

Add this under plugins.entries:

{
  "plugins":{
    "slots":{
      "memory":"openclaw-mem0"
    },
    "entries":{
      "openclaw-mem0":{
        "enabled":true,
        "config":{
          "mode":"open-source",
          "userId":"your-user-id"
        }
      }
    }
  }
}

To customize the embedder, vector store, or LLM:

{
  "plugins":{
    "slots":{
      "memory":"openclaw-mem0"
    },
    "entries":{
      "openclaw-mem0":{
        "enabled":true,
        "config":{
          "mode":"open-source",
          "userId":"your-user-id",
          "oss":{
            "embedder":{"provider":"openai","config":{"model":"text-embedding-3-small"}},
            "vectorStore":{"provider":"qdrant","config":{"host":"localhost","port":6333}},
            "llm":{"provider":"openai","config":{"model":"gpt-4o"}}
          }
        }
      }
    }
  }
}

Restart the gateway after saving:

openclaw gateway

All oss fields are optional. The defaults use OpenAI embeddings (text-embedding-3-small), an in-memory vector store, and OpenAI LLM. See the Mem0 OSS docs for the full list of available providers.

What tools your agent now has access to

Once the plugin is enabled, your agent gains eight memory tools automatically:

Tool Description
memory_search Search memories by natural language query. Supports scope, categories, filters.
memory_add Store facts. Accepts text or facts array, category, importance, metadata.
memory_list List all memories. Filter by userId, agentId, scope.
memory_get Retrieve a single memory by ID
memory_update Update a memory's text in place. Preserves history.
memory_delete Delete by memoryId, query, or all: true.
memory_event_list List recent background processing events (platform mode only).
memory_event_status Get status of a specific event by ID (platform mode only).

For normal usage you do not need to call these manually. Auto-capture and auto-recall handle most cases. They are there when you need explicit control.

Verifying that persistent memory works

At this point, everything should be wired up. The only thing left is to confirm memory actually persists.

Start by telling your agent something worth remembering:

User: I usually build backend APIs in Python

Agent: Got it. I've noted that you build backend APIs in Python.

You should see this in your logs immediately:

21:49:09[plugins] openclaw-mem0: auto-captured 1 memories

Stop the agent. Start it again so you are in a new session:

openclaw gateway

Ask something that depends on that memory:

User: Suggest a project idea for me

Agent: Since you build backend APIs in Python, you could build a small API gateway with rate limiting and API key support.

Then confirm the memory exists directly using the CLI:

Search by exact phrase

openclaw mem0 search "backend APIs in Python"

# Search by natural language
openclaw mem0 search "what does the user usually build"

# Search only long-term memories
openclaw mem0 search "backend APIs" --scope long-term

# Search only session memories
openclaw mem0 search "backend APIs" --scope session

# List all memories
openclaw mem0 list

# List with filters
openclaw mem0 list --user-id alice --top-k 20

You should see:

Found 1 memory

At this point there is nothing left to assume. The memory exists. It survives restarts. It is injected into every response. The agent is no longer guessing.

Configuration reference

Core options

Key Type Default Description
mode "platform" / "open-source" "platform" Which backend to use
userId string OS username Scope memories per user
autoRecall boolean true Inject memories before each turn
autoCapture boolean true Store facts after each turn
topK number 5 Max memories injected per recall
searchThreshold number 0.3 Minimum similarity score (0–1)

Platform mode options

Key Description
apiKey Supports ${MEM0_API_KEY} env var syntax
customInstructions Override what gets extracted and how it is formatted
customCategories Override the 12 default memory category tags

Open-source mode options (oss)

Key Default Description
oss.embedder.provider "openai" Embedding provider ("openai", "ollama", etc.)
oss.vectorStore.provider "memory" Vector store ("memory", "qdrant", "chroma", etc.)
oss.llm.provider "openai" LLM provider ("openai", "anthropic", "ollama", etc.)
oss.historyDbPath SQLite path for memory edit history
oss.disableHistory false Disable memory edit history tracking

Start building agents that actually remember

OpenClaw agents forget because memory is treated as a suggestion, not a requirement. Facts may or may not be saved. Memory may or may not be searched. Context may disappear at any time due to compaction. When all of that is left to the LLM, forgetting is the expected outcome.

@mem0/openclaw-mem0 changes this by enforcing memory capture and recall at the system layer rather than leaving it to the prompt. Memory is captured outside the agent session. Relevant memory is reintroduced on every turn. Restarts do not matter. Long conversations do not matter. The agent reasons with the same facts every time.

You do not need to rewrite prompts or change how your agent works. You only replace the memory layer.

If you are building agents that run across sessions, handle real user preferences, or are expected to behave consistently over time, persistent memory is not optional. It is the foundation.

The simplest next step is to install the plugin, restart your agent, and watch it stop guessing and start remembering.

FAQs

Do I need to change my agent prompts to use @mem0/openclaw-mem0?

No. The plugin works at the memory layer. Your prompts and agent logic stay the same.

Does this replace OpenClaw's built-in memory tools?

Yes. The plugin replaces the default memory behavior with persistent memory backed by Mem0.

I was using memory_store or memory_forget before, do those still work?

These tools were renamed to memory_add and memory_delete in the current version. Update any custom prompts or agent code that references the old names.