codex-agent-mem integrates with Codex using two runtime surfaces:
notify for turn captureIt also exposes a local FastAPI inspector for humans:
/ui for project, session, turn, and observation browsingAnd it can reinject compressed continuity when enabled:
AGENTS.md sync for generated working memory when the pack is smaller than the source contextAnd it now exposes explicit audit and persistence utilities:
And on top of that, it now supports governed memory selection:
For low-impact Desktop and long-running hosts, v1.0 also adds:
Scope note: this document covers Codex CLI, codex exec, and Codex Desktop. It does not document or claim ChatGPT web/app connector support. ChatGPT connector validation is a separate future integration surface.
agent-turn-completecodex_agent_mem.codex_notify normalizes the payloadsession_summary, decision, and operational-state observationsAGENTS.md is updated in the working directorymem_searchmem_getmem_recentmem_project_briefmem_open_workmem_completion_checkmem_recent_changesmem_scope_guardmem_context_packmem_provenancemem_healthmem_health_runtimemem_snapshot_listmem_snapshot_createmem_snapshot_restoremem_policy_listmem_policy_validatemem_policy_addmem_policy_removemem_inheritance_listmem_inheritance_addmem_inheritance_removemem_repair_proposemem_repair_applymem_context_pack also supports budget=auto, so the runtime can select the smallest fitting reinjection profile instead of always forcing one fixed budget.
In v1.0, mem_context_pack also returns a stable pack_hash and accepts known_pack_hash. If the generated continuity pack did not change, the server can return a compact not_modified=true response instead of resending the full pack.
codex-agent-mem-bootstrap-codex --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
codex-agent-mem-bootstrap-codex --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
The generated config uses:
notify[mcp_servers."codex-agent-mem"]--idle-timeout-seconds for defensive stdio cleanup--profile for profile-aware tool surfaces--response-mode for compact, balanced, or verbose MCP text responsesapproval_mode = "approve" for the read-only retrieval toolscodex_agent_memFor a lower-impact Codex Desktop profile, generate:
codex-agent-mem-bootstrap-codex --mcp-profile minimal --mcp-read-only --idle-timeout-seconds 1800
codex-agent-mem-bootstrap-codex --mcp-profile minimal --mcp-read-only --idle-timeout-seconds 1800
That exposes only:
mem_context_packmem_open_workmem_completion_checkmem_health_runtimeand disables mutating MCP tools.
For CLI and short codex exec runs, a shorter timeout such as --idle-timeout-seconds 300 is usually better because it cleans up unused stdio processes faster. For long-lived Codex Desktop threads, a longer timeout such as 1800 reduces the chance that the host keeps a closed MCP transport after the server exits for inactivity.
--sync-project-doc is now opt-in. Add it to notify only if you want automatic AGENTS.md reinjection in the working directory.
The generated snippet also marks the read-only retrieval tools as:
approval_mode = "approve"
That matters for non-interactive Codex runs such as codex exec, where MCP tool prompts can otherwise be cancelled before returning data.
Use single-quoted TOML strings so backslashes stay literal.
See:
On macOS and Linux, prefer:
$HOME/.codex_agent_mem/codex_agent_mem.db for the local database pathcodex-agent-mem-bootstrap-codex --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
When editing ~/.codex/config.toml manually, use the installed command paths from your environment instead of Windows-style Scripts\\ paths.
The default and simplest path is direct DB ingestion through notify.
An optional HTTP wrapper also exists:
That path is useful only if you explicitly want notify -> HTTP -> local API.
The current transport is stdio. That means one MCP process per host connection is expected; this integration does not claim a singleton daemon. codex-agent-mem now adds an idle timeout, signal-aware shutdown, runtime diagnostics, and explicit SQLite cleanup so unused or orphaned stdio instances exit more defensively.
Use different timeout expectations by host:
--idle-timeout-seconds 1800 or higher for long threads where the host may keep a tool client alive.codex exec --ephemeral: prefer --idle-timeout-seconds 300 for faster cleanup.Current evidence points to a host-side lifecycle problem in long-lived Codex Desktop sessions rather than a single MCP being the sole root cause.
Observed pattern:
codex exec --ephemeral with the same global MCP config finishes cleanlyWhat codex-agent-mem does about it:
--sync-project-doc opt-in instead of defaultmem_health_runtime--profile minimal --read-only for lower-impact Desktop setupsinitialize, tools/list, and mem_health_runtimeknown_pack_hash matchesStdio remains the default and most compatible transport.
If a host repeatedly opens MCP stdio connections, you can run a local daemon:
codex-agent-mem-daemon --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db" --profile minimal --read-only
Then point the stdio bridge at it:
codex-agent-mem-mcp --daemon-url http://127.0.0.1:37773 --db-path "$HOME/.codex_agent_mem/codex_agent_mem.db"
On Windows PowerShell:
codex-agent-mem-daemon --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db --profile minimal --read-only
codex-agent-mem-mcp --daemon-url http://127.0.0.1:37773 --db-path C:\Users\YOU\.codex_agent_mem\codex_agent_mem.db
That does not claim to fix the host bug. It reduces the blast radius and makes the MCP easier to audit.
For the full diagnostic note and temporary mitigations, see: