Adding memory to pi
no hooks, an extension API — and one file is the whole install
pi writes a JSONL log per session under ~/.pi/agent/sessions and can resume one; omp (Oh My Pi) is the same lineage and keeps the same shape under ~/.omp, with a page of its own. A new session in either reads nothing from the others, and nothing from the Claude Code or Codex session on the same machine where the problem was already solved. This page is about adding that.
What they already have
Neither has hooks. Both have an extension API, and extensions under the agent's extensions/ directory are auto-discovered — so installing is one file and no settings edit, and removing it is deleting the file.
Adding recall
From npm, without the deja CLI on hand:
pi install npm:@vshulcz/pi-deja
The package brings the binary along: a digest at session start, recall on every prompt, /deja to search by hand. Or, with the CLI installed:
deja install pi-auto deja install omp-auto
Each writes the MCP server, so the model can call the deja tool itself — search past sessions, read one in full, see a file's history, ask what fixed an error, ask how a command is really run here, store a decision — and one extension:
- pi —
~/.pi/agent/extensions/deja.ts, answeringbefore_agent_start. It fires after you submit a prompt, carries the prompt text, and can return a message that is stored in the session and sent to the model — both halves of what Claude Code splits across SessionStart and UserPromptSubmit, in one event. pi also has a real channel to you,ctx.ui.notify, so the recall line and the "index still building" note go there rather than into the prompt. - omp — a module under the active agent's
extensions/. The per-prompt block goes in through thecontextevent, whose handler returns{ messages }to replace what goes to the provider; the once-per-session digest goes in throughbefore_agent_start, which stores what it returns as a message of its own.inputnever fires in print mode. - prime-agent (PrimeIntellect) — the same lineage again, wired by
deja install prime-auto:~/.prime/agent/extensions/deja.tsfor the digest and the per-prompt recall throughbefore_agent_start, the MCP server undermcpServersin~/.prime/agent/settings.json, and/dejain the prompt box. It has no fix pair:tool_callandtool_resultare in its extension docs and did not fire on 0.9.1 in any mode tested here, so that half is left out rather than wired to an event that stays quiet.
pi and omp also answer tool_result, which is the only handler whose return value the model reads. When a command fails, the repair goes in beside the error, in the same turn — what followed that same error on this machine before. When a file is read, the file's own history goes in the same way: what the sessions that worked on it decided. The read is the step before the edit, and neither agent has a seam that runs earlier — tool_call can block a tool or rewrite its arguments, nothing more. On pi that means a tool result marked as an error; omp's bash tool leaves the error flag false and reports the exit code in details.exitCode instead, so the extension reads that. And both answer session_compact: compaction throws away the blocks the session was shown, so the list that keeps them from repeating is cleared with it.
What arrives
On each prompt, the history it is actually about, when there is any; silence is the common case. An injection is capped at about 1.5 KB per prompt and 4 KB per tool call — what memory costs has the measured comparison.
The part that is not about pi
The index covers every agent's transcripts on the machine — forty-two of them, each in its own format — so a fix found in Claude Code answers a question asked in pi, including sessions from before any of this was installed. A transcript a client later deletes stays searchable; only deja forget drops one on purpose. Nothing here writes memories, so there is nothing to hallucinate into your history; indexing and search are local, and credentials are stripped as the index is built (privacy).
Getting started · Switching between agents · The pi session format · omp
Found this useful? Star deja-vu on GitHub.