Skip to content

User-level ~/.codex/hooks.json PostToolUse ignored while plugin PostToolUse runs #24211

Open

Description

@jakobtfaber

Version: codex-cli 0.133.0
Platform: macOS arm64 (Apple Silicon)
Binary: /Users/jakobfaber/.nvm/versions/node/v24.13.1/bin/codex

Observed Behavior:

  • User-level ~/.codex/hooks.json works perfectly for SessionStart, UserPromptSubmit, PreToolUse, and Stop.
  • Adding user-level PostToolUse with standard schema does not execute in the live session (e.g. /tmp/user-posttooluse.log is never written).
  • Under the same tool emission and trust-bypass conditions, plugin-level PostToolUse (e.g., warp@claude-code-warp, remember@claude-plugins-official, and memory-doc-audit@memory-doc-audit-local) executes successfully.
  • No trust entries are ever generated in ~/.codex/config.toml for ~/.codex/hooks.json:post_tool_use:0:0 (nor is the user prompted to trust it), whereas trust entries exist for all other user-level hooks (pre_tool_use, session_start, stop, user_prompt_submit) and plugin-level post_tool_use hooks (e.g. warp@claude-code-warp:hooks/hooks.json:post_tool_use:0:0).
  • --dangerously-bypass-hook-trust bypasses trust check but still fails to trigger user-level PostToolUse, proving it is never discovered/registered in the event dispatcher.

Expected Behavior:
User-level PostToolUse loaded from ~/.codex/hooks.json should be discovered and run on the same supported tool emissions as plugin-level PostToolUse hooks.

Step-by-step Reproduction (Live Session):

  1. Write ~/.codex/hooks.json containing a command hook for "PostToolUse" (e.g. executing "echo USER_POSTTOOLUSE_FIRED >> /tmp/user-posttooluse.log").
  2. Run any command via the interactive Codex CLI that completes successfully (e.g. running "ls" via the shell tool).
  3. Check /tmp/user-posttooluse.log — it is missing or empty, indicating the hook never ran.
  4. (Contrast) Configure the same hook inside a local plugin's hooks/hooks.json. Add and enable the plugin via "codex plugin add".
  5. Run the same command — the plugin-level hook triggers successfully, proving the tool-use hook execution engine itself is functioning.

Evidence:

  • Official developer docs list ~/.codex/hooks.json and show PostToolUse in the hook schema.
  • codex-rs/config/src/hook_config.rs includes PostToolUse.
  • codex-rs/hooks/src/engine/discovery.rs is intended to load config-layer hooks.json and plugin hooks into the same handler list.
  • codex-rs/hooks/src/engine/discovery.rs applies bypass_hook_trust to both config-layer and plugin hooks.
  • codex-rs/core/src/tools/hook_names.rs says apply_patch matcher aliases include Write and Edit.

Caveat:
An isolated "codex exec" test harness with a fake CODEX_HOME/HOME fails to run ANY hooks (including SessionStart/Stop), meaning "codex exec" suffers from broader sandbox-masking / hook-loading limitations. The bug must be diagnosed and verified in a live interactive session.

Activity

  1. added
    bug
    CLI
    hooks
    on May 23, 2026
  2. etraut-openai commented on May 23, 2026

    @etraut-openai
    Contributor

    @jshaofa-ui, please stop spamming our issue tracker with AI-generated posts. These are not helpful.

  3. Pappmann commented on Aug 16, 2026

    @Pappmann

    Additional reproduction on Linux with codex-cli 0.147.0:

    A user-level ~/.codex/hooks.json contains working UserPromptSubmit and Stop hooks plus a PostToolUse hook. The prompt and stop hooks run, but the user-level PostToolUse hook is not invoked for a successful shell command issued through the current tool path; in particular, a completed git push produces no PostToolUse event for the hook.

    The command itself succeeds and the remote update is visible, but a downstream integration relying on PostToolUse cannot observe the push. The configured hook is valid and trusted, and the same integration has received push events through another client/runtime path. This points to event discovery/dispatch or tool-path handling rather than a failure inside the hook command.

    The observed call uses an outer functions.exec wrapper with a nested exec_command. Could this be the same user-level PostToolUse registration/dispatch gap described in this issue?

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

    CLIbughooks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions