Skip to content

feat: add OpenClaw plugin and documentation#3964

Merged
deshraj merged 1 commit intomainfrom
user/dyadav/add-openclaw
Feb 2, 2026
Merged

feat: add OpenClaw plugin and documentation#3964
deshraj merged 1 commit intomainfrom
user/dyadav/add-openclaw

Conversation

@deshraj
Copy link
Copy Markdown
Collaborator

@deshraj deshraj commented Feb 2, 2026

Summary

  • Adds 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 (memory_search, memory_list, memory_store, memory_get, memory_forget)
  • Adds integration documentation to the docs site under Integrations > Agent Frameworks

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
// ============================================================================

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interfaces and types can go into a types.ts for better modularity and readibility

page_size?: number;
}

interface MemoryItem {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memory item can also contain run_id

}

interface SearchOptions {
user_id: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entities can be extracted in a single type and then extended in this type

}

interface ListOptions {
user_id: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind off redundant

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done async to unblock the execution

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Event loop will handle this

// 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also go into a constants file

// ============================================================================
// Config Schema
// ============================================================================

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

);
}

return new PlatformProvider(cfg.apiKey!, cfg.orgId, cfg.projectId);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again sending org id and project id is redundant

// ============================================================================
// Provider Factory
// ============================================================================

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can go into a factory.ts

// Tools
// ========================================================================

api.registerTool(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a tools.ts would have been better suited here

@deshraj
Copy link
Copy Markdown
Collaborator Author

deshraj commented Feb 2, 2026

Thanks Saket. Will incorporate these in the follow up PR. Right now, trying to meet the deadline.

@whysosaket
Copy link
Copy Markdown
Member

Thanks Saket. Will incorporate these in the follow up PR. Right now, trying to meet the deadline.

Sounds good! Approved

@deshraj deshraj merged commit 3d3e875 into main Feb 2, 2026
4 checks passed
@deshraj deshraj deleted the user/dyadav/add-openclaw branch February 2, 2026 18:04
garciaba79 pushed a commit to garciaba79/mem0 that referenced this pull request Feb 12, 2026
@Zlo7
Copy link
Copy Markdown
Contributor

Zlo7 commented Feb 12, 2026

@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

  • Problem: Hook returns { systemContext: ... } but OpenClaw expects { prependContext: ... }
  • Result: Memories are fetched but never injected into prompts
  • Fix: One-line property rename

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.

jamebobob pushed a commit to jamebobob/mem0-vigil-recall that referenced this pull request Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants