Connect OpenClaw to Agent Memory Service
This document describes how to install the @mem0/openclaw-mem0 plugin in OpenClaw and connect to the Agent Memory Service (AMS) using the Mem0-compatible protocol. Once connected, OpenClaw can recall memories from AMS before a conversation starts and write conversation content to AMS after it ends.
Prerequisites
Before you begin, ensure you meet the following requirements:
-
You have added an agent identity in the AMS console and copied the corresponding API key.
-
You have created an endpoint in the AMS console and obtained the endpoint alias.
-
OpenClaw is installed and its gateway starts properly.
-
The OpenClaw CLI is installed locally, and you can successfully run
openclaw --version. -
The OpenClaw version is compatible with the
openclaw-mem0plugin version. For details on configuration differences between versions, see the Version compatibility section.
Configure the AMS Mem0-compatible address in the following format:
http://<endpoint alias>:1995/mem0
In this address, 1995 is the fixed port and /mem0 is the prefix for the Mem0-compatible protocol.
Integration information
|
Parameter |
Source |
Description |
|---|---|---|
|
|
The API key from the Agent Identity Management page in the AMS console. |
The API key is bound to an agent identity. You do not need to specify |
|
|
The AMS endpoint alias. |
The format is |
|
|
Customized by your application. |
Identifies the user whose memories are being stored. This is typically a business user ID, an account name, or a stable OpenClaw user identifier. |
|
|
An OpenClaw session. |
Distinguishes between different conversations. A fixed session ID is recommended for verifying auto capture. |
Version compatibility
-
Recommended versions: OpenClaw
v2026.4.24or later, and@mem0/openclaw-mem01.0.11. -
For earlier versions of OpenClaw, such as
v2026.3.23, you can use@mem0/openclaw-mem01.0.6for a compatible integration. For more information, see the "How to connect an older OpenClaw version" section in the FAQ.
Step 1: Install the plugin
Run the following command to install the OpenClaw Mem0 plugin:
openclaw plugins install @mem0/openclaw-mem0
After the installation is complete, view the plugin information:
openclaw plugins inspect openclaw-mem0
To check your OpenClaw version, run the following command:
openclaw --version
Step 2: Configure the plugin
Enable openclaw-mem0 in the OpenClaw configuration file. The configuration file is typically located at:
~/.openclaw/openclaw.json
When automatically capturing session conversations, we recommend using autoCapture and autoRecall. Newer versions of OpenClaw require you to add hooks.allowConversationAccess to the plugin entry.
{
"plugins": {
"slots": {
"memory": "openclaw-mem0"
},
"entries": {
"openclaw-mem0": {
"enabled": true,
"config": {
"mode": "platform",
"apiKey": "${MEM0_API_KEY}",
"baseUrl": "http://<endpoint alias>:1995/mem0",
"userId": "openclaw-user",
"autoCapture": true,
"autoRecall": true,
"topK": 5
},
"hooks": {
"allowConversationAccess": true
}
}
}
}
}
Parameter descriptions:
|
Parameter |
Required |
Description |
|---|---|---|
|
|
Yes |
Specifies |
|
|
Yes |
Must be set to |
|
|
Yes |
The API key obtained from the AMS console. You can reference an environment variable using the |
|
|
Yes |
The AMS Mem0-compatible address. It must include the fixed port |
|
|
Yes |
The user identifier. Memories under the same |
|
|
No |
Specifies whether to capture the conversation content after the agent replies. Enabled by default. |
|
|
No |
Specifies whether to recall relevant memories before the agent replies. Enabled by default. |
|
|
No |
The maximum number of memories to automatically recall. |
|
|
Yes |
Allows the plugin to read the current session conversation to enable auto capture. |
Example of setting an environment variable:
export MEM0_API_KEY="<Your AMS API key>"
Step 3: Restart the gateway
After modifying the configuration, restart the OpenClaw gateway:
openclaw gateway restart
Validate the configuration file format:
openclaw config validate
Check the plugin connection status:
openclaw mem0 status --json
If connected is true in the returned result, the plugin is connected to AMS:
{
"ok": true,
"mode": "platform",
"connected": true,
"userId": "openclaw-user"
}
Step 4: Verify the integration
When verifying auto capture for an OpenClaw session, we recommend using a fixed session ID. Use the same session for the entire conversation, and then use the /reset command to end the current session.
If you use the WebUI for the entire conversation, open the following URL:
http://localhost:18789/chat?session=ams-openclaw-demo
If you use the CLI for the conversation and then enter /reset in the WebUI, you must open the URL that corresponds to the explicit CLI session:
http://localhost:18789/chat?session=agent%3Amain%3Aexplicit%3Aams-openclaw-demo
Here, agent:main:explicit:ams-openclaw-demo corresponds to the CLI's --session-id ams-openclaw-demo.
Example CLI conversation:
openclaw agent --session-id ams-openclaw-demo \
--message "I'm writing an integration guide for connecting OpenClaw to AMS. It includes a small example called 'Nanping Teabreak 0527'. I want the steps to feel like a casual chat." \
--thinking off
Auto capture uses the config.userId from openclaw.json. In this example, it is openclaw-user.
Example conversation:
I'm writing an integration guide for connecting OpenClaw to AMS. It includes a small example called "Nanping Teabreak 0527". I want the steps to feel like a casual chat: chat a bit, then enter /reset, and then see if the memory was saved.
In the same session, enter /reset and choose Reset the current session. Do not create a new session instead of using /reset; creating a new session does not end the current one.
As another note for this example, I want to emphasize that the baseUrl should use the endpoint alias from the AMS console, with :1995/mem0 appended to the address. Don't use a local test address.
In the same session, enter /reset and select Reset the current session. Do not create a new session instead of using /reset; a new session will not end the current one.
Then, switch to a different topic in the same session:
Let's switch to a lighter topic. I might spend half a day near Xixi this weekend. I'm looking for a place where I can get coffee, take a slow walk, but that isn't too crowded or touristy. It would be great if there were more trees and fewer people, perfect for an afternoon around 3 or 4 PM.
After thinking about it, I've settled on a little plan for my weekend half-day: 'Huawu Slow Walk 0527'. I'll enter from the Xixi Huawu entrance around 3 PM, walk along the water, and find a quiet shop for an iced Americano. I don't want to rush through attractions; lots of shade and few people is all I need.
Changing topics, let's put the weekend plans aside for now. Tonight, I'm going to review the curl examples in the AMS Quick Start guide again, mainly to confirm that the baseUrl is written as the console endpoint alias plus :1995/mem0.
View the background events:
openclaw mem0 event list --json
If the event status is SUCCEEDED and payload.messages contains the conversation from this session, it indicates that autoCapture has sent the conversation to AMS:
{
"ok": true,
"events": [
{
"event_type": "ADD",
"status": "SUCCEEDED",
"payload": {
"user_id": "openclaw-user",
"run_id": "<user_id_hash>_group"
}
}
]
}
To confirm that long-term memory has been generated, wait for the background processing to complete after the event succeeds. Then, search for a stable keyword from the conversation:
openclaw mem0 search "Huawu Slow Walk 0527" --user-id openclaw-user --top-k 5 --json
If the result contains the corresponding keyword, this means that AMS has completed memory extraction and written it to the search index:
[
{
"scope": "long-term",
"categories": ["travel"],
"memory": "The user has decided on the 'Huawu Slow Walk 0527' plan..."
}
]
Plugin capabilities
Automatic capabilities
|
Capability |
Description |
|---|---|
|
|
Before the agent replies, the plugin recalls relevant memories from AMS based on the current input and injects them into the context. |
|
|
After the agent replies, the plugin sends the conversation content from the current session to AMS, which then determines whether to generate a memory. |
Agent tools
The plugin registers the following memory tools for the agent:
|
Tool |
Description |
|---|---|
|
|
Searches for memories using natural language. |
|
|
Actively writes content such as facts, preferences, and decisions. |
|
|
Retrieves a single memory by ID. |
|
|
Lists memories. |
|
|
Updates the text of a memory. |
|
|
Deletes a memory. |
|
|
Views background events in platform mode. |
|
|
Checks the status of a single background event. |
For the relationship between memory writing tools and autoCapture, see the FAQ question "No auto capture event after a conversation".
CLI commands
The following are common CLI commands:
# Check connection
openclaw mem0 status --json
# View background events
openclaw mem0 event list --json
openclaw mem0 event status <event_id> --json
# List memories
openclaw mem0 list --user-id openclaw-user --top-k 10 --json
# Search memories
openclaw mem0 search "user preference" --user-id openclaw-user --top-k 5 --json
# Manually add a memory
openclaw mem0 add "User preference: Use Chinese for technical documents and maintain the Alibaba Cloud Help Center style." --user-id openclaw-user --json
For the relationship between manual CLI writes and OpenClaw sessions, see the FAQ question "Why is the group_id different from the OpenClaw session?".
FAQ
API key, userId, and agent ID
In AMS, an agent identity is identified by its API key. You do not need to pass agent_id in the OpenClaw configuration.
The userId distinguishes the user whose memories are being stored. It is typically a business user ID, an account name, or a stable OpenClaw user identifier and is different from the agent ID in the AMS console.
Plugin connection status is false
Check the following configurations:
-
Verify that the
apiKeyis from the target agent identity in the AMS console. -
Verify that the
baseUrlis formatted ashttp://<endpoint alias>:1995/mem0. -
Ensure the endpoint status is Running.
-
Ensure your network can access the endpoint.
No auto capture event after a conversation
Check the following items in order:
-
Verify that
hooks.allowConversationAccessis set totrue. -
Do not enable the openclaw-mem0 skills mode.
-
Ensure you are using a fixed WebUI session for verification. When using the CLI for conversation and
/resetin a browser, you must use the explicit session URL.
If the agent calls memory_add, memory_update, or memory_delete during the current turn of the conversation, the plugin skips autoCapture for that turn to avoid duplicate writes. In this case, the events shown in the event list are from the tool calls and do not indicate whether session auto capture is working.
Successful event list, empty list or search
The event list indicates that the write request has entered the AMS processing pipeline. The list and search commands depend on the final generated memory.
There are two common reasons:
-
The conversation might not have a clear conclusion or topic change (which forms a 'boundary'). To create one, you can switch to a significantly different topic in the same session and start another turn of conversation.
-
The background extraction process is not yet complete. After a boundary is triggered, AMS still needs to perform memory extraction, clustering, and index writing. Wait for up to a minute before searching again.
First, check the event list for an ADD event with a status of SUCCEEDED. Then, use the search results after changing the topic to determine if a long-term memory has been generated.
group_id vs. OpenClaw session
AMS uses run_id/group_id to identify session groups. If run_id is not explicitly passed, AMS automatically generates a session group ID in the format <user_id_hash>_group.
When verifying OpenClaw session auto capture, rely on the payload.messages and event status in the event list. The manual openclaw mem0 add command is suitable for verifying API connectivity, but it is not a valid test for session auto capture.
Connecting older OpenClaw versions
Older versions of OpenClaw, such as v2026.3.23, can be used with @mem0/openclaw-mem@1.0.6. The plugin's runtime code supports baseUrl, but the configSchema in the manifest does not declare baseUrl, so you must modify the manifest of the installed plugin before configuration.
First, try to install from the plugin marketplace:
openclaw plugins install @mem0/openclaw-mem0@1.0.6
If the plugin marketplace is rate-limited or the download fails, install the plugin from your local file system after first downloading it with npm:
npm install -g @mem0/openclaw-mem0@1.0.6
npm root -g
openclaw plugins install /path/to/node_modules/@mem0/openclaw-mem0
After installation, modify the following file:
~/.openclaw/extensions/openclaw-mem0/openclaw.plugin.json
Change configSchema.additionalProperties to true so that baseUrl can pass the OpenClaw configuration validation.
OpenClaw v2026.3.23 does not provide the hooks.allowConversationAccess configuration, so omit this field from your configuration. The configuration is as follows:
{
"plugins": {
"slots": {
"memory": "openclaw-mem0"
},
"entries": {
"openclaw-mem0": {
"enabled": true,
"config": {
"mode": "platform",
"baseUrl": "http://<endpoint alias>:1995/mem0",
"apiKey": "<Your AMS API key>",
"userId": "openclaw"
}
}
}
}
}