By default, the OpenClaw Agent cannot remember user preferences across sessions. The memory plugin from Alibaba Cloud Model Studio uses the long-term memory API to enable cross-session context awareness. After a conversation ends, the plugin automatically extracts and stores key information. Before the next conversation begins, it automatically recalls relevant memories.
Comparison
The following two conversations show the difference in behavior between the default Agent and an Agent with the long-term memory plugin enabled in the same scenario.
Default Agent (no memory) | Agent with the long-term memory plugin enabled |
First conversation: User: I'm working on a Python project using the FastAPI framework. Agent: OK. FastAPI is a high-performance web framework. How can I help?
Second conversation (new session): User: Help me write an API. Agent: What language and framework are you using? The Agent cannot remember the previous conversation.
| First conversation: User: I'm working on a Python project using the FastAPI framework. Agent: OK. FastAPI is a high-performance web framework. How can I help?
Second conversation (new session): User: Help me write an API. The Agent retrieves a relevant memory: "The user is working on a Python project with the FastAPI framework."
The Agent starts to help write the API.
|
How it works
The memory plugin runs inside the OpenClaw Gateway. It interacts with the Alibaba Cloud Model Studio long-term memory API through two lifecycle hooks: before_agent_start and agent_end. All read and write operations are sent as HTTPS requests to the Alibaba Cloud Model Studio server-side. Model Studio then handles extraction, vectorization, and semantic retrieval.
Automatic memory capture (autoCapture): Automatically extracts and stores key information after a conversation ends.
Automatic memory recall (autoRecall): Automatically retrieves relevant memories and injects them into the context before a conversation begins.
Install and configure the plugin
The memory plugin has a unified configuration, and all Agents share the same memory. You cannot configure the plugin for each Agent independently.
Step 1: Confirm the OpenClaw running status
Run the following command to verify that the OpenClaw Gateway has started:
openclaw gateway statusThe output should include Gateway: bind=loopback and port information.
Step 2: Get a DashScope API key
On the Key Management page in the Alibaba Cloud Model Studio console, obtain an API key and save it. You will need it in the following steps.
Step 3: Install the plugin
Install with npm
openclaw plugins install @modelstudio/modelstudio-memory-for-openclawAfter the installation is successful, the command-line interface (CLI) displays the message Installed plugin: modelstudio-memory-for-openclaw. Do not restart the Gateway yet. You must complete the configuration first.
Step 4: Configure plugin parameters
Open ~/.openclaw/openclaw.json and add the configuration to the plugins section:
{
"plugins": {
"slots": {
"memory": "modelstudio-memory-for-openclaw"
},
"entries": {
"modelstudio-memory-for-openclaw": {
"enabled": true,
"config": {
"apiKey": "sk-xxx",
"userId": "user_001",
"profileSchema": "your_profile_schema_id",
"memoryLibraryId": "your_memory_library_id",
"projectId": "your_project_id"
}
}
}
}
}Configuration details:
slots.memory: Registers the plugin in the memory slot. This automatically disables the built-inmemory-coreandmemory-lancedbplugins.apiKey: Enter the DashScope API key that you obtained in Step 2.userId: A user identifier that isolates the memory space for different users. Users with the sameuserIdshare a namespace, whereas users with differentuserIdvalues are completely isolated.
All configuration items:
Configuration item | Type | Default value | Description |
| string | - | Starts with sk-xxx. |
| string | - | The user identifier for the memory space. |
| boolean |
| Automatically extracts and stores memories after a conversation. |
| boolean |
| Automatically retrieves and injects memories before a conversation. |
| number |
| The number of memories to return for each recall. |
| number |
| The minimum similarity threshold (0–100). |
| string | - | The user persona ID. This parameter is optional. Go to the Memory Library page, click View Details for a specific memory library, and get the ID from the memory rule page. |
| string | - | The memory library ID. This parameter is optional. Get the ID from the card on the Memory Library page. Note If you do not pass this parameter, the default memory library ID is automatically selected. |
| string | - | The memory segment rule ID. This parameter is optional. Click View Details for a specific memory library and get the ID from the memory rule page. Note If you do not pass this parameter, the default memory segment rule ID for the specified memory library is automatically selected. |
Step 5: Verification
Verify the installation
# View plugin information
openclaw plugins info modelstudio-memory-for-openclaw
# View status
openclaw modelstudio-memory statsRestart the Gateway:
openclaw gateway restartAfter the restart is complete, run the following command to verify the plugin status:
openclaw plugins info modelstudio-memory-for-openclawExpected output:
Memory (Bailian)
id: modelstudio-memory-for-openclaw
Status: loaded
Tools: memory_search, memory_store, memory_list, memory_forget
CLI commands: modelstudio-memoryStatus: loaded indicates that the plugin loaded successfully. Verify connectivity with the Alibaba Cloud Model Studio API:
openclaw modelstudio-memory statsExpected output:
User: user_001
Total memories: 0
Auto-capture: true
Auto-recall: true
Top-K: 5The long-term memory plugin is now configured. The Agent's automatic capture and recall features are enabled by default and do not require manual operations. You can open the OpenClaw panel at the default address http://127.0.0.1:18789 to start a conversation with the memory-enabled Agent.
Use memory tools in conversations
In addition to automatic capture and recall, the plugin registers four tools with the Agent. The Agent can actively invoke these tools during a conversation based on the context.
memory_search: Semantically retrieves memories from the memory library. This tool accepts a natural language query, performs semantic retrieval, and returns a list of the most similar memories. The Agent automatically selects this tool when a user asks retrospective questions, such as "What did we discuss before?" or "What do you remember about the database?"
memory_store: Writes specified content directly to the memory library without conversational extraction. This is useful when a user explicitly asks the Agent to remember a specific fact, such as "Remember my server IP is 192.168.1.xxx."
memory_list: Lists all memory entries for the current
userIdwith paging. This tool is useful for browsing and managing existing memories.memory_forget: Deletes a specific memory based on its ID. The Agent typically first uses
memory_searchto locate the target memory and then callsmemory_forgetto delete it.
Equivalent CLI commands:
# Semantically retrieve memories
openclaw modelstudio-memory search "user preferences"
# List all memories with paging
openclaw modelstudio-memory list --page 1 --size 10
# View memory statistics
openclaw modelstudio-memory statsQuotas and limits
The Alibaba Cloud Model Studio long-term memory API has the following rate limits:
API operation | Rate limit |
AddMemory (write) | 120 times per minute |
SearchMemory (query) | 300 calls/minute |
Total for all operations | 3,000 calls/minute |
Performance metrics:
SearchMemory end-to-end latency: 200–500 ms
AddMemory latency: 500–1,000 ms
Automatic capture is asynchronous and does not affect response speed.
FAQ
Why is the plugin status not loaded after restarting the Gateway?
Verify that
plugins.entries.modelstudio-memory-for-openclaw.enabledis set totruein openclaw.json. Also, verify thatplugins.slots.memorypoints to"modelstudio-memory-for-openclaw". After you make the corrections, runopenclaw gateway restartagain.Why do I see an InvalidApiKey error in the logs?
This error indicates that the DashScope API key is invalid or has expired. Log on to the Alibaba Cloud Model Studio console to verify the API key status and create a new one if necessary. If you are using an environment variable, verify that
DASHSCOPE_API_KEYis set correctly and that the Gateway process can read the variable.Can I configure an API key from an Alibaba Cloud Model Studio Coding Plan?
This is not supported.
How do I view the plugin's operational logs?
The OpenClaw Gateway log files are stored by date in the system's temporary directory. The filename format is
openclaw-YYYY-MM-DD.log.# Linux / macOS tail -f /tmp/openclaw/openclaw-$(date +%F).log | grep modelstudio-memory # Windows PowerShell Get-Content "$env:TEMP\openclaw\openclaw-$(Get-Date -Format 'yyyy-MM-dd').log" -Wait | Select-String "modelstudio-memory"The plugin's automatic capture and recall mechanisms cover most scenarios and do not require extra intervention. You can monitor the growth of memory data in the Memory Library and adjust the
topKand cache policy as your business needs grow.
References
Document | Description |
Official Alibaba Cloud documentation for OpenClaw integration and configuration. | |
Create and Manage API Keys for Alibaba Cloud Model Studio | |
Complete parameter descriptions and code examples for APIs such as AddMemory and SearchMemory. | |
Create and manage memory libraries in the console. |



