# Codex Memory --- --- > How OpenAI Codex carries knowledge between sessions (AGENTS.md, Codex memories) and how a team gives every Codex session the same memory with Glen. --- --- # What OpenAI Codex remembers, and how a team can share it URL: https://codexmemory.com/ Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > OpenAI Codex carries knowledge between sessions in two ways: AGENTS.md files, which it reads before it starts work, and Codex memories, an opt-in feature stored under $CODEX_HOME/memories/ on one machine. Neither one reaches a teammate's Codex. Glen adds that shared layer: its Codex hooks record each turn into your organization's memory and hand the relevant past work back as context before the model reads your prompt. ## What Codex remembers without help Every Codex run begins with no recollection of the last one. Whatever it knows about your repo before the first prompt comes from instruction files on disk, plus, if you turned it on, a local memory store. OpenAI's guidance is to keep the instructions a team relies on in AGENTS.md rather than in memories, since memories never leave the machine; the [AGENTS.md guide](https://codexmemory.com/agents-md) covers what each file should hold. *OpenAI Codex's built-in memory, November 2026* | Layer | Location | Default | Who sees it | | --- | --- | --- | --- | | AGENTS.md | `~/.codex/AGENTS.md` (or `AGENTS.override.md`), then one file per directory from the repo root down | Read every session, up to `project_doc_max_bytes` (32 KiB) | Anyone who clones the repo, for the committed files | | Codex memories | `$CODEX_HOME/memories/` | Off until you set `memories = true` | You, on the machine that wrote it | ## The edge of built-in memory - A teammate's Codex spends an afternoon finding out why the migration has to run before the backfill. Unless someone edits AGENTS.md, your session tomorrow starts that search again. - Memories written on your work laptop are absent on your home machine and in any fresh environment. - Half the team runs [Claude Code](https://claudecodememory.com) or [Cursor](https://cursormemory.com). What those agents learn never shows up in Codex, and Codex's lessons never reach them. - AGENTS.md records conclusions. The reasoning, the failed attempts and the thread that settled it stay in transcripts nobody reads twice. ## How Glen plugs into Codex [Glen](https://tryglen.com) is hosted memory for your organization plus a set of Codex hooks. `glen install` writes four entries into `~/.codex/hooks.json`, and each one calls the `glen` CLI. Codex only runs hooks you have trusted, so approve them when Codex asks, or open `/hooks` and approve them there. Full steps are on the [setup page](https://codexmemory.com/setup). - **UserPromptSubmit** runs `glen ingest`, which sends your prompt, the previous assistant turn, the repo and the branch. The matching memories come back as `additionalContext`, so Codex places them in front of the model before it reads what you typed. - When the turn ends, **Stop** runs `glen ingest` again to record it. For Codex that means your prompt and the final reply. - **PostToolUse** on Bash calls `glen pr-link`, tying each `git commit` to the session behind it. - On launch, **SessionStart** calls `glen session-start`. > **Put your team's memory in front of Codex** One command installs the CLI, signs you in and registers the hooks. Free for up to 3 people and 15,000 memories, no credit card. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Measured on Codex itself Glen's benchmark ran on Codex 5.5. It took the last 100 merged PRs of a workspace with two months of Glen history and had Codex re-implement each one from a one-shot prompt, five runs per PR with Glen and five without, with memory rolled back to the moment before each PR. The Glen runs used 29% fewer tokens, finished 21% faster and matched or beat the quality of the runs without it. Recall arrived through the same per-prompt injection Codex gets today. [Method and results](https://tryglen.com/blog/replaying-100-prs). ## Which layer for which job *Where Codex knowledge should live* | You want Codex to | Put it in | | --- | --- | | Run `pnpm test` before every commit, no exceptions | AGENTS.md | | Keep your personal shorthand on your own laptop | Codex memories | | Know a teammate's session already ruled out the cache-first approach | Glen | | Explain the conversation behind lines 40 to 80 of a file | `glen code-search` | | Start a new hire with what the team settled last quarter | Glen | > **When to skip Glen:** A solo developer on one machine may never miss it: AGENTS.md plus Codex memories covers that case. Glen is also hosted only, with no self-hosted build, and recorded sessions are searchable by your organization. The [team memory comparison](https://codexmemory.com/team-memory) lays out the alternatives. ## Frequently asked questions ### Does OpenAI Codex have memory? Yes, two kinds. AGENTS.md files are read at the start of every session, and Codex memories, off by default, stores notes under $CODEX_HOME/memories/ on one machine. ### How do I turn on Codex memories? Set memories = true in your Codex configuration. The notes stay on that machine, so OpenAI suggests keeping anything the team depends on in AGENTS.md. ### Can Codex remember previous sessions? Only what made it into AGENTS.md or its local memories. With Glen installed, every turn is recorded, so a later Codex session, yours or a colleague's, gets the relevant part of earlier work with its prompt. ### Does Glen work with Codex and Claude Code in the same team? Yes. Both agents record into, and recall from, the same organization memory, so a fix found in one shows up in the other. ### What does Glen cost for Codex users? The same as for any agent: Free covers 15,000 memories and up to 3 people, Personal raises that to 250,000 memories with integrations, and Team removes the limits. --- # Writing AGENTS.md for Codex: what loads, what fits, what to leave out URL: https://codexmemory.com/agents-md Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Codex reads AGENTS.md before it starts work: the global file in ~/.codex (or AGENTS.override.md in its place), then one file per directory from the repo root down, until the total reaches project_doc_max_bytes, 32 KiB by default. Put the rules every task must follow there. Leave personal habits to Codex memories and the history of past sessions to a searchable team memory such as Glen. ## How Codex assembles its instructions 1. Your global file, `~/.codex/AGENTS.md`. An `AGENTS.override.md` there is used in its place. 2. The `AGENTS.md` at the repository root. 3. An `AGENTS.md` in each directory below that, down to the one you are working in. Codex stops adding files once the combined text reaches `project_doc_max_bytes`, which is 32 KiB unless you change it. A deep monorepo with a long root file can hit that ceiling before the most specific directory gets read. Raising the setting is possible, but every byte you add rides along on every request. ## What earns a place in AGENTS.md - The commands Codex should run: install, test, lint, typecheck, and the order that matters. - Conventions you'd otherwise repeat in review, such as where new modules go or how errors are returned. - Lines it must not cross. Generated files stay untouched; secrets never get logged. - Short pointers into deeper docs, so the detail loads only for tasks that need it. > **A quick test:** Would you want this applied on a task that has nothing to do with it? If yes, it is a rule and belongs in AGENTS.md. If it only matters when someone touches one subsystem, put it in that subsystem's AGENTS.md or out of the file entirely. ## AGENTS.md, Codex memories or Glen *Three places Codex knowledge can live* | | AGENTS.md | Codex memories | Glen | | --- | --- | --- | --- | | Written by | People, by hand | Codex, once enabled | Glen's hooks, every turn | | Stored in | The repo and `~/.codex` | `$CODEX_HOME/memories/` | Your organization's hosted memory | | Enabled | Always | Off by default (`memories = true`) | After `glen install` | | Reaches | Everyone with the repo | One machine | Teammates, filtered by what each may see | | Good for | Rules that must always hold | Your own habits | Why past work went the way it did | OpenAI recommends keeping required team guidance in AGENTS.md, and that advice holds with Glen installed. Recall from Glen depends on a prompt matching past work. A rule in AGENTS.md applies whether or not anything matches. ## One file, several agents AGENTS.md is not Codex-only. Cursor reads it alongside its rules, and [Grok Build reads it too](https://grokmemory.dev/grok-build). A team that mixes agents can commit one AGENTS.md and get the same rules everywhere, instead of keeping three files in sync. ## Knowledge that doesn't fit in a file The 32 KiB cap is a good discipline, and it also means most of what a team learns never makes it in. Which fix was tried first, why a timeout is 45 seconds, what a reviewer objected to: all of that lives in session transcripts. [Glen](https://tryglen.com/docs/codex) records those for the organization and returns the relevant part with the prompt that needs it, so AGENTS.md can stay lean. When something recalled from Glen proves to be a standing rule, promote it into AGENTS.md. > **Keep AGENTS.md short** Let Glen hold the history every Codex session can recall. Free for 15,000 memories. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Frequently asked questions ### Where does Codex look for AGENTS.md? In ~/.codex for your global file (AGENTS.override.md takes its place if present), then in the repository root and each directory below it down to where you are working. ### What is project_doc_max_bytes in Codex? The limit on how much AGENTS.md text Codex loads, 32 KiB by default. Files past that budget are not read. ### Should I use AGENTS.md or Codex memories? AGENTS.md for anything the team needs, because it is shared through git. Codex memories stays on one machine, which suits personal preferences. ### Can other coding agents read AGENTS.md? Yes. Cursor and Grok Build both read AGENTS.md, so a single committed file can carry the same rules to several agents. --- # Choosing a shared memory for a team on Codex URL: https://codexmemory.com/team-memory Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > For a team running Codex, the test is whether one engineer's session can use what another engineer's session already worked out. A committed AGENTS.md shares rules but only what someone writes; Codex memories and local MCP memory servers stay on one machine. Glen records every Codex turn from every teammate into one organization memory and returns the relevant part with each prompt. ## Four questions to ask of any option - **Does it capture on its own?** Hooks record every turn. A save tool records only what the model decides to keep, and models skip it. - **When does recall happen?** Codex's UserPromptSubmit hook can return `additionalContext`, so a tool built on it puts memory in place before the model starts. - **Who else can read it?** A colleague's Codex, a Claude Code user, someone in Cursor. - **What happens after a reversal?** If the team abandons a design, the old answer should stop resurfacing. *Memory options for teams using Codex, November 2026* | Option | How it captures | How it recalls | Who shares it | | --- | --- | --- | --- | | Glen | Hooks, every turn | Added to each prompt | Your organization, filtered per user | | Committed AGENTS.md | Someone edits it | Read each session | Anyone with the repo | | Codex memories | Codex's own notes, opt-in | Loaded from `$CODEX_HOME/memories/` | One machine | | Reference MCP memory server | Whatever the model chooses to write | When the model queries it | One machine (local JSONL file) | | Mem0 or Supermemory | When the agent or your code calls the API | When the agent searches | Whoever holds the API key | ## Where Glen fits Glen assumes several people run agents in one codebase. Capture comes from Codex's hooks, so the record reflects what sessions did, not what a model remembered to save. Recall rides on the prompt itself. The store also sits above any single agent: a decision made in a teammate's [Claude Code session](https://claudecodememory.com) reaches your Codex the next time your prompt touches that code. Sharing memory raises two practical questions, and Glen answers both at recall time. Each memory is checked against what the asking user may see, so connecting GitHub or public Slack channels never exposes something they couldn't open already. When a newer decision contradicts an older one, Glen aims to surface the one that stuck. If a stale memory still comes back, `glen forget` takes it out of recall, and restore puts it back. ## What the other options do well AGENTS.md is still the right home for rules, and Glen doesn't change that. Codex memories is a sensible default for one person's preferences. Mem0 (Apache 2.0) and Supermemory (MIT) are memory APIs, a better fit when you are building memory into your own product rather than sharing it across a team. For background on the MCP route, [Glen's MCP server](https://memorymcp.dev) works with any MCP client. > **Test it with two colleagues** Free covers up to 3 people and 15,000 memories. Run glen import on day one to bring in your last 30 days of sessions. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Reasons to pick something else - Your company requires self-hosting. Glen runs as a hosted service only. - Colleagues shouldn't be able to search each other's sessions. Recorded sessions are visible across the organization, subject to per-memory access checks. - It's just you, on one laptop, with one agent. - You want a knowledge graph or a vector database to query directly. Glen is neither. ## Frequently asked questions ### Can Codex memories be shared with my team? No. Codex memories lives under $CODEX_HOME/memories/ on one machine. Share rules through a committed AGENTS.md, and past work through a team memory such as Glen. ### Do Codex memories sync across machines? No. Each machine keeps its own memories directory, so a new laptop or environment starts empty. ### What does Glen record from Codex? Each turn's prompt and final reply, with the repo and branch, plus a link between each git commit and the session that made it. ### Does everyone on the team need to use Codex? No. Claude Code, Cursor, Pi and Grok Build have Glen plugins too, and all of them record into the same organization memory. --- # Setting up shared memory in OpenAI Codex URL: https://codexmemory.com/setup Last updated: 2026-11-07 Published by Glen (https://tryglen.com), shared memory for coding agents. > Run npx @tryglen/cli@latest install, choose Codex and sign in. The installer registers Glen's four hooks in ~/.codex/hooks.json; Codex only runs hooks you trust, so approve them when prompted or through /hooks. After that, each prompt goes to Glen and matching team memory comes back as context before the model reads it. 1. **Run the installer** It needs Node.js. The installer looks for coding agents on your machine, asks which should get Glen, and installs the `glen` CLI. ```bash npx @tryglen/cli@latest install ``` 2. **Sign in** A browser window opens. Create a free account, or join the organization your team already uses. 3. **Trust the hooks** The installer writes Glen's entries into `~/.codex/hooks.json`. Codex won't run a hook until you trust it, so accept the prompt when Codex shows it, or run `/hooks` inside Codex and approve the four Glen entries. ```bash /hooks ``` 4. **Bring in your history** Optional, and worth doing on day one. Importing your last 30 days of local sessions gives recall something to find straight away. ```bash glen import ``` 5. **Work, then ask** Start a Codex session and prompt as usual; matching memory arrives with each prompt. To ask a question outright, run a search. The answer cites a source for every claim and takes about 10 seconds. ```bash glen search "why does the migration run before the backfill" ``` ## What the installer puts in hooks.json *Glen's Codex hooks* | Codex event | Command | Effect | | --- | --- | --- | | SessionStart | `glen session-start` | Runs once when a session opens | | UserPromptSubmit | `glen ingest` | Sends the prompt, prior reply, repo and branch; returns matching memory as `additionalContext` | | Stop | `glen ingest` | Records the prompt and the final reply | | PostToolUse (Bash) | `glen pr-link` | Links each `git commit` to the session | If memory never shows up, the hooks are the first thing to check. An untrusted hook is skipped without running, and `/hooks` shows which ones Codex has approved. ## Pausing or limiting recording *Glen's recording modes* | Command | Recall | Recording to team memory | | --- | --- | --- | | `glen incognito` | Keeps working | Stops | | `glen silent` | Stops surfacing anything | Keeps going | | `glen off` | Stops | Stops | Glen does not train AI models on customer content. The details are in [Glen's Codex docs](https://tryglen.com/docs/codex) and the [privacy policy](https://tryglen.com/privacy). ## Searching from ChatGPT too The [ChatGPT connector](https://tryglen.com/docs/chatgpt) searches the same memory your Codex sessions write to, which helps when you're planning outside the terminal. It reads; it does not record your chats. Other tools can connect through [Glen's remote MCP server](https://memorymcp.dev). > **Install Glen for Codex** One command, free for up to 3 people and 15,000 memories. Install: `npx @tryglen/cli@latest install`. Start free at https://tryglen.com ## Frequently asked questions ### Why aren't my Codex hooks running? Codex skips hooks it hasn't been told to trust. Open /hooks in Codex and approve Glen's entries, then start a new session. ### Where are Codex hooks configured? In ~/.codex/hooks.json. Glen's installer adds its four entries there for you. ### Do I need Codex memories turned on for Glen? No. Glen works through hooks and its own hosted memory, so the memories = true setting makes no difference to it. ### Does Glen slow Codex down? Each hook adds a network round trip. In Glen's replay of 100 merged PRs on Codex 5.5, runs with Glen still finished 21% faster and used 29% fewer tokens.