Add long-term memory to OpenClaw agents using the Mem0 plugin with auto-recall and auto-capture support.
Add long-term memory to OpenClaw agents with the @mem0/openclaw-mem0 plugin. Your agent forgets everything between sessions — this plugin fixes that by automatically watching conversations, extracting what matters, and bringing it back when relevant.
The userId field is a string you choose to uniquely identify the user whose memories are being stored. It is not something you look up in the Mem0 dashboard — you define it yourself.Pick any stable, unique identifier for the user. Common choices:
Your application’s internal user ID (e.g. "user_123", "[email protected]")
A UUID (e.g. "550e8400-e29b-41d4-a716-446655440000")
A simple username (e.g. "alice")
All memories are scoped to this userId — different values create separate memory namespaces. If you don’t set it, it defaults to "default", which means all users share the same memory space.
In a multi-user application, set userId dynamically per user (e.g. from your auth system) rather than hardcoding a single value.
// plugins.entries"openclaw-mem0": { "enabled": true, "config": { "apiKey": "${MEM0_API_KEY}", "userId": "alice" // any unique identifier you choose for this user }}
Session (short-term) — Auto-capture stores memories scoped to the current session via Mem0’s run_id / runId parameter. These are contextual to the ongoing conversation.
User (long-term) — The agent can explicitly store long-term memories using the memory_store tool (with longTerm: true, the default). These persist across all sessions for the user.
During auto-recall, the plugin searches both scopes and presents them separately — long-term memories first, then session memories — so the agent has full context.
The agent gets five tools it can call during conversations:
Tool
Description
memory_search
Search memories by natural language
memory_list
List all stored memories for a user
memory_store
Explicitly save a fact
memory_get
Retrieve a memory by ID
memory_forget
Delete by ID or by query
The memory_search and memory_list tools accept a scope parameter ("session", "long-term", or "all") to control which memories are queried. The memory_store tool accepts a longTerm boolean (default: true) to choose where to store.
# Search all memories (long-term + session)openclaw mem0 search "what languages does the user know"# Search only long-term memoriesopenclaw mem0 search "what languages does the user know" --scope long-term# Search only session/short-term memoriesopenclaw mem0 search "what languages does the user know" --scope session# View statsopenclaw mem0 stats
The @mem0/openclaw-mem0 plugin gives OpenClaw agents persistent memory with minimal setup. Whether using Mem0 Cloud or self-hosting, your agents can now remember user preferences, facts, and context across sessions automatically.