To add persistent memory to Codex, keep memory outside Codex and expose it through Answer Engine’s MCP server or an equivalent tool surface. Use a scoped library key, point the server at https://engine.answeragent.ai, and test recall from a fresh Codex task with a known source-backed project fact.
Last updated: June 20, 2026.
What should Codex remember?
Codex should remember project decisions, repository conventions, prior debugging results, and source-backed facts that future coding tasks need. It should not store secrets, every terminal line, or unsupported guesses.
The OpenAI Codex repository describes Codex CLI as a local coding agent that runs on your computer. OpenAI’s Agents SDK also documents MCP integration patterns for hosted, HTTP, and stdio servers (OpenAI Agents SDK MCP). Use those concepts to keep the memory layer external and inspectable.
What config shape should you use?
Use the standard Answer Engine MCP config shape where your Codex environment supports MCP-style server configuration:
{
"mcpServers": {
"answer-engine": {
"command": "npx",
"args": ["answer-engine-mcp"],
"env": {
"ANSWER_ENGINE_API_KEY": "ae_live_your_key_here",
"ANSWER_ENGINE_API_URL": "https://engine.answeragent.ai",
"ANSWER_ENGINE_LIBRARY": "personal-memory"
}
}
}
}
The MCP introduction explains why this shape is portable across clients. The MCP architecture overview explains the host, client, and server roles.
How do you seed memory for Codex?
Start with source-backed facts:
ae auth login
ae sync once --source claude-code --library personal-memory
ae search "what test command should this repo use" --library personal-memory
The launch CLI surface includes ae sync for importing local Claude Code transcript turns. Even if Codex was not the original source, Codex can benefit from the same memory library once it is exposed through MCP or API.
How do you verify recall?
Open a fresh Codex task and ask:
Use Answer Engine memory to find the last testing rule for this repository. Cite the memory source.
The expected behavior is not a benchmark result. It is operational proof that Codex called the external memory layer and returned source-backed context. If the answer guesses, strengthen the instruction. If no memory returns, inspect the library scope and write path.
What should you avoid?
Do not paste a real API key into a committed config. Do not use a stale host. Do not rely on Codex’s current prompt as the only record of a project decision. Do not copy sensitive transcripts into a shared library without scope review.
How should Codex write new memories?
Ask Codex to write memories only when the fact has future value. Good write candidates include repository commands, architectural decisions, recurring user preferences, issue scope corrections, and investigation results that would save time in a later task. Poor write candidates include temporary shell output, speculative explanations, partial stack traces, and secrets.
Use an explicit phrasing when the distinction matters:
Save this as Answer Engine memory for the current project: marketing content belongs in apps/marketing, not packages/web-ui. Source: AGENTS.md and issue #680.
That instruction gives the memory server a durable fact, scope, and source label. It also prevents Codex from deciding that every useful sentence in the current task should become long-term memory.
How should teams share Codex memory?
Use separate libraries for personal memory, project memory, and team-shared memory. A personal library can hold preferences such as preferred explanation style. A project library should hold repo-specific facts. A team library should hold conventions that multiple engineers can reuse. Keeping those scopes separate makes deletion, export, and permission review practical.
When a memory becomes stale, write a replacement that supersedes the old fact rather than leaving both as current. Codex should be able to retrieve the current rule and inspect the older source when the history matters.
For team use, make the library name part of the task contract. A prompt that says “use the answer-engine-marketing library for this repo” is easier to audit than a vague request to use memory. It also helps prevent a personal preference from being mistaken for a project rule.
For a broader design, read Give your coding agent memory and Portable Agent Memory.