Skip to main content
Prerequisite: Install the engram binary first via Homebrew or binary download.
This command does three things:
  1. Registers [mcp_servers.engram] in ~/.codex/config.toml (Windows: %APPDATA%\codex\config.toml)
  2. Writes ~/.codex/engram-instructions.md with the Engram Memory Protocol
  3. Writes ~/.codex/engram-compact-prompt.md for compaction recovery
1

Install engram binary

2

Run setup command

Output:
3

Verify installation

The agent should list mem_save, mem_search, etc.

What Gets Configured

MCP Server Registration

Adds to ~/.codex/config.toml:

Memory Protocol Instructions

Writes to ~/.codex/engram-instructions.md:

Compaction Recovery Prompt

Writes to ~/.codex/engram-compact-prompt.md:
Codex injects this into the compaction output, ensuring the new agent persists the summary.

Manual Setup (Alternative)

If you prefer to configure manually:

Add MCP Server

Edit ~/.codex/config.toml (Windows: %APPDATA%\codex\config.toml):

Add Memory Protocol

Create ~/.codex/engram-instructions.md and copy the Memory Protocol from DOCS.md. Then point to it in config.toml:

Add Compaction Recovery

Create ~/.codex/engram-compact-prompt.md:
Then point to it in config.toml:

Compaction Recovery

Codex uses experimental_compact_prompt_file to inject instructions after compaction. When Codex compacts (summarizes long conversations), it:
  1. Generates a compacted summary
  2. Injects the content of engram-compact-prompt.md
  3. The new agent reads: “FIRST ACTION REQUIRED: Call mem_session_summary…”
  4. The agent saves the summary to engram, preserving work from before compaction
This prevents memory loss across compaction events.

Platform-Specific Notes

Windows

engram setup codex writes to:
  • MCP config: %APPDATA%\codex\config.toml
  • Instructions: %APPDATA%\codex\engram-instructions.md
  • Compaction prompt: %APPDATA%\codex\engram-compact-prompt.md

macOS / Linux

engram setup codex writes to:
  • MCP config: ~/.codex/config.toml
  • Instructions: ~/.codex/engram-instructions.md
  • Compaction prompt: ~/.codex/engram-compact-prompt.md

Memory Protocol Behavior

With the Memory Protocol in engram-instructions.md, the agent:
  • Saves proactively after bugfixes, decisions, discoveries, patterns
  • Searches reactively when you say “remember” or “what did we do”
  • Searches proactively when starting work that might overlap past sessions
  • Closes sessions with mem_session_summary before saying “done”
  • Recovers state after compaction via experimental_compact_prompt_file
No manual prompting needed — the protocol is always active.

Troubleshooting

MCP tools not available

Check MCP server registration:

Agent doesn’t use memory

Check that instruction files exist:

Server not running

Manually start the server:
Codex will connect via stdio, but the HTTP API is useful for debugging.

Next Steps