Setup
1
Start agentmemory
2
Wire MCP
~/.codex/, backs up config.toml, and appends the server block. On Codex Desktop, add --with-hooks (see below).3
Install the Codex plugin (recommended)
plugin/ directory as the Claude Code plugin and registers the MCP server, 6 lifecycle hooks, and 17 skills.4
Restart Codex
Codex picks up MCP servers on next launch.
5
Verify
codex mcp list should show agentmemory as enabled. Run one prompt, then check the Sessions tab at http://localhost:3113 for hook-captured observations — and if none appear, see the hook trust approval below.What connect writes
~/.codex/config.toml
--force strips the existing [mcp_servers.agentmemory] block first and appends a fresh one, so the file never accumulates duplicates. The write is verified by re-reading the file.
Capture model
The plugin registers 6 lifecycle hooks:SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PreCompact, Stop. Codex’s hook engine injects CLAUDE_PLUGIN_ROOT into hook subprocesses, so the same hook scripts run unmodified across Claude Code and Codex. Subagent, SessionEnd, Notification, TaskCompleted, and PostToolUseFailure events are Claude Code only and are not registered for Codex.
The plugin also registers 9 invocable skills (/recall, /remember, /session-history, /forget, /recap, /handoff, /lesson, /commit-context, /commit-history) plus 8 reference skills the agent loads on demand.
Codex Desktop: --with-hooks workaround
Until upstream fixes plugin-scope dispatch, mirror the same hook commands into the global hooks file:
hooks.codex.json manifest into ~/.codex/hooks.json with ${CLAUDE_PLUGIN_ROOT} resolved to the absolute bundled plugin/ path. The merge is idempotent: re-installs strip only entries whose command points under the bundled scripts/ directory, and your own hook entries survive. It runs even when MCP is already wired.
The merged entries reference absolute, version-embedding paths. Re-run
agentmemory connect codex --with-hooks after upgrading agentmemory to refresh them, then re-approve in the TUI.Troubleshooting
MCP tools work but no observations are captured
MCP tools work but no observations are captured
Two causes, in order of likelihood. First: the hooks were never trusted — codex runs only hooks with a recorded
trusted_hash, and the “Hooks need review” prompt appears only in the interactive TUI, so launch codex once and choose Trust all (a codex exec-only workflow never sees the prompt and the hooks stay inert, while codex still prints hook: ... Completed for other tools’ trusted hooks, which is easy to misread). Second: you are on Codex Desktop relying on plugin-local hooks, which are currently silent there (openai/codex#16430) — run connect codex --with-hooks to mirror the hooks into ~/.codex/hooks.json, then trust them in the TUI.Hooks fallback skipped: could not locate bundled plugin/ directory
Hooks fallback skipped: could not locate bundled plugin/ directory
The installer resolves the bundled
plugin/ directory of the installed @agentmemory/agentmemory package. Reinstall the package (npm install -g @agentmemory/agentmemory) and re-run. The MCP wiring is applied regardless of this skip.src/cli/connect/codex.ts and src/cli/connect/codex-hooks.ts. Hook manifest: plugin/hooks/hooks.codex.json.