Add persistent memory to Pi Agent with the Mem0 plugin semantic search, auto-capture, and dream consolidation.
Add persistent memory to Pi Agent 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.
That’s it. The extension loads automatically on every Pi session. No config files needed — 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.
The mem0_memory tool is registered with Pi and callable by the agent during conversations:
Action
Required Params
Description
search
query
Semantic search across memories
add
content
Store a new memory
get_all
—
List all memories in scope
delete
memory_id
Delete a specific memory
delete_all
—
Delete all memories in scope
All actions accept an optional scope parameter: project (default), session, or global.Tool output is truncated to 200 lines / 50KB to prevent context overflow.
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.
/mem0-pin uses Mem0’s update() API to prepend [PINNED] to the memory text. This preserves the original memory ID — no add+delete cycle that would lose history or change the UUID.
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.
# Session 1You: I prefer dark mode and concise answers.# Mem0 auto-captures preferences# Session 2 (days later)You: What do you know about my preferences?# Pi retrieves stored memories — no re-explaining needed
“No API key found” — Verify MEM0_API_KEY is set: echo $MEM0_API_KEY. If empty, add it to your shell profile (see Prerequisites)
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