feat: add OpenClaw plugin and documentation#3964
Conversation
Add the @mem0/openclaw-mem0 plugin that provides long-term memory for OpenClaw agents: - Auto-recall injects relevant memories before agent responses - Auto-capture stores important facts after each turn - Supports both Mem0 Cloud (platform) and self-hosted (open-source) modes - Includes 5 agent tools for explicit memory operations Also adds integration documentation to the docs site. Co-authored-by: Cursor <cursoragent@cursor.com>
| // ============================================================================ | ||
| // Types | ||
| // ============================================================================ | ||
|
|
There was a problem hiding this comment.
interfaces and types can go into a types.ts for better modularity and readibility
| page_size?: number; | ||
| } | ||
|
|
||
| interface MemoryItem { |
There was a problem hiding this comment.
memory item can also contain run_id
| } | ||
|
|
||
| interface SearchOptions { | ||
| user_id: string; |
There was a problem hiding this comment.
entities can be extracted in a single type and then extended in this type
| } | ||
|
|
||
| interface ListOptions { | ||
| user_id: string; |
| private async _init(): Promise<void> { | ||
| const { default: MemoryClient } = await import("mem0ai"); | ||
| const opts: Record<string, string> = { apiKey: this.apiKey }; | ||
| if (this.orgId) opts.org_id = this.orgId; |
| if (options.enable_graph) opts.enable_graph = options.enable_graph; | ||
| if (options.output_format) opts.output_format = options.output_format; | ||
|
|
||
| const result = await this.client.add(messages, opts); |
There was a problem hiding this comment.
This can be done async to unblock the execution
| // Default Custom Instructions & Categories | ||
| // ============================================================================ | ||
|
|
||
| const DEFAULT_CUSTOM_INSTRUCTIONS = `Your Task: Extract and maintain a structured, evolving profile of the user from their conversations with an AI assistant. Capture information that would help the assistant provide personalized, context-aware responses in future interactions. |
There was a problem hiding this comment.
Prompts can go into a separate prompts file
| - Raw code snippets (capture the intent/decision, not the code itself) | ||
| - Information the user explicitly asks not to remember`; | ||
|
|
||
| const DEFAULT_CUSTOM_CATEGORIES: Record<string, string> = { |
There was a problem hiding this comment.
This can also go into a constants file
| // ============================================================================ | ||
| // Config Schema | ||
| // ============================================================================ | ||
|
|
| ); | ||
| } | ||
|
|
||
| return new PlatformProvider(cfg.apiKey!, cfg.orgId, cfg.projectId); |
There was a problem hiding this comment.
Again sending org id and project id is redundant
| // ============================================================================ | ||
| // Provider Factory | ||
| // ============================================================================ | ||
|
|
There was a problem hiding this comment.
This can go into a factory.ts
| // Tools | ||
| // ======================================================================== | ||
|
|
||
| api.registerTool( |
There was a problem hiding this comment.
a tools.ts would have been better suited here
|
Thanks Saket. Will incorporate these in the follow up PR. Right now, trying to meet the deadline. |
Sounds good! Approved |
|
@deshraj thanks for the OpenClaw plugin! I discovered an issue with the auto-recall feature and wanted to bring it to your attention. Issue: Auto-recall silently fails due to property name mismatch
I've submitted:
The fix is minimal and maintains all your original functionality. Would appreciate your review when you have a moment! I realize this is a pretty large repo so it isn't critical for mem0 overall, but I believe it's critical for the OpenClaw plugin. |
Summary
@mem0/openclaw-mem0plugin that provides long-term memory for OpenClaw agentsmemory_search,memory_list,memory_store,memory_get,memory_forget)