Does OpenAI Codex have a memory?
Yes, but not the way many expect. Codex has no recollection that carries over by itself across all sessions. There are two mechanisms: AGENTS.md, instruction files that Codex reads before it does any work, and Codex memories, local memories built from earlier chats. Both are files on your machine. Anyone searching for "Codex memory" usually ends up at one of the two.
AGENTS.md: the main Codex memory
When it starts, Codex builds a chain of AGENTS.md files and reads it before it works. So every task begins with the same ground rules, whichever repository you open. The order:
- Global: In the Codex home (
~/.codexby default), Codex readsAGENTS.override.mdif it exists, otherwiseAGENTS.md. Only the first non-empty file counts. - Project: From the project root, usually the Git root, Codex walks down to the current directory. In each folder it checks
AGENTS.override.md, thenAGENTS.md, then any fallback names you configured. At most one file per folder is included. - Merge order: The files are concatenated from the root down. What sits closer to your working directory comes later in the prompt and overrides earlier guidance.
- Limit: At
project_doc_max_bytes, 32 KiB by default, Codex stops adding files.
Typical contents are commands for test and build, conventions, and rules like "run the linter before opening a pull request". Claude Code can also use an existing AGENTS.md as its project instructions, more in the guide to Claude Code memory.
Codex memories: local recollections
In addition, Codex can generate local memories from earlier chats. This is off by default. You turn it on in the settings under Personalization ("Enable Codex memories") or with memories = true in the [features] section of config.toml. Then:
- Memories are created in the background, not right when a chat ends. Codex skips active and very short sessions and redacts secrets from the generated fields.
- They are stored locally in the Codex home and apply to that machine. ChatGPT memory on the web is a separate store.
- OpenAI itself recommends keeping required guidance in AGENTS.md or project documentation. Memories are a recall aid, not the only source for rules that must always apply.
Where memory files hit their limits
- A hard ceiling: After 32 KiB (default), further knowledge falls out of the chain.
- All or nothing: The chain is built at startup, not to fit the task. Every line takes up context in every session.
- Manual upkeep: You maintain AGENTS.md yourself. Outdated rules stay until someone deletes them.
- Tied to one machine: Codex memories are stored locally. What Codex learned on the laptop, the session on the server doesn't know.
- Each tool on its own: What Claude Code learned, Codex doesn't know, and vice versa.
Codex memory via MCP
Codex supports the Model Context Protocol (MCP). You register servers in config.toml, globally in ~/.codex/config.toml or per project in .codex/config.toml. A server reached over HTTP gets a section [mcp_servers.<name>] with its address (url). Local servers are started through command, and codex mcp add exists for that too. That gives Codex tools to store and retrieve memories.
One catch remains: many simple MCP memory servers wait for the agent to remember to query them. In the heat of work, that often doesn't happen.
Hebby: one shared memory for Codex and Claude Code
Hebby is a long-term memory that connects to Codex through hooks and MCP. It remembers on its own, without Codex having to ask, and solves the limits of memory files:
- Targeted: only the memories that fit the current request, instead of a fixed chain.
- Connected and current: Hebby knows which memory belongs to which system. What's outdated steps back, what proves itself gets stronger (Hebbian learning).
- Shared: Codex gets the same memories as Claude Code. What one agent learns, all of them know right away, Hermes and any other MCP-capable agent included.
AGENTS.md with Hebby: our recommendation
Long instruction files cost tokens in every session and measurably make the agent worse (why). So keep AGENTS.md short: only what must hold without exception in every session, usually a sentence or two. With Hebby, decisions, pitfalls and project knowledge arrive in the session on their own when they're needed.

Hebby Memories: the second brain for Claude Code, Codex & co. Learns as you work, thinks ahead, never forgets what matters. Get Early Access →
Frequently asked questions
Does OpenAI Codex have a memory?
Yes, in two forms. Codex reads AGENTS.md files with your instructions before it works. In addition there are local Codex memories built from earlier chats. They are off by default and apply per machine.
Where does Codex look for AGENTS.md?
Globally in the Codex home, ~/.codex by default, and per project in the repository: from the project root down to the current directory, at most one file per folder. Files closer to the working directory override earlier guidance.
How do I connect a memory service to Codex?
Through MCP. Codex reads MCP servers from config.toml, globally in ~/.codex or per project in .codex. For HTTP servers you enter the address (url) under mcp_servers. Hebby sets up Codex with hooks and MCP in the guided setup after sign-up.
Can Codex and Claude Code share the same memory?
Not with memory files and local memories, because each tool keeps its own. Through a shared MCP memory service like Hebby they can: what Claude Code learns, Codex knows too.
