Repository navigation
Description
Summary
AgentMemory v0.9.18 includes a Codex plugin hook config at hooks/hooks.codex.json, but in Codex Desktop the automatic hooks do not appear to run. As a result, normal Codex tool calls do not create observations, even though the AgentMemory server and hook scripts work when invoked manually.
Environment
- AgentMemory version: 0.9.18
- Client: Codex Desktop on Windows
- Workspace: Windows local workspace
- AgentMemory server:
http://localhost:3111 - Viewer:
http://localhost:3113 - Plugin enabled in
~/.codex/config.toml:
[plugins."agentmemory@agentmemory"]
enabled = trueFeature flags are enabled and the server is healthy:
Provider: llm
Embeddings: embeddings
Flags:
GRAPH_EXTRACTION_ENABLED enabled
CONSOLIDATION_ENABLED enabled
AGENTMEMORY_AUTO_COMPRESS enabled
AGENTMEMORY_INJECT_CONTEXT enabled
What I tested
1. Normal Codex Desktop tool calls do not create observations
I ran several real Codex tool calls in the current session, including shell commands, file reads, rg searches, and even failing commands.
After those tool calls:
agentmemory status
still reported:
Observations: 0
2. Direct REST observation works
Manually posting to the AgentMemory REST API succeeds:
Invoke-RestMethod -Method Post `
-Uri http://localhost:3111/agentmemory/observe `
-Body $body `
-ContentType 'application/json'Result:
obs_mpb823mo_eaa0961cded0
So the server can receive observations.
3. Manual hook script execution works
Running the hook scripts directly also creates searchable observations:
$payload | node "C:\Users\Lenovo\.codex\plugins\cache\agentmemory\agentmemory\0.9.18\scripts\post-tool-use.mjs"
$payload | node "C:\Users\Lenovo\.codex\plugins\cache\agentmemory\agentmemory\0.9.18\scripts\prompt-submit.mjs"Those produced searchable observations, including:
obs_mpb87wk7_a8d9e8426885
obs_mpb87wnn_7ed2afd3df63
So the scripts themselves work when invoked manually.
Suspicious detail
hooks/hooks.codex.json contains commands like:
"command": "node ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-use.mjs"But in the Codex Desktop environment I checked:
CLAUDE_PLUGIN_ROOT = empty
CODEX_PLUGIN_ROOT = empty
This makes me suspect one of the following:
- Codex Desktop currently does not dispatch plugin hooks from
hooks.codex.json; or - Codex does dispatch hooks, but
${CLAUDE_PLUGIN_ROOT}is not defined in Codex, so the hook command cannot resolve the script path; or - The hook schema/event names differ between Claude Code and Codex Desktop.
Expected behavior
When agentmemory@agentmemory is enabled in Codex and hooks.codex.json is present, normal Codex events should create observations, e.g.:
- user prompt submission →
prompt_submitobservation - tool use completion →
post_tool_useobservation - session start/end → corresponding session events
After a few Codex tool calls, agentmemory status should show Observations > 0.
Actual behavior
Normal Codex Desktop tool calls do not increase observations. Observations remains 0.
Manual REST calls and manual script execution both work, so the break seems to be in the Codex hook dispatch / hook config integration rather than in the AgentMemory REST API or hook scripts.
Impact
This prevents Codex Desktop from automatically capturing observations, which also prevents downstream features such as session history, consolidation, and graph extraction from working as intended in Codex workflows.
Activity
rockarxiv commentedon May 18, 2026
+1 I have the same issue, and I believe it is coming from Codex itself. see openai/codex#16430
I've fixed it temporarily by adding those scripts to my
~/.codex/hooks.jsonKeesan12 commentedon May 18, 2026
The ${CLAUDE_PLUGIN_ROOT} detail sounds like the key clue. If Codex Desktop does not provide the expected plugin-root variable or hook dispatch contract, the integration needs a startup preflight that says exactly which hook path resolved, which runtime variables are present, and whether automatic dispatch is actually active. Otherwise users end up debugging the memory layer when the real break is earlier in the hook chain.
jonathanzhan1975 commentedon May 19, 2026
Picking up the threads from @rockarxiv and @Keesan12 — both point at the same gap on different sides.
On the upstream root cause (@rockarxiv → openai/codex#16430): agreed, Codex Desktop's hook-dispatch contract is the load-bearing piece here. Until that's clarified upstream,
hooks.codex.jsonwill keep being silently inert on Desktop while working fine on the CLI. @rockarxiv's workaround of mirroring scripts into~/.codex/hooks.jsonis the right escape hatch for now — worth promoting that to a documented fallback in the plugin README until upstream lands the fix.On the detection side (@Keesan12's preflight idea): this converges with what I proposed in #508 — a
memory_diagnose --include-hook-paths(or a dedicatedagentmemory print-claude-hooks --check) that resolves every wired hook path viaTest-Path/fs.existsSyncand reports which runtime variables (${CLAUDE_PLUGIN_ROOT},${CODEX_PLUGIN_ROOT}, etc.) actually expanded. That single command would have caught both this issue and #508 in under a second, instead of leaving users to manually audit~/.claude/settings.jsonor~/.codex/hooks.json.Proposed consolidation:
memory_diagnose --include-hook-paths(covers both client surfaces — Claude Code settings + Codex hooks.json)SessionStartand writes a single warning observation if any wired hook is unreachableHappy to put this PR together if @rohitg00 confirms direction. Currently have 3 PRs in flight (#528, #529, #538) so this would queue behind those — but the work is small enough that it could realistically ship as a focused follow-up to whichever of those lands first.
fix(codex): --with-hooks workaround for openai/codex#16430 (closes #509…
Keesan12 commentedon May 21, 2026
That
memory_diagnose --include-hook-pathsshape sounds like exactly the right wedge.The part I would keep brutally concrete is the receipt boundary: if the command runs, can an operator immediately answer which hook path resolved, which vars expanded, which dispatch path is live, and which client surface was actually admitted without opening config files by hand.
That kind of startup-truth output seems like the fastest way to turn this from config archaeology into a one-command diagnosis.
Keesan12 commentedon May 22, 2026
The cleanest next move here is a startup-truth receipt before any deeper hooks: which hook path actually loaded, which one was skipped, what config source won, and the first failure class. That keeps the thread grounded in diagnostics instead of conflating it with policy or product surface.
Keesan12 commentedon May 26, 2026
The suspicious detail you surfaced feels like the right root cause to chase: hooks that work manually but not through Codex Desktop usually point to hook dispatch or environment wiring, not the AgentMemory server itself. If Codex is not setting the plugin-root variable the hook expects, I would rather see the hook fail loudly with a path check than silently record zero observations. That would make the missing integration obvious on the first run instead of after tool calls have already disappeared into the void.
fix(codex): --with-hooks workaround for openai/codex#16430 (closes ro…