Codex memory between sessions, fixed with hooks
Codex starts every session from AGENTS.md and the current repository state. The work you did together, the decisions behind the code, and the dead ends you ruled out are not in either one.
OpenAI. Sources checked 2026-09-25.
How Codex handles memory today
Codex builds context from AGENTS.md files in a layered order: global guidance first, then project files from the repository root down, then subtree files when it reads inside a directory. AGENTS.override.md can replace the global file. OpenAI documents a size cap, so very large AGENTS.md files get truncated rather than rejected.
Inside a session, Codex manages context as the window fills and compacts older conversation. The compaction output is the model’s summary of what happened, which is not the same thing as what you decided.
What Codex forgets
Codex does not forget the repository. It forgets the conversation that produced it.
- Session history. A new session opens with AGENTS.md and the code, not with yesterday’s reasoning about the code.
- Compaction detail. Community reports on the Codex tracker describe compaction dropping context wholesale, and sessions stalling after a compaction event.
- Large AGENTS.md files. Past the documented cap, instructions are silently dropped, so the rule you added last week may never load.
- Cross-tool context. Decisions made in another assistant are invisible to Codex unless someone writes them into the repository.
The fix with MemoryRouter
The Codex package installs lifecycle hooks that recall relevant memory before the model runs and capture the completed turn after it. Compaction triggers a re-inject, so the session continues with its working context instead of a summary of it.
- 1
Install the Codex package
Scope the install to your user account, then authenticate when prompted. Node 18 or newer, and a current Codex build for full hook support.
Install hooks
npx -y memoryrouter-codex init --scope user - 2
Check health
Run doctor and confirm the hooks are registered for the scope you chose.
Verify
npx -y memoryrouter-codex doctor --scope user - 3
Test a fresh session
Finish a turn where you make a real decision, open a new session in the same project, and ask for the decision. It comes back without you restating it.
For a fully local install where the key never sits in shell history, the Codex guide documents a stdin variant that pipes the key from your clipboard.
Install guide, verification steps, and removal commands on the Codex page. 14-day free trial.
Related
Full Codex guide
Install guide, verification steps, and removal commands on the Codex page. 14-day free trial.
Claude Code memory
Keep project decisions across sessions and compaction with the published hook package.
Cursor memory
Connect the vault as a remote MCP server so new chats open with project decisions.
Codex memory between sessions
Finish a session in Codex, open a new one, and the repository is there while the conversation is not.
Codex memory FAQ
Sources
- OpenAI Codex AGENTS.md guide
- Codex customization concepts
- openai/codex issue 36712: automatic context compaction destroys context
Sources checked 2026-09-25. Tool behavior changes; check the vendor docs before relying on a detail.