refactor(integrations): shared agent plugin runtimes and native adapters (#7203)
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
---
|
||||
title: Antigravity
|
||||
description: "Add persistent memory to Google Antigravity with the Mem0 plugin: MCP server, lifecycle hooks, and slash commands."
|
||||
description: "Add persistent memory to Google Antigravity with the Mem0 plugin: a search tool, lifecycle hooks, and memory skills."
|
||||
---
|
||||
|
||||
Add persistent memory to [**Google Antigravity**](https://antigravity.google) (`agy` CLI and Desktop IDE) with the Mem0 plugin. Your agent forgets everything between sessions. Mem0 fixes that by storing decisions, preferences, and learnings so they carry over automatically.
|
||||
Add persistent memory to [**Google Antigravity**](https://antigravity.google) (`agy` CLI and Desktop IDE) with the Mem0 plugin. The plugin captures completed work, and Antigravity can search those memories in later sessions.
|
||||
|
||||
<Info>Current plugin version: `0.3.1`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. A Mem0 API key (starts with `m0-`):
|
||||
- <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=integration-antigravity">Get your API key</a> (free sign-up at <a href="https://app.mem0.ai?utm_source=oss&utm_medium=integration-antigravity">app.mem0.ai</a>)
|
||||
|
||||
2. Add it to your shell profile so it persists across sessions:
|
||||
2. Python 3.10 or newer available as `python3`
|
||||
|
||||
3. Add the key to your shell profile so it persists across sessions:
|
||||
|
||||
<CodeGroup>
|
||||
```bash zsh
|
||||
@@ -26,22 +30,33 @@ echo 'export MEM0_API_KEY="m0-your-api-key"' >> ~/.bashrc && source ~/.bashrc
|
||||
|
||||
**Option A: degit** (recommended):
|
||||
|
||||
<Warning>
|
||||
When upgrading an existing installation, move `~/.gemini/config/plugins/mem0` aside first. Installing over that directory can leave obsolete files from older plugin versions.
|
||||
</Warning>
|
||||
|
||||
```bash
|
||||
# Install the plugin (MCP server, hooks, scripts)
|
||||
npx degit mem0ai/mem0/integrations/mem0-plugin ~/.gemini/config/plugins/mem0
|
||||
npx degit mem0ai/mem0/integrations/antigravity-plugin ~/.gemini/config/plugins/mem0
|
||||
```
|
||||
|
||||
This installs the MCP server, lifecycle hooks, and shared scripts.
|
||||
This installs the generated Antigravity bundle with the Mem0 server, lifecycle hooks, and six memory skills.
|
||||
|
||||
## What's Included
|
||||
|
||||
| Component | Included |
|
||||
|-----------|:--------:|
|
||||
| MCP Server (9 memory tools) | Yes |
|
||||
| Local MCP Server (`search_memories`) | Yes |
|
||||
| Lifecycle Hooks | Yes |
|
||||
| 16 Slash Commands | Yes |
|
||||
| 6 Memory Skills | Yes |
|
||||
| Sidekick Agent | Yes |
|
||||
|
||||
## Available MCP Tools
|
||||
## Memory tools and skills
|
||||
|
||||
The full plugin exposes a focused `search_memories` tool and captures completed work through lifecycle hooks. Six skills provide search, status, remember, forget, pause, and resume workflows. A native sidekick can handle a bounded task in the workspace assigned by Antigravity; it does not claim Claude Code worktree isolation.
|
||||
|
||||
If you need the full set of direct CRUD tools, connect the [hosted Mem0 MCP server](/platform/mem0-mcp) separately instead of installing both configurations under the same server name.
|
||||
|
||||
## Hosted MCP tools
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
@@ -57,23 +72,46 @@ This installs the MCP server, lifecycle hooks, and shared scripts.
|
||||
|
||||
## Lifecycle Hooks
|
||||
|
||||
The plugin uses the same shell scripts as Claude Code, Cursor, and Codex: hooks bridge environment variables using `${extensionPath}` (Antigravity's plugin-root token).
|
||||
The plugin translates Antigravity events into the shared Mem0 capture lifecycle.
|
||||
|
||||
| Hook | Event | What it does |
|
||||
|------|-------|-------------|
|
||||
| **Session start** | `SessionStart` | Loads prior memories and displays status banner |
|
||||
| **User prompt** | `UserPromptSubmit` | Searches relevant memories before each message |
|
||||
| **Pre-tool** | `PreToolUse` | Blocks MEMORY.md writes, enforces `user_id`/`app_id` on mem0 tools |
|
||||
| **Post-tool** | `PostToolUse` | Tracks stats, scans bash errors for related memories |
|
||||
| **Stop** | `Stop` | Stores a session summary at the end of every assistant turn (not just at session end) |
|
||||
| **Invocation** | `PreInvocation` | Initializes the first invocation and recovers pending capture |
|
||||
| **Post-tool** | `PostToolUse` | Records useful tool results and failures |
|
||||
| **Stop** | `Stop` | Captures the completed exchange for a later session |
|
||||
|
||||
What you type is stored as yours. What the agent produces (session summaries and compaction summaries) is stored as the assistant's, so its suggestions never become your stated preferences.
|
||||
Recall is explicit through `search_memories` and the search skill. The current Antigravity adapter does not inject query-specific memory during `PreInvocation` because that event does not include the user's prompt.
|
||||
|
||||
What you type is stored as yours. Captured agent summaries are stored as the assistant's, so its suggestions never become your stated preferences.
|
||||
|
||||
## Antigravity 1.1.25 workarounds
|
||||
|
||||
Antigravity 1.1.25 can validate a plugin's `mcp_config.json` without loading the server. Check whether Mem0 is registered:
|
||||
|
||||
```bash
|
||||
agy mcp list
|
||||
```
|
||||
|
||||
If `mem0` is absent, register the plugin's bundled server with Antigravity's supported global MCP command, then start a new session:
|
||||
|
||||
```bash
|
||||
agy mcp add mem0 python3 ~/.gemini/config/plugins/mem0/core/mcp_server.py
|
||||
```
|
||||
|
||||
The same release can send hooks with an empty `workspacePaths` array. For the `agy` CLI, pass the current repository explicitly:
|
||||
|
||||
```bash
|
||||
MEM0_CWD="$PWD" agy
|
||||
```
|
||||
|
||||
The adapter uses `MEM0_CWD` only when Antigravity omits the workspace. If neither value is available, it skips recall and capture instead of writing memories under an incorrect repository scope.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **No tools appearing**: Restart your Antigravity session after installation
|
||||
- **"Connection failed"**: Verify your key is set: `echo $MEM0_API_KEY`
|
||||
- **MCP 401 Unauthorized**: If `${MEM0_API_KEY}` interpolation doesn't work in your `agy` version, replace with your literal key in `mcp_config.json`
|
||||
- **No `mem0` entry in `agy mcp list`**: Use the Antigravity 1.1.25 global MCP registration command above
|
||||
- **Hooks do not capture in the CLI**: Launch `agy` with `MEM0_CWD="$PWD"`
|
||||
- **"Connection failed"**: Verify your key is set without printing it: `test -n "$MEM0_API_KEY" && echo configured`
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Mem0 MCP Setup" icon="puzzle-piece" href="/platform/mem0-mcp">
|
||||
|
||||
@@ -5,6 +5,8 @@ description: "Persistent cross-session memory for Claude Code. Install once, mem
|
||||
|
||||
Claude Code forgets everything between sessions. This plugin fixes that. Install it, work normally, and Claude remembers what happened across sessions.
|
||||
|
||||
<Info>Current plugin version: `0.3.1`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. A Mem0 Platform account and API key (starts with `m0-`):
|
||||
@@ -71,6 +73,8 @@ Review its result and send any corrections back to the same sidekick.
|
||||
|
||||
Changes stay in the sidekick's worktree until the main agent reviews and copies them over. By default the worktree branches from the repo's default branch. Set `worktree.baseRef` to `"head"` in your Claude settings to branch from the current commit instead. Uncommitted changes are not copied into the sidekick's worktree.
|
||||
|
||||
At startup, Sidekick receives the memories already recalled for its parent session. It can also call the Mem0 search tool for its assigned task. Start and completion hooks track its work locally; completing a Sidekick task does not independently send a memory-extraction request. Sidekick returns its result, validation, and a local commit when it changes files, so the main agent can review the work before incorporating it.
|
||||
|
||||
## How it works
|
||||
|
||||
The plugin follows a simple cycle: capture during a session, extract memories in the background, recall in the next session.
|
||||
@@ -81,11 +85,11 @@ The plugin follows a simple cycle: capture during a session, extract memories in
|
||||
|
||||
**Step by step:**
|
||||
|
||||
1. **Capture.** Hooks save the main agent's activity locally: user messages, Claude's answers, changed files, and short test/build results. Subagent (sidekick) output is excluded. No model calls, no blocking.
|
||||
1. **Capture.** Hooks save the main agent's activity locally: user messages, Claude's answers, changed files, and short test/build results. Direct Sidekick lifecycle records stay local. Subagent results included in the main transcript can provide supporting evidence for extraction; the main agent's final response establishes the outcome. Capture does not call a model.
|
||||
|
||||
2. **Flush.** After every five completed exchanges, a detached background worker sends that batch to Mem0. Large exchanges flush sooner. Ending or compacting the session flushes anything remaining. If the session sits idle, an auto-flush runs after five minutes (configurable with `MEM0_CODE_IDLE_FLUSH_SECONDS`). The timer resets on each new exchange. The worker survives Claude Code exiting.
|
||||
|
||||
3. **Extract.** Each flush sends a single `add` call with `agent_id` (the project identity), `user_id` (you), `app_id` (the repository), and `run_id` (the session). Mem0 classifies each extracted memory as shared project knowledge or a personal preference.
|
||||
3. **Extract.** Each flush sends `add` calls with `agent_id` (the project identity), `user_id` (you), `app_id` (the repository), and `run_id` (the session). Prompts and responses are redacted without a character cutoff. Large conversations are split across requests without dropping message text. Mem0 classifies each extracted memory as shared project knowledge or a personal preference.
|
||||
|
||||
4. **Recall.** On the next session's first prompt, the plugin searches automatically and supplies up to five relevant memories. No model is called to write the query.
|
||||
|
||||
@@ -110,10 +114,14 @@ Every memory carries identifiers showing where it came from:
|
||||
| Identifier | What it is | Example |
|
||||
| --- | --- | --- |
|
||||
| `user_id` | You (personal memory only) | Your Mem0 user ID |
|
||||
| `agent_id` | The project identity (shared memory only) | `acme-payments-api` |
|
||||
| `agent_id` | The project identity (shared memory only) | `acme-payments-api-<hash>` |
|
||||
| `app_id` | The repository (scopes both lanes) | `acme-payments-api` |
|
||||
| `run_id` | The Claude Code session | The session ID |
|
||||
|
||||
New Git repository memories use an `agent_id` with a hash of the Git remote identity so matching owner/repository names on different hosts stay separate. Searches also include the previous unhashed `agent_id`, scoped by the repository's `app_id`, so existing shared memories remain available after upgrading. Those older memories retain their original namespace, which did not distinguish Git hosts. Local folders continue using a hash of their path.
|
||||
|
||||
Explicitly forgetting shared project memory with `--include-project-memory` covers both repository IDs. Without that option, shared memories are preserved.
|
||||
|
||||
A search returns the union of shared project memory and your personal preferences. The scope narrows the project part:
|
||||
|
||||
| Scope | What you get |
|
||||
@@ -124,7 +132,7 @@ A search returns the union of shared project memory and your personal preference
|
||||
|
||||
The `dir` scope is hierarchical: a parent directory sees everything in its children, but a child never sees the parent's memories.
|
||||
|
||||
Pass `--run-id <session-id>` to see only what one specific session recorded. Set the default scope with the `search_scope` setting or `MEM0_CODE_SEARCH_SCOPE` env var.
|
||||
The search tool accepts an optional `run_id` with every scope (`repo`, `dir`, and `mine`); `/mem0:search` exposes it as `--run-id session-id`. It restricts both shared and personal results to memories saved in that coding-agent session. Omit it to search across sessions. This is a memory filter, not a label for the session making the request; automatically filtering by the current session would hide earlier-session memories. Each memory update still records the session's `run_id`. Set the default scope with the `search_scope` setting or `MEM0_CODE_SEARCH_SCOPE` env var.
|
||||
|
||||
## Settings
|
||||
|
||||
|
||||
+26
-32
@@ -1,9 +1,11 @@
|
||||
---
|
||||
title: Codex
|
||||
description: "Add persistent memory to OpenAI Codex with the Mem0 plugin: MCP server, lifecycle hooks, and SDK skill."
|
||||
description: "Add persistent memory to OpenAI Codex with automatic capture, automatic recall, a search tool, and six memory skills."
|
||||
---
|
||||
|
||||
Add persistent memory to [**OpenAI Codex**](https://openai.com/codex/) with the Mem0 plugin. Codex forgets everything between tasks. This plugin fixes that by connecting to Mem0's cloud memory layer via MCP, automatically capturing learnings at key lifecycle points, and retrieving relevant context before every response.
|
||||
Add persistent memory to [**OpenAI Codex**](https://openai.com/index/codex/) with the Mem0 plugin. Codex forgets everything between tasks. This plugin fixes that by connecting to Mem0's cloud memory layer via MCP, automatically capturing learnings at key lifecycle points, and retrieving relevant context before every response.
|
||||
|
||||
<Info>Current plugin version: `0.3.1`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -15,7 +17,9 @@ Before setting up Mem0 with Codex, ensure you have:
|
||||
|
||||
2. OpenAI Codex access
|
||||
|
||||
3. Your API key added to your shell profile (persists across sessions):
|
||||
3. Python 3.10 or newer available as `python3`
|
||||
|
||||
4. Your API key added to your shell profile (persists across sessions):
|
||||
|
||||
<CodeGroup>
|
||||
```bash zsh
|
||||
@@ -33,7 +37,7 @@ source ~/.bashrc
|
||||
|
||||
### Option A: Plugin Marketplace (Recommended)
|
||||
|
||||
Install the full plugin including MCP server, lifecycle hooks, and SDK skill.
|
||||
Install the full plugin, including automatic capture and recall, the `search_memories` tool, and six memory skills.
|
||||
|
||||
1. Add the Mem0 marketplace:
|
||||
|
||||
@@ -88,7 +92,7 @@ codex plugin marketplace remove mem0-plugins # unregister the marketplace enti
|
||||
To update, run `codex plugin marketplace upgrade` to pull the latest from the Mem0 repo.
|
||||
|
||||
<Info icon="check">
|
||||
After either option, start a new Codex task and ask: *"List my mem0 entities"* or *"Search my memories for hello"*. If the `mem0` tools appear and respond, you're all set.
|
||||
After Option A, ask Codex to search memory for a recent project decision. After Option B, ask it to list your Mem0 entities. If the matching tool responds, the connection is ready.
|
||||
</Info>
|
||||
|
||||
## Codex Cloud
|
||||
@@ -106,13 +110,16 @@ Lifecycle hooks that shell out to local scripts (Option A) are not applicable in
|
||||
|
||||
| Component | Plugin Install | MCP Only |
|
||||
|-----------|:--------------:|:--------:|
|
||||
| MCP Server (9 memory tools) | Yes | Yes |
|
||||
| Lifecycle Hooks | Opt-in (see below) | No |
|
||||
| Mem0 SDK Skill | Yes | No |
|
||||
| Memory tools | `search_memories` | 9 CRUD tools |
|
||||
| Lifecycle hooks | Yes | No |
|
||||
| Native subagent memory lifecycle | Yes | No |
|
||||
| Memory skills | 6 | No |
|
||||
|
||||
## Available MCP Tools
|
||||
Codex plugins cannot currently bundle a named custom agent. If you define project or user agents under `.codex/agents/` or `~/.codex/agents/`, the full Mem0 plugin gives every native subagent the parent turn's retrieved memory context and records its completed result.
|
||||
|
||||
Once installed, the following tools are available in every Codex session:
|
||||
## Direct MCP tools
|
||||
|
||||
Option B exposes the following hosted tools. The full plugin in Option A uses the focused `search_memories` tool and captures writes through lifecycle hooks.
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
@@ -126,33 +133,20 @@ Once installed, the following tools are available in every Codex session:
|
||||
| `delete_entities` | Delete a user/agent/app/run entity and its memories |
|
||||
| `list_entities` | List users/agents/apps/runs stored in Mem0 |
|
||||
|
||||
## Lifecycle Hooks
|
||||
## Lifecycle hooks
|
||||
|
||||
Unlike Claude Code, Codex has no plugin-host mechanism for auto-wiring hooks from an installed plugin: it only reads hooks from `~/.codex/hooks.json` (or `<repo>/.codex/hooks.json`). Installing the plugin (Option A) does **not** turn hooks on by itself. To enable them, run the bundled installer once against your local clone:
|
||||
|
||||
```bash
|
||||
python3 <path-to-your-clone>/integrations/mem0-plugin/scripts/install_codex_hooks.py
|
||||
```
|
||||
|
||||
This merges Mem0's entries into `~/.codex/hooks.json` and is idempotent (safe to re-run after upgrading). It also requires the `codex_hooks` feature flag in `~/.codex/config.toml`:
|
||||
|
||||
```toml
|
||||
[features]
|
||||
codex_hooks = true
|
||||
```
|
||||
|
||||
The installer prints a reminder if the flag isn't set. Restart Codex after installing hooks or editing the config. To remove: `python3 .../install_codex_hooks.py --uninstall`.
|
||||
|
||||
Once enabled, Mem0 hooks into Codex's lifecycle to automatically manage memory:
|
||||
Option A registers the hooks with the plugin. No separate hook installer or global `hooks.json` edit is required.
|
||||
|
||||
| Hook | Event | What it does |
|
||||
|------|-------|-------------|
|
||||
| **Session start** | `SessionStart` | Loads prior memories and displays status banner |
|
||||
| **User prompt** | `UserPromptSubmit` | Searches relevant memories before each message |
|
||||
| **Pre-tool (3 handlers)** | `PreToolUse` | Blocks MEMORY.md writes; enforces `user_id`/`app_id` on mem0 tool calls; scans files being read for relevant memory context |
|
||||
| **Post-tool** | `PostToolUse` | Tracks stats, scans bash errors for related memories |
|
||||
| **Stop** | `Stop` | Stores a session summary at the end of every assistant turn (not just at session end) |
|
||||
| **Pre-compact** | `PreCompact` | Stores a summary before the context is compacted |
|
||||
| **Post-tool** | `PostToolUse` | Records useful tool outcomes for the completed exchange |
|
||||
| **Subagent start** | `SubagentStart` | Reuses the parent turn's retrieved memory context in the child |
|
||||
| **Subagent stop** | `SubagentStop` | Records the child transcript path and completed result |
|
||||
| **Stop** | `Stop` | Captures completed work and starts a background flush when needed |
|
||||
| **Pre-compact** | `PreCompact` | Flushes pending capture before context compaction |
|
||||
| **Session end** | `SessionEnd` | Flushes any remaining capture in the background |
|
||||
|
||||
What you type is stored as yours. What Codex produces (session summaries and compaction summaries) is stored as the assistant's, so its suggestions never become your stated preferences.
|
||||
|
||||
@@ -181,7 +175,7 @@ You: Add WebSocket support for real-time notification delivery.
|
||||
- **"Connection failed"**: Verify `MEM0_API_KEY` is set: `echo $MEM0_API_KEY`
|
||||
- **No tools appearing**: Restart your Codex session after installation
|
||||
- **Duplicate `mem0` MCP / "tool collision" errors**: You combined Option A with Option B. Remove the `[mcp_servers.mem0]` block from `~/.codex/config.toml`; the plugin registers it automatically
|
||||
- **Hooks not firing**: Hooks are opt-in and are not installed by the marketplace install itself. Run `scripts/install_codex_hooks.py` (see [Lifecycle Hooks](#lifecycle-hooks)), confirm `codex_hooks = true` is set under `[features]` in `~/.codex/config.toml`, and restart Codex. MCP-only installs (Option B) never include hooks
|
||||
- **Hooks not firing**: Confirm you installed Option A and restart Codex. MCP-only installs (Option B) do not include hooks.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Mem0 MCP Setup" icon="puzzle-piece" href="/platform/mem0-mcp">
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
---
|
||||
title: Cursor
|
||||
description: "Add persistent memory to Cursor with the Mem0 MCP server for context-aware coding."
|
||||
description: "Add persistent memory to Cursor with automatic capture, explicit recall, a search tool, and six memory skills."
|
||||
---
|
||||
|
||||
Add persistent memory to [**Cursor**](https://cursor.com) with the Mem0 MCP server. Your AI assistant forgets everything between sessions. Mem0 fixes that by connecting Cursor to Mem0's cloud memory layer via MCP so you can save and retrieve relevant context during coding sessions.
|
||||
Add persistent memory to [**Cursor**](https://cursor.com) with the Mem0 plugin. Cursor captures completed work in the background, and its agent can search relevant project context in later sessions. You can also connect only the hosted MCP server when you do not need lifecycle capture.
|
||||
|
||||
<Info>Current plugin version: `0.3.1`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -15,7 +17,9 @@ Before setting up Mem0 with Cursor, ensure you have:
|
||||
|
||||
2. Cursor installed ([cursor.com](https://cursor.com))
|
||||
|
||||
3. Your API key added to your shell profile (persists across sessions):
|
||||
3. Python 3.10 or newer available as `python3`
|
||||
|
||||
4. Your API key added to your shell profile (persists across sessions):
|
||||
|
||||
<CodeGroup>
|
||||
```bash zsh
|
||||
@@ -35,13 +39,25 @@ source ~/.bashrc
|
||||
|
||||
## Installation
|
||||
|
||||
### Option A: One-Click Deeplink (MCP Only)
|
||||
### Option A: Full Plugin (Recommended)
|
||||
|
||||
Add the Mem0 marketplace:
|
||||
|
||||
```bash
|
||||
cursor-agent plugin marketplace add https://github.com/mem0ai/mem0
|
||||
```
|
||||
|
||||
Open Cursor's **Customize** page or run `/plugins`, select the **Mem0 Plugins** marketplace, and install **Mem0** at user or project scope. Enter your Mem0 API key when Cursor asks for the plugin configuration, then restart Cursor.
|
||||
|
||||
The full plugin includes automatic capture, the `search_memories` recall tool, lifecycle hooks, a sidekick agent, and six memory skills.
|
||||
|
||||
### Option B: One-Click Deeplink (MCP Only)
|
||||
|
||||
The fastest way to get started. Click the link below to install the Mem0 MCP server directly in Cursor:
|
||||
|
||||
[Install Mem0 MCP in Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=mem0&config=eyJtY3BTZXJ2ZXJzIjp7Im1lbTAiOnsidXJsIjoiaHR0cHM6Ly9tY3AubWVtMC5haS9tY3AvIiwiaGVhZGVycyI6eyJBdXRob3JpemF0aW9uIjoiVG9rZW4gJHtlbnY6TUVNMF9BUElfS0VZfSJ9fX19)
|
||||
|
||||
### Option B: npx (MCP Only)
|
||||
### Option C: npx (MCP Only)
|
||||
|
||||
```bash
|
||||
npx mcp-add \
|
||||
@@ -51,7 +67,7 @@ npx mcp-add \
|
||||
--clients "cursor"
|
||||
```
|
||||
|
||||
### Option C: Manual Configuration (MCP Only)
|
||||
### Option D: Manual Configuration (MCP Only)
|
||||
|
||||
Add the following to your `.cursor/mcp.json`:
|
||||
|
||||
@@ -73,9 +89,20 @@ Add the following to your `.cursor/mcp.json`:
|
||||
</Info>
|
||||
|
||||
|
||||
## Available MCP Tools
|
||||
## What's included
|
||||
|
||||
Once installed, the following tools are available in every Cursor session:
|
||||
| Component | Full plugin | MCP only |
|
||||
| --- | :---: | :---: |
|
||||
| Memory tools | `search_memories` | 9 CRUD tools |
|
||||
| Automatic capture | Yes | No |
|
||||
| Recall | `search_memories` | MCP search tools |
|
||||
| Lifecycle hooks | Yes | No |
|
||||
| Memory skills | 6 | No |
|
||||
| Sidekick agent | Yes | No |
|
||||
|
||||
## MCP-only tools
|
||||
|
||||
Options B, C, and D expose the following hosted tools. The full plugin uses the focused `search_memories` tool and captures writes through lifecycle hooks.
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
@@ -89,6 +116,25 @@ Once installed, the following tools are available in every Cursor session:
|
||||
| `delete_entities` | Delete a user/agent/app/run entity and its memories |
|
||||
| `list_entities` | List users/agents/apps/runs stored in Mem0 |
|
||||
|
||||
## Lifecycle hooks
|
||||
|
||||
The full plugin translates Cursor's native events into the shared Mem0 memory lifecycle:
|
||||
|
||||
| Cursor event | What Mem0 does |
|
||||
| --- | --- |
|
||||
| `sessionStart` | Initializes the project session and recovers pending capture |
|
||||
| `beforeSubmitPrompt` | Observes the submitted prompt; recall stays tool-driven because this event cannot inject context |
|
||||
| `postToolUse` / `postToolUseFailure` | Records useful tool results and failures |
|
||||
| `subagentStart` / `subagentStop` | Records the Mem0 Sidekick lifecycle and completed result |
|
||||
| `afterAgentResponse` / `stop` | Captures the completed exchange |
|
||||
| `preCompact` / `sessionEnd` | Flushes pending capture in the background |
|
||||
|
||||
<Note>
|
||||
Cursor's `beforeSubmitPrompt` hook can allow or block a prompt, but it cannot add context to that prompt. The plugin therefore gives the agent `search_memories` and a memory-aware sidekick for recall instead of claiming automatic per-prompt injection.
|
||||
</Note>
|
||||
|
||||
Cursor's `subagentStart` hook also cannot inject parent context. The bundled Sidekick searches Mem0 itself, while the lifecycle hooks correlate its start and completion for later capture.
|
||||
|
||||
## Example Workflow
|
||||
|
||||
```text
|
||||
@@ -112,7 +158,7 @@ You: The /orders endpoint is also slow, same pattern as before.
|
||||
## Troubleshooting
|
||||
|
||||
- **"Connection failed"**: Verify `MEM0_API_KEY` is set: `echo $MEM0_API_KEY`
|
||||
- **Duplicate tools**: If you had a previous MCP config for `mem0`, remove it before installing the plugin
|
||||
- **Duplicate tools**: Do not combine the full plugin with an MCP-only option. Remove the standalone `mem0` MCP entry before installing the plugin.
|
||||
- **No tools appearing**: Go to Cursor Settings > MCP and verify the `mem0` server shows as connected
|
||||
|
||||
<CardGroup cols={2}>
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
---
|
||||
title: DeepSeek Harness
|
||||
description: "Add persistent Mem0 memory to the DeepSeek Harness (Cordis) agent with two native tools: search and add."
|
||||
description: "Add persistent memory to DeepSeek Harness with automatic recall, automatic capture, and two native Mem0 tools."
|
||||
---
|
||||
|
||||
Add persistent memory to the [**DeepSeek Harness**](https://github.com/deepseek-ai/deepseek-harness) with `@mem0/deepseek-plugin`. The Harness agent forgets everything between sessions. This plugin gives it two Mem0-backed tools so recall and writes persist across runs, sharing the same memory bank you already use from Claude Code, Codex, and other agents.
|
||||
Add persistent memory to the [**DeepSeek Harness**](https://github.com/deepseek-ai/deepseek-harness) with `@mem0/deepseek-plugin`. The plugin recalls relevant context before a model request, captures completed turns, and provides explicit Mem0 tools when the agent needs them.
|
||||
|
||||
<Info>Current package version: `0.3.0`.</Info>
|
||||
|
||||
## Overview
|
||||
|
||||
The plugin registers two agent-callable tools:
|
||||
The plugin provides automatic memory plus two agent-callable tools:
|
||||
|
||||
| Tool | Does |
|
||||
| Capability | What it does |
|
||||
|---|---|
|
||||
| Automatic recall | Searches with the latest human prompt and adds unseen results to the model context |
|
||||
| Automatic capture | Stores the human and assistant messages from each completed turn |
|
||||
| `search_memory` | Recall facts from Mem0 relevant to a query |
|
||||
| `add_memory` | Store a fact in Mem0 for future sessions |
|
||||
|
||||
@@ -18,7 +22,15 @@ Unlike file-based memory plugins, Mem0 is a managed backend: server-side extract
|
||||
|
||||
## How it works
|
||||
|
||||
A Cordis plugin is a module exporting `apply(ctx, config)`. This one declares `inject = ['tools']` so it waits for the harness tool registry, then registers the two tools via `ctx.tools.register(...)`. When the plugin unmounts, the tools are removed automatically (Cordis revertible effects).
|
||||
A Cordis plugin is a module exporting `apply(ctx, config)`. This plugin waits for the Harness tool and system-prompt services, then uses their native extension points:
|
||||
|
||||
- `system-prompt/assemble` recalls memory before a model request.
|
||||
- `session/event` captures only completed turns from the durable event stream.
|
||||
- `ctx.tools.register(...)` exposes explicit search and add tools.
|
||||
|
||||
Cordis removes the listeners and tools when the plugin unmounts. Memory failures are fail-open, so a Mem0 outage does not stop the agent from completing its normal work.
|
||||
|
||||
DeepSeek Harness provides subagents through separate host-composition packages. This Mem0 package does not register a named Sidekick or claim child filesystem isolation. A Harness child uses Mem0 only when its own agent preset includes the Mem0 plugin.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -44,19 +56,28 @@ source ~/.bashrc
|
||||
|
||||
## Try it locally
|
||||
|
||||
1. Build the plugin:
|
||||
1. Build and pack the plugin:
|
||||
```sh
|
||||
cd integrations/deepseek-plugin
|
||||
pnpm install
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm build
|
||||
mkdir -p /tmp/mem0-deepseek-plugin
|
||||
pnpm pack --pack-destination /tmp/mem0-deepseek-plugin
|
||||
```
|
||||
|
||||
2. Point the Harness at it. Copy `cordis.example.yml`, set the absolute path to `dist/index.js` and your `userId`, then load it:
|
||||
2. Install it into a disposable Harness profile so Harness supplies its peer dependencies:
|
||||
```sh
|
||||
pnpm dsh web --patch ./integrations/deepseek-plugin/cordis.example.yml
|
||||
DSH_HOME=/tmp/mem0-dsh-dev pnpm dlx @deepseek-ai/dsh@0.1.1-rc.2 \
|
||||
plugin --profile headless add /tmp/mem0-deepseek-plugin/mem0-deepseek-plugin-0.3.0.tgz
|
||||
```
|
||||
|
||||
3. Open the web UI and ask the agent to remember something, then recall it in a later turn.
|
||||
3. Copy `cordis.example.yml`, set its installed package path and your `userId`, then load it with the same profile:
|
||||
```sh
|
||||
DSH_HOME=/tmp/mem0-dsh-dev pnpm dlx @deepseek-ai/dsh@0.1.1-rc.2 \
|
||||
web --patch ./integrations/deepseek-plugin/cordis.example.yml
|
||||
```
|
||||
|
||||
4. Open the web UI and ask the agent to remember something, then recall it in a later turn.
|
||||
|
||||
The `cordis.yml` entry looks like this:
|
||||
|
||||
@@ -65,10 +86,12 @@ The `cordis.yml` entry looks like this:
|
||||
- name: "@deepseek-ai/dsh-tools"
|
||||
- insert:
|
||||
- id: mem0
|
||||
name: "/absolute/path/to/integrations/deepseek-plugin/dist/index.js"
|
||||
name: "/tmp/mem0-dsh-dev/profiles/headless/node_modules/@mem0/deepseek-plugin/dist/index.js"
|
||||
config:
|
||||
# apiKey is read from MEM0_API_KEY when omitted here.
|
||||
userId: "your-user-id"
|
||||
autoRecall: true
|
||||
autoCapture: true
|
||||
# host: "https://your-onprem.mem0.ai" # optional: Platform on-prem / dedicated base URL
|
||||
```
|
||||
|
||||
@@ -80,10 +103,25 @@ For a Mem0 Platform on-prem or dedicated deployment, point `config.host` at that
|
||||
|---|---|---|---|
|
||||
| `apiKey` | no | `$MEM0_API_KEY` | Mem0 platform API key |
|
||||
| `userId` | yes | | Default entity that owns the memories |
|
||||
| `allowUserOverride` | no | `false` | Permit model-selected access to a different user only in a trusted multi-user deployment |
|
||||
| `host` | no | `api.mem0.ai` | Platform base URL (on-prem / dedicated) |
|
||||
| `autoRecall` | no | `true` | Recall relevant memory before model requests |
|
||||
| `autoCapture` | no | `true` | Store completed human and assistant turns |
|
||||
|
||||
Both tools also accept optional per-call `userId`, `agentId`, and `runId` params so a single install can partition memory by entity, agent, or session; when omitted they fall back to the configured `userId`.
|
||||
|
||||
## Telemetry
|
||||
|
||||
Writes are tagged `source="DEEPSEEK_HARNESS"` so Mem0's backend can attribute usage to this integration.
|
||||
Writes are tagged `source="DEEPSEEK_HARNESS"` so Mem0 can attribute usage to this integration. Anonymous usage events include operation names, durations, result counts, and coarse failure kinds. Queries, memory text, entity IDs, and API keys are never included. Set `MEM0_TELEMETRY=false` to opt out.
|
||||
|
||||
<Note>
|
||||
This plugin is a developer preview and tracks the evolving DeepSeek Harness plugin API.
|
||||
</Note>
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **`MISSING_CREDENTIAL` for `deepseek-official`**: Configure `DEEPSEEK_API_KEY` through Harness's Models page or export it in the shell that launches Harness.
|
||||
- **`EMFILE: too many open files, watch` on macOS**: Launch Harness with `CHOKIDAR_USEPOLLING=1`.
|
||||
- **Mem0 tools do not appear**: Run Harness with `--dump-config` and confirm the final composition contains the `mem0` row and the installed `dist/index.js` path.
|
||||
|
||||
Per-call `userId` overrides are rejected unless the operator enables `allowUserOverride: true`. Automatic recall and capture always use the configured user.
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
---
|
||||
title: Kimi Code
|
||||
description: "Add persistent project memory to Kimi Code with automatic capture, automatic recall, Mem0 skills, and tools."
|
||||
---
|
||||
|
||||
Kimi Code forgets project decisions between sessions. The Mem0 plugin captures completed work, recalls relevant context before a response, and gives Kimi explicit memory tools and skills.
|
||||
|
||||
<Info>Current plugin version: `0.3.1`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. A Mem0 Platform account and API key:
|
||||
- [Sign up at app.mem0.ai](https://app.mem0.ai?utm_source=oss&utm_medium=integration-kimi)
|
||||
- [Get your API key](https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=integration-kimi) (starts with `m0-`)
|
||||
|
||||
2. [Kimi Code](https://www.kimi.com/code) with plugin support.
|
||||
|
||||
3. Python 3.10+ and Git on your machine.
|
||||
|
||||
## Quick start
|
||||
|
||||
Export the key in the shell where you start Kimi Code:
|
||||
|
||||
```bash
|
||||
export MEM0_API_KEY='your-mem0-api-key'
|
||||
kimi
|
||||
```
|
||||
|
||||
Inside Kimi Code, install the native plugin bundle and reload the session:
|
||||
|
||||
```text
|
||||
/plugins install https://github.com/mem0ai/mem0/tree/main/integrations/kimi-plugin
|
||||
/reload
|
||||
```
|
||||
|
||||
Run `/plugins info mem0` to confirm that the plugin, MCP server, skills, hooks, and sidekick agent loaded.
|
||||
|
||||
## What you get
|
||||
|
||||
- **Automatic capture:** Kimi records completed exchanges locally and flushes durable project knowledge to Mem0 in the background.
|
||||
- **Automatic recall:** Relevant memories are added before Kimi answers the first prompt in a session.
|
||||
- **Explicit search:** Kimi can call `search_memories` when it needs a more specific answer.
|
||||
- **Six memory skills:** Search, status, remember, forget, pause, and resume use the same memory behavior as the other Mem0 coding-agent plugins.
|
||||
- **Project scoping:** Memories stay attached to the repository, with separate personal and shared project lanes.
|
||||
- **Kimi sidekick:** A focused subagent can investigate or implement a bounded task in a separate context. Filesystem isolation depends on the environment Kimi provides.
|
||||
|
||||
Credentials are redacted before memory capture. If Mem0 is unavailable, hooks fail open so Kimi can continue its normal work.
|
||||
|
||||
## How it works
|
||||
|
||||
Kimi's native lifecycle events are translated into the shared Mem0 memory lifecycle:
|
||||
|
||||
| Kimi event | What Mem0 does |
|
||||
| --- | --- |
|
||||
| `SessionStart` | Loads recent project context |
|
||||
| `UserPromptSubmit` | Searches for relevant memories before the response |
|
||||
| `PostToolUse` / `PostToolUseFailure` | Records useful tool results and failures |
|
||||
| `Stop` | Captures the completed exchange |
|
||||
| `PreCompact` / `SessionEnd` | Flushes pending capture in the background |
|
||||
| `SubagentStart` / `SubagentStop` | Passes parent context to the Mem0 sidekick and records its lifecycle |
|
||||
|
||||
## Verify the plugin
|
||||
|
||||
In one session, say:
|
||||
|
||||
```text
|
||||
Remember exactly: the release codename for this repository is ORCHID-9274.
|
||||
```
|
||||
|
||||
Start a new Kimi session in the same repository and ask:
|
||||
|
||||
```text
|
||||
What is the release codename for this repository? Do not infer it from repository files.
|
||||
```
|
||||
|
||||
Kimi should return `ORCHID-9274` from memory.
|
||||
|
||||
## Managing the plugin
|
||||
|
||||
```text
|
||||
/plugins list
|
||||
/plugins info mem0
|
||||
/plugins disable mem0
|
||||
/plugins enable mem0
|
||||
/plugins remove mem0
|
||||
```
|
||||
|
||||
Run `/reload` or start a new session after enabling, disabling, or reinstalling the plugin.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Problem | Fix |
|
||||
| --- | --- |
|
||||
| Missing API key | Start Kimi from a shell where `MEM0_API_KEY` is exported. |
|
||||
| Plugin changes do not appear | Run `/plugins reload`, then `/reload` or `/new`. |
|
||||
| MCP server is disabled | Run `/plugins mcp enable mem0 mem0`, then `/reload`. |
|
||||
| No memory in a later session | Wait a moment for the background flush, then ask Kimi to search memory explicitly. |
|
||||
| Remove the plugin | Run `/plugins remove mem0`. |
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Cursor" icon="arrow-pointer" href="/integrations/cursor">
|
||||
Add the same persistent project memory to Cursor
|
||||
</Card>
|
||||
<Card title="Claude Code" icon="/images/provider-icons/anthropic.svg" href="/integrations/claude-code">
|
||||
Use Mem0 with Claude Code and its isolated sidekick
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
||||
<Snippet file="star-on-github.mdx" />
|
||||
@@ -5,6 +5,8 @@ description: "Add long-term memory to OpenClaw agents using the Mem0 plugin with
|
||||
|
||||
Add long-term memory to [OpenClaw](https://github.com/openclaw/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.
|
||||
|
||||
<Info>Current package version: `1.1.0`.</Info>
|
||||
|
||||
## Overview
|
||||
|
||||
<Frame>
|
||||
@@ -14,11 +16,12 @@ Add long-term memory to [OpenClaw](https://github.com/openclaw/openclaw) agents
|
||||
The plugin provides:
|
||||
1. **Triage**: The agent extracts durable facts from conversations using a structured protocol with importance gates and domain overlays
|
||||
2. **Recall**: Before each turn, relevant memories are retrieved with reranking and injected into context
|
||||
3. **Dream**: Periodic memory consolidation merges duplicates, resolves conflicts, prunes stale entries
|
||||
4. **Agent Tools**: Eight tools for explicit memory operations during conversations
|
||||
3. **Agent Tools**: Eight tools for explicit memory operations during conversations
|
||||
|
||||
Skills mode, `autoRecall`, and `autoCapture` are all enabled by default during `openclaw mem0 init`.
|
||||
|
||||
Automatic capture preserves the full text of selected user and assistant messages after noise filtering and secret redaction, without a per-message character cutoff. It selects recent messages and earlier work summaries; it does not capture every message in the conversation.
|
||||
|
||||
## Requirements
|
||||
|
||||
Check your OpenClaw version:
|
||||
@@ -101,7 +104,7 @@ You no longer need manual config editing to get started. Everything happens insi
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
That's it. No API key, no config file editing, no environment variables. The plugin is now active with skills-based memory (triage, recall, and dream) running automatically.
|
||||
That's it. No API key, no config file editing, no environment variables. The plugin is now active with skills-based memory (triage and recall) running automatically.
|
||||
|
||||
<Note>The chat flow uses the same underlying config as manual setup: it writes `apiKey`, `userId`, and `skills` config into `openclaw.json` for you. You can still open the file to inspect or override values afterward.</Note>
|
||||
|
||||
@@ -142,7 +145,6 @@ That's it. No API key, no config file editing, no environment variables. The plu
|
||||
"keywordSearch": true,
|
||||
"identityAlwaysInclude": true
|
||||
},
|
||||
"dream": { "enabled": true },
|
||||
"domain": "companion"
|
||||
}
|
||||
}
|
||||
@@ -441,7 +443,7 @@ If `openclaw plugins update` fails:
|
||||
|
||||
### Auto-Capture and Auto-Recall
|
||||
|
||||
Auto-capture and auto-recall are **enabled by default**. When skills mode is configured (the default after `openclaw mem0 init`), these are ignored in favor of the skills-based triage/recall/dream protocol.
|
||||
Auto-capture and auto-recall are **enabled by default**. When skills mode is configured (the default after `openclaw mem0 init`), these are ignored in favor of the skills-based triage and recall protocol.
|
||||
|
||||
To disable either:
|
||||
|
||||
@@ -464,13 +466,12 @@ The agent can always use memory tools (`memory_add`, `memory_search`, etc.) expl
|
||||
|
||||
### Credential Protection
|
||||
|
||||
The plugin never stores API keys, tokens, or secrets as memories. Five independent layers enforce this:
|
||||
The plugin never stores API keys, tokens, or secrets as memories. Four independent layers enforce this:
|
||||
|
||||
1. **Triage gate**: The extraction prompt rejects values matching known credential patterns (`sk-`, `m0-`, `ghp_`, `AKIA`, `Bearer`, `password=`, `token=`, `secret=`)
|
||||
2. **Dream cleanup**: Periodic memory consolidation deletes any memories that slipped through containing credential patterns
|
||||
3. **Extraction instructions**: Default extraction rules explicitly instruct the model to store only that a credential was configured, never the value
|
||||
4. **Configurable patterns**: Add custom credential patterns via `skills.triage.credentialPatterns`
|
||||
5. **CLI redaction**: `openclaw mem0 config show` redacts sensitive fields (`apiKey`, `oss.*.config.apiKey`)
|
||||
2. **Extraction instructions**: Default extraction rules explicitly instruct the model to store only that a credential was configured, never the value
|
||||
3. **Configurable patterns**: Add custom credential patterns via `skills.triage.credentialPatterns`
|
||||
4. **CLI redaction**: `openclaw mem0 config show` redacts sensitive fields (`apiKey`, `oss.*.config.apiKey`)
|
||||
|
||||
### API Key Storage
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ description: "Add persistent memory to OpenCode with the Mem0 plugin: native SDK
|
||||
|
||||
Add persistent memory to [**OpenCode**](https://opencode.ai) with the Mem0 plugin. Your agent forgets everything between sessions. Mem0 fixes that by storing decisions, preferences, and learnings so they carry over automatically.
|
||||
|
||||
<Info>Current package version: `0.3.0`.</Info>
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. A Mem0 API key (starts with `m0-`):
|
||||
@@ -33,7 +35,7 @@ opencode plugin @mem0/opencode-plugin
|
||||
**Or let your agent do it**: paste this into OpenCode:
|
||||
|
||||
```
|
||||
Install @mem0/opencode-plugin by following https://raw.githubusercontent.com/mem0ai/mem0/main/integrations/mem0-plugin/.opencode-plugin/README.md
|
||||
Install @mem0/opencode-plugin by following https://raw.githubusercontent.com/mem0ai/mem0/main/integrations/opencode-plugin/README.md
|
||||
```
|
||||
|
||||
This adds the plugin to your `~/.config/opencode/opencode.json`. Restart OpenCode. You get the native memory tools, lifecycle hooks, and all `/mem0-*` slash commands. The memory tools are registered by the plugin itself via the `mem0ai` SDK. No MCP server to configure.
|
||||
@@ -61,9 +63,9 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
|
||||
| Component | Plugin (A) | Standalone MCP (B) |
|
||||
|-----------|:----------:|:------------------:|
|
||||
| 9 memory tools | Native (SDK) | Remote MCP server |
|
||||
| 10 memory tools | Native (SDK) | 9 remote MCP tools |
|
||||
| Lifecycle Hooks | Yes | No |
|
||||
| 9 Skills | Yes | No |
|
||||
| 7 Skills | Yes | No |
|
||||
|
||||
## Available Memory Tools
|
||||
|
||||
@@ -78,6 +80,7 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
| `delete_all_memories` | Bulk delete all memories in scope |
|
||||
| `delete_entities` | Delete a user/agent/app/run entity and its memories |
|
||||
| `list_entities` | List users/agents/apps/runs stored in Mem0 |
|
||||
| `get_event_status` | Check the processing status of an asynchronous memory event |
|
||||
|
||||
## Memory scope
|
||||
|
||||
@@ -87,9 +90,9 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
|-------|-------|--------|
|
||||
| `project` *(default)* | this repo (`user_id` + `app_id`) | this repo |
|
||||
| `session` | this run only (`+ run_id`) | this run |
|
||||
| `global` | **all your projects in the workspace** (`app_id: "*"`) | user-wide |
|
||||
| `global` | **all your projects in the workspace** (filtered by your user ID) | user-wide |
|
||||
|
||||
Ask naturally, for example, *"search my memories across all my projects"*. The agent passes `scope: "global"`. For normal questions it stays scoped to the current project automatically.
|
||||
Select `/mem0-scope global` before requesting a cross-project tool operation. A tool cannot enable global scope by supplying an argument alone. Switch back with `/mem0-scope project` when finished.
|
||||
|
||||
To change the **default** scope (used when no scope is passed), run the `/mem0-scope` skill:
|
||||
|
||||
@@ -117,31 +120,12 @@ The plugin uses the [mem0ai](https://www.npmjs.com/package/mem0ai) TypeScript SD
|
||||
| `experimental.session.compacting` | **Compaction** | Stores session state memory, then injects prior memories into compaction context so nothing is lost |
|
||||
| `shell.env` | **Shell env** | Exports `MEM0_USER_ID`, `MEM0_APP_ID`, `MEM0_SESSION_ID`, and `MEM0_BRANCH` to all shell executions |
|
||||
|
||||
## Auto-dream (memory consolidation)
|
||||
|
||||
The plugin can automatically consolidate stored memories by merging duplicates, dropping stale/sensitive entries, and rewriting vague ones. This keeps your memory set clean over time. It runs at most once per session, and only when **all** gates pass:
|
||||
|
||||
- **Time**: at least `minHours` (default 24) since the last consolidation
|
||||
- **Sessions**: at least `minSessions` (default 5) sessions since then
|
||||
- **Memories**: at least `minMemories` (default 20) stored for the project
|
||||
|
||||
A filesystem lock (`~/.mem0/mem0-dream.lock`) keeps two sessions from consolidating at once. Tune the thresholds with a `dream` block in `~/.mem0/settings.json`, or disable entirely with `MEM0_DREAM=false`:
|
||||
|
||||
```json
|
||||
{
|
||||
"dream": { "enabled": true, "auto": true, "minHours": 24, "minSessions": 5, "minMemories": 20 }
|
||||
}
|
||||
```
|
||||
|
||||
If auto-dream hasn't run yet, it's almost always because a gate hasn't been met (most often too few memories). Run `/mem0-status` to see the exact gate progress (e.g. `sessions 2/5, memories 3/20`), `/mem0-dream` to consolidate **now** regardless of the gates, or lower the thresholds above.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **No tools appearing**: Restart OpenCode after installing
|
||||
- **"Connection failed"**: Verify your key is set: `echo $MEM0_API_KEY`
|
||||
- **Plugin not loading**: Run `opencode plugin @mem0/opencode-plugin` again, then restart
|
||||
- **Hooks not firing**: Hooks require the plugin install (Option A). MCP-only installs don't include hooks.
|
||||
- **Auto-dream never runs**: It's gated (time + sessions + memories). Run `/mem0-status` to see which gate is blocking, or `/mem0-dream` to consolidate now.
|
||||
- **Wrong project name / memories not found**: The project id comes from your git remote; launch OpenCode from inside the repo (not your home directory). Check the resolved id with `/mem0-status`.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
---
|
||||
title: Pi Agent
|
||||
description: "Add persistent memory to Pi Agent with the Mem0 plugin semantic search, auto-capture, and dream consolidation."
|
||||
description: "Add persistent memory to Pi Agent with the Mem0 plugin, semantic search, and automatic capture."
|
||||
---
|
||||
|
||||
Add persistent memory to [**Pi Agent**](https://pi.dev) with `@mem0/pi-agent-plugin`. Your agent forgets everything between sessions. This plugin fixes that by automatically capturing knowledge from conversations, storing it in Mem0's cloud memory layer, and retrieving relevant context before every response.
|
||||
|
||||
<Info>Current package version: `0.3.0`.</Info>
|
||||
|
||||
## Overview
|
||||
|
||||
The plugin provides:
|
||||
1. **Auto-capture**: Extracts durable facts from both user and assistant messages automatically
|
||||
2. **Semantic recall**: Retrieves relevant memories via the `mem0_memory` tool before each response
|
||||
3. **Dream consolidation**: Periodic maintenance: merges duplicates, resolves contradictions, prunes stale entries
|
||||
4. **Monorepo-aware scoping**: Uses git root for project detection, consistent across subdirectories
|
||||
5. **Confirmation dialogs**: Destructive commands ask before acting via Pi's built-in UI
|
||||
6. **8 skills + 8 commands**: Essential memory management from slash commands and agent-guided workflows
|
||||
3. **Monorepo-aware scoping**: Uses git root for project detection, consistent across subdirectories
|
||||
4. **Confirmation dialogs**: Destructive commands ask before acting via Pi's built-in UI
|
||||
5. **6 skills + 6 commands**: Essential memory management from slash commands and agent-guided workflows
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -59,14 +60,7 @@ For advanced settings, create `~/.pi/agent/mem0-config.json`:
|
||||
"userId": "your-username",
|
||||
"autoCapture": true,
|
||||
"defaultScope": "project",
|
||||
"searchThreshold": 0.3,
|
||||
"dream": {
|
||||
"enabled": true,
|
||||
"auto": true,
|
||||
"minHours": 24,
|
||||
"minSessions": 5,
|
||||
"minMemories": 20
|
||||
}
|
||||
"searchThreshold": 0.3
|
||||
}
|
||||
```
|
||||
|
||||
@@ -76,12 +70,7 @@ For advanced settings, create `~/.pi/agent/mem0-config.json`:
|
||||
| `userId` | `string` | `$MEM0_USER_ID` or `"default"` | User identity for memory scoping |
|
||||
| `autoCapture` | `boolean` | `true` | Store facts from conversations automatically |
|
||||
| `defaultScope` | `string` | `"project"` | Default memory scope: `project`, `session`, or `global` |
|
||||
| `searchThreshold` | `number` | `0.3` | Minimum similarity score (0–1) a memory must reach to count as a match for `/mem0-search`, `/mem0-forget`, and `/mem0-pin`, enforced on each result's relevance score. Raise it to be stricter; lower it if relevant results are missed. |
|
||||
| `dream.enabled` | `boolean` | `true` | Enable dream consolidation |
|
||||
| `dream.auto` | `boolean` | `true` | Auto-trigger dreams when thresholds are met |
|
||||
| `dream.minHours` | `number` | `24` | Minimum hours between auto-dreams |
|
||||
| `dream.minSessions` | `number` | `5` | Minimum sessions before first auto-dream |
|
||||
| `dream.minMemories` | `number` | `20` | Minimum memories before auto-dream triggers |
|
||||
| `searchThreshold` | `number` | `0.3` | Minimum similarity score (0–1) a memory must reach to count as a match for `/mem0-search` and `/mem0-forget`, enforced on each result's relevance score. Raise it to be stricter; lower it if relevant results are missed. |
|
||||
|
||||
|
||||
## What's Included
|
||||
@@ -89,11 +78,10 @@ For advanced settings, create `~/.pi/agent/mem0-config.json`:
|
||||
| Component | Description |
|
||||
|-----------|-------------|
|
||||
| `mem0_memory` tool | Agent-callable tool for search, add, get_all, delete, delete_all |
|
||||
| 8 slash commands | Essential memory management from the command line |
|
||||
| 8 skills | Guide the agent on how to use each capability |
|
||||
| 6 slash commands | Essential memory management from the command line |
|
||||
| 6 skills | Guide the agent on how to use each capability |
|
||||
| Auto-capture | Extracts and stores facts on every `agent_end` event |
|
||||
| System prompt | Appends memory policy to every agent turn |
|
||||
| Dream consolidation | Automated memory maintenance with session/time/count gates |
|
||||
|
||||
## Agent Tool
|
||||
|
||||
@@ -119,8 +107,6 @@ Tool output is truncated to 200 lines / 50KB to prevent context overflow.
|
||||
| `/mem0-forget <query>` | Search and delete memories (with confirmation dialog) |
|
||||
| `/mem0-search <query>` | Semantic search across memories |
|
||||
| `/mem0-tour [scope]` | Browse all memories grouped by category |
|
||||
| `/mem0-dream` | Consolidate: merge duplicates, prune stale, resolve contradictions |
|
||||
| `/mem0-pin <query>` | Pin a memory to protect from dream pruning (preserves memory ID) |
|
||||
| `/mem0-scope <scope>` | Change default scope for this session (project, session, global) |
|
||||
| `/mem0-status` | Connection health, identity, and memory count |
|
||||
|
||||
@@ -136,23 +122,12 @@ Memories are scoped using Mem0's `user_id`, `app_id`, and `run_id` parameters:
|
||||
|
||||
The `app_id` is auto-detected from the git repository root (`git rev-parse --show-toplevel`), so all subdirectories within a monorepo share the same memory pool. Falls back to the working directory name for non-git directories. The `run_id` is derived from Pi's session file path.
|
||||
|
||||
## Dream Consolidation
|
||||
|
||||
### Confirmation Dialogs
|
||||
## Confirmation Dialogs
|
||||
|
||||
Destructive and mutating commands use Pi's built-in `ctx.ui.confirm()` dialog before acting:
|
||||
|
||||
- `/mem0-forget` asks "Delete this memory?" before deleting a single match
|
||||
- `/mem0-pin` asks "Pin this memory?" before modifying it
|
||||
- Cancelling either operation is always safe. No changes are made
|
||||
|
||||
### Pin
|
||||
|
||||
`/mem0-pin` uses Mem0's `update()` API to prepend `[PINNED]` to the memory text. This preserves the original memory ID. There is no add+delete cycle that would lose history or change the UUID.
|
||||
|
||||
### Dream Consolidation
|
||||
|
||||
The plugin includes automated memory maintenance ("dream") that merges duplicates, resolves contradictions, and prunes stale entries. When enabled, dreams auto-trigger after enough sessions, time, and memories accumulate (configurable via `dream.*` settings). Run `/mem0-dream` to trigger consolidation manually at any time. Pinned memories (via `/mem0-pin`) are protected from pruning.
|
||||
- Cancelling the operation is always safe. No changes are made.
|
||||
|
||||
## Example Workflow
|
||||
|
||||
@@ -172,7 +147,6 @@ You: What do you know about my preferences?
|
||||
- **Extension not loading**: Check Pi startup output for errors. Run `pi -e ./src/entry.ts` from the plugin directory for verbose output
|
||||
- **Memories not capturing**: Verify `autoCapture` is `true` (default). Check `/mem0-status` for connection health
|
||||
- **Wrong project detected**: The plugin uses the git repository root as `app_id`. If not in a git repo, it falls back to the working directory name. Run `/mem0-status` to see the detected project
|
||||
- **Dream not triggering**: All three gates must pass (time, sessions, memories). Use `/mem0-dream` to force it manually
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="Claude Code Integration" icon="/images/provider-icons/anthropic.svg" href="/integrations/claude-code">
|
||||
@@ -184,3 +158,5 @@ You: What do you know about my preferences?
|
||||
</CardGroup>
|
||||
|
||||
<Snippet file="star-on-github.mdx" />
|
||||
|
||||
Global tool operations require `/mem0-scope global` or `defaultScope: "global"` in plugin configuration. A model-supplied `scope` argument cannot enable cross-project access on its own. Empty or wildcard user, project, and session identities are rejected.
|
||||
|
||||
Reference in New Issue
Block a user