Codex memory between sessions
Finish a session in Codex, open a new one, and the repository is there while the conversation is not. AGENTS.md holds instructions, not the story of what you built.
Sources checked 2026-09-25.
Why session context does not carry
Codex builds its guidance from AGENTS.md files in a layered order: global, then project files from the root down, then subtree files where it reads. That is instructions, loaded fresh each session.
OpenAI documents a size cap on instruction files as well. Past the cap, content gets truncated without an error, so a large AGENTS.md is quietly delivering only part of what you wrote.
Inside a session, compaction rewrites older conversation. Public reports on the Codex tracker include compaction halting sessions and compaction leaving an unusually large amount of history in the active window, which pushes the same problem to the next run.
Free fixes you can do today
These work today, with no new tools.
- 1
Write the handoff before you close
A five-line note at the end of a session, committed as a file, is the cheapest memory there is. "Where we stopped, what is next, what we ruled out."
- 2
Keep AGENTS.md lean
Bloat risks truncation and costs tokens every run. Move history out and keep instructions in.
- 3
Scope AGENTS.md to the tree
Subtree files load when Codex reads inside that directory, so local rules near the code they govern are more reliably applied than one giant root file.
- 4
Resume instead of restarting
Where a session can be resumed, resume it. Starting fresh throws away everything the run learned.
The durable fix
The published Codex package installs lifecycle hooks that recall relevant memory before the model runs and capture the completed turn after it, with a re-inject after compaction.
It works in the CLI and desktop surfaces, scopes to your user account, and writes to the same vault your other tools read.
- 1
Install the hooks
Install for your account
npx -y memoryrouter-codex init --scope user - 2
Verify
Health check
npx -y memoryrouter-codex doctor --scope user - 3
Test it
Make a real decision in one session, open another, and ask what was decided. It should answer from memory rather than from the repository.
Full setup guide: Codex setup guide
Secure install, verification, and removal on the Codex page. 14-day free trial.
Related
FAQ
Sources
- OpenAI Codex AGENTS.md guide
- openai/codex issue 36712: automatic context compaction destroys context
- openai/codex issue 7138: AGENTS.md truncated silently
Sources checked 2026-09-25. Tool behavior changes; check the vendor docs before relying on a detail.