Adding memory to opencode

its own sessions are not the same thing as memory

opencode keeps its own sessions in a local database and can reopen one. What it cannot do is start a new session already knowing what you worked out last month — and it certainly cannot read what you did in Claude Code, Codex or Cursor on the same machine. This page is about closing both.

What opencode already has

Sessions live in ~/.local/share/opencode/opencode.db (or under XDG_DATA_HOME), and the picker reopens them. That is history you can revisit, not memory the agent uses: nothing reads yesterday's session when you ask today's question, and the database holds opencode's sessions only.

Two ways to add recall

The plugin

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-deja"]
}

opencode installs the package on start. It needs the deja binary, which does the indexing — the plugin is the seam, not the engine:

brew install deja-vu
# or
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh

The CLI

deja install opencode-auto

Writes the MCP server into opencode.json and a plugin file of its own into ~/.config/opencode/plugins/. Shorter if you already have the binary, and it wires every other agent on the machine in the same pass with deja install --auto.

Having both is fine. The package reads what the installer wrote — the MCP entry, the plugin file — and contributes only what is missing, so nothing is registered or recalled twice.

What arrives, and when

Six tools the model can call — recall past sessions, read one in full, see what a file's history says, ask what fixed an error, ask how a command is really run here, store a decision — and three moments where memory arrives without being asked:

  • Once per session, the project's recent history is pushed onto the system prompt, with a one-time toast so you know it happened.
  • Per prompt, a relevance pass on what you just typed. Silent when nothing matches, which is the common case.
  • Before compaction, the working transcript is indexed, so the session survives the window collapsing — see what compaction drops.

An injection is capped: 1,536 bytes per prompt, about 4 KB for a tool call. What memory costs has the measured numbers against replaying or grepping instead.

The part that is not opencode-specific

The index covers every agent's transcripts on the machine, not opencode's alone — twenty of them today, each in its own format. So a fix you found in Claude Code in March answers a question you ask in opencode in August, and the reverse. That is the whole reason to index rather than to capture: the history is already written, including the months before any of this was installed.

Turning parts off

{"plugin": [["opencode-deja", {"autoRecall": false, "tools": true}]]}

autoRecall: false keeps the tools and drops the unasked injections; tools: false does the reverse. The tools also stand down on their own when the MCP server is already wired, so you are not given the same six answers under two names.

What it does not do

It does not write memories or summarise anything, so there is nothing to hallucinate into your history. It does not reach the network: indexing and search are local, and credentials are stripped as the index is built (privacy). And it does not make opencode's own session list any better — it makes the sessions searchable, which is a different thing.

Getting started · Switching between agents · The plugin source