Adding memory to Codex CLI

the MCP server, the hook you have to approve, and the marketplace

Codex CLI records every session and opens the next one empty. The rollout files are still on disk, along with the work you did the same week in whichever other agent was open.

The same question put to the same agent twice: without memory it has no record of it, with deja it answers with the decision from eight months earlier

same prompt before and after deja — local BM25 recall across past sessions on disk, zero LLM calls

AGENTS.md, and memories if you turn them on

Codex reads AGENTS.md — the repository's, and ~/.codex/AGENTS.md for every project — at the start of a session. It also has an opt-in Memories feature (features.memories, off by default) that turns past threads into notes for later ones, per OpenAI's config reference. With it off, nothing carries between sessions except what you wrote in that file.

What Codex already has

Rollouts live under ${CODEX_HOME:-~/.codex}/sessions/YYYY/MM/DD/rollout-*.jsonl, with the prompts you typed in history.jsonl beside them. Complete, and read by nothing. How Codex's store is read has the format and the quirks it took to parse it.

Adding recall

deja install codex-auto

That writes the deja MCP server into ~/.codex/config.toml and the hooks that carry recall into the session: at session start, on each prompt, before a command or patch, after a failed command, before a compaction and at session end. The server alone is deja install codex.

One catch worth knowing before you go looking for a bug: Codex will not run a hook it has not been shown. Open Codex once and approve them under /hooks, otherwise every file on disk looks right and no memory ever arrives — codex exec included.

This repository is also a Codex plugin marketplace:

codex plugin marketplace add https://github.com/vshulcz/deja-vu
codex plugin add deja-vu@deja-vu

Running both is safe rather than doubled: MCP servers are keyed by name and every manifest we ship calls this one deja, so the two resolve to one server rather than listing every tool twice.

Either path needs the binary, since a plugin ships files and not runtimes:

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

Why this matters more in Codex than most

Codex sessions are short and many — a day's work is spread over a dozen rollout files rather than one long thread. That makes the thing you settled on Tuesday hard to find by scrolling and easy to find by search. Finding a session is the command side of that.

Codex also hands a hook the transcript before a compaction, so the working context is recoverable here: deja keeps the task, the files and each command with whether it passed, and hands them back once in the next turn after the summary. See after compaction.

The part that is not about this harness

The index covers every agent's transcripts on the machine — fifty-two of them today, each in its own format — so a fix found in one tool answers a question asked in another, including sessions from before any of this was installed. That is the reason to index rather than to capture.

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). An injection is capped at 1,536 bytes per prompt and about 4 KB per tool call — what memory costs has the measured comparison.

Repository memory & handoff

Share vetted project decisions and dead ends through git in .deja/memory.jsonl (deja repo candidates, deja repo add <id>). Entries are redacted on write, stored sorted with merge=union so parallel branches merge cleanly, and loaded for any teammate who clones the repository ({"activations":{"auto":{"repo":false}}} in the trust policy keeps them out of hooks). See repo memory.

Switching tools mid-task? Run deja handoff --to <agent> (or use handoff via MCP) to transfer the active session's goal, decisions, touched files, passed checks, and open work into another coding agent.

Getting started · How Codex's store is read · Switching agents

Found this useful? Star deja-vu on GitHub.