Skip to content

Codex Desktop does not appear to trigger hooks.codex.json observations #509

Closed

Description

@jonathanzhan1975

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 = true

Feature 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:

  1. Codex Desktop currently does not dispatch plugin hooks from hooks.codex.json; or
  2. Codex does dispatch hooks, but ${CLAUDE_PLUGIN_ROOT} is not defined in Codex, so the hook command cannot resolve the script path; or
  3. 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_submit observation
  • tool use completion → post_tool_use observation
  • 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

  1. rockarxiv commented on May 18, 2026

    @rockarxiv

    +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.json

  2. Keesan12 commented on May 18, 2026

    @Keesan12

    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.

  3. jonathanzhan1975 commented on May 19, 2026

    @jonathanzhan1975
    ContributorAuthor

    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.json will keep being silently inert on Desktop while working fine on the CLI. @rockarxiv's workaround of mirroring scripts into ~/.codex/hooks.json is 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 dedicated agentmemory print-claude-hooks --check) that resolves every wired hook path via Test-Path/fs.existsSync and 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.json or ~/.codex/hooks.json.

    Proposed consolidation:

    • One PR adding memory_diagnose --include-hook-paths (covers both client surfaces — Claude Code settings + Codex hooks.json)
    • Output includes: resolved hook path, exists?, runtime vars present, dispatch active (where detectable)
    • Same check runs at SessionStart and writes a single warning observation if any wired hook is unreachable

    Happy 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.

  4. added a commit that references this issue on May 20, 2026
    e371be9
  5. Keesan12 commented on May 21, 2026

    @Keesan12

    That memory_diagnose --include-hook-paths shape 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.

  6. Keesan12 commented on May 22, 2026

    @Keesan12

    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.

  7. Keesan12 commented on May 26, 2026

    @Keesan12

    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.

  8. added a commit that references this issue on Jul 27, 2026
    aa2d3c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions