@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.
Current package version:
0.3.0.Overview
The plugin provides:- Auto-capture: Extracts durable facts from both user and assistant messages automatically
- Semantic recall: Automatically searches project memories before each agent turn;
mem0_memorysupports additional explicit searches - Monorepo-aware scoping: Uses git root for project detection, consistent across subdirectories
- Confirmation dialogs: Destructive commands ask before acting via Pi’s built-in UI
- 6 skills + 6 commands: Essential memory management from slash commands and agent-guided workflows
Prerequisites
-
A Mem0 Platform account and API key:
- Sign up at app.mem0.ai
- Get your API key (starts with
m0-)
- Pi Agent installed (pi.dev)
- Your API key added to your shell profile:
Installation
MEM0_API_KEY from your environment is picked up automatically.
Start a new Pi session and run
/mem0-status to verify the connection. You should see your user ID, detected project, and memory count.Optional Configuration
For advanced settings, create~/.pi/agent/mem0-config.json:
What’s Included
Agent Tool
Themem0_memory tool is registered with Pi and callable by the agent during conversations:
All actions accept an optional
scope parameter: project (default), session, or global.
Tool output is truncated to 200 lines / 50KB to prevent context overflow.
Commands
Memory Scopes
Memories are scoped using Mem0’suser_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. Automatic recall and capture use project scope, regardless of defaultScope; automatic writes do not include run_id. Use session-scoped tools or commands to save and recall session-specific memories. Captured user and assistant message text is redacted without a per-message character cutoff.
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.
Confirmation Dialogs
Destructive and mutating commands use Pi’s built-inctx.ui.confirm() dialog before acting:
/mem0-forgetasks “Delete this memory?” before deleting a single match- Cancelling the operation is always safe. No changes are made.
Example Workflow
Troubleshooting
- “No API key found”: Verify
MEM0_API_KEYis set:echo $MEM0_API_KEY. If empty, add it to your shell profile (see Prerequisites) - Extension not loading: Check Pi startup output for errors. For a source checkout, run
pnpm build, thenpi -e ./dist/entry.jsfrom the plugin directory - Memories not capturing: Verify
autoCaptureistrue(default). Check/mem0-statusfor 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-statusto see the detected project
Claude Code Integration
Add Mem0 memory to Claude Code
OpenClaw Integration
Add Mem0 memory to OpenClaw agents
Using Mem0? Star us on GitHub to help more developers discover memory for AI apps.