Codex hooks not working? 12 causes and how to fix each

Codex hooks not working? Check /hooks trust, the file location, Stop hook JSON, timeouts and matchers. Twelve causes, checked.

By The IdlePal team · Published · Last checked against the official docs

Illustration for Codex hooks not working? 12 causes and how to fix each: Pip, IdlePal's desktop pet

When Codex hooks are not working, the cause is almost always one of a short list: the hook isn’t trusted, the file is in a layer Codex doesn’t load, the script prints the wrong output, or it runs out of time. Start with /hooks: it shows every hook Codex found and whether it still needs review. The twelve causes below cover the rest, in the order worth checking, each with its fix. Everything here was checked against OpenAI’s hooks docs on November 19, 2026.

Codex hooks not running? Check these first

Three quick checks rule out most problems before you touch a script.

  1. Run /hooks in the CLI. If your hook isn’t listed, Codex never loaded the file. If it’s listed as needing review, trust it.
  2. Look for a startup warning. Codex warns when hooks need review and when a layer has both a hooks.json and an inline [hooks] table.
  3. Run the command by hand. Pipe a small JSON object into it from the session’s working directory, for example echo '{}' | ./my-hook.sh, and read what it prints.

Why are my Codex hooks not working?

1. The hook isn’t trusted yet

Codex records trust against a hash of each hook. A new hook, or one you edited, is skipped until you review it. In the CLI, open /hooks and trust it. In the desktop app, click Review hooks in the composer or go to Settings > Hooks. A plugin update that changes a bundled hook script needs a fresh review too.

While you’re still editing a script, codex --dangerously-bypass-hook-trust runs enabled hooks for one invocation without saving trust. Don’t leave it in an alias.

2. The file is in the wrong place

Codex reads hooks from four places:

Layer Location
System /etc/codex/hooks.json
User ~/.codex/hooks.json (or $CODEX_HOME/hooks.json)
Project <repo>/.codex/hooks.json
Inline [hooks] tables in any of those layers’ config.toml

A file named hook.json, a hooks.json at the repo root instead of inside .codex/, or a custom CODEX_HOME you forgot about are the usual mistakes.

3. Project hooks need a trusted project

Hooks in .codex/hooks.json only load from trusted project layers. Codex checks every .codex folder from the project root down to your working directory. If the project isn’t trusted, its hooks are skipped without running. In a linked Git worktree, the project layer can read hooks from the main checkout, which surprises people who edited the worktree’s copy.

4. Hooks are turned off

Hooks are on by default. Look for this in your config.toml:

[features]
hooks = false

The old codex_hooks key still works as a deprecated alias, so check for it too. On a work machine, an admin can also force hooks off in requirements.toml, or set allow_managed_hooks_only = true, which skips every user, project, session and plugin hook. Managed hooks keep running either way.

5. The handler type isn’t supported

Only command and mcp_tool handlers run today. Handlers of type prompt or agent are parsed and then skipped, so a hook that looks valid can still do nothing.

When the hook runs but fails

6. The Stop hook prints plain text

This is the most common error message. Stop and SubagentStop expect JSON on stdout when the hook exits 0, and plain text is invalid. End the script with an empty object and send everything else elsewhere:

afplay /System/Library/Sounds/Glass.aiff >/dev/null 2>&1 &
echo '{}'

Interrupt is strict too: exit 0 with no output, or print JSON with an optional systemMessage.

7. A relative path breaks

Commands run in the session’s working directory, not the folder that holds hooks.json. A path like ./scripts/notify.sh works in one directory and fails in the next. Resolve paths from the repo root instead:

"$(git rev-parse --show-toplevel)/.codex/hooks/notify.sh"

Make the script executable with chmod +x while you’re there.

8. It times out

timeout is in seconds and defaults to 600 for most events. SessionEnd and Interrupt are different: they default to 1 second and allow 3 at most. A hook that plays a sound, calls an API or waits on a lock can blow through that. Start slow work in the background and return straight away.

9. A PreToolUse field marks it as failed

On PreToolUse, fields Codex doesn’t support yet (continue, stopReason, suppressOutput, or permissionDecision: "ask") mark the hook run as failed, and the tool call goes ahead anyway. On PostToolUse, updatedMCPToolOutput and suppressOutput fail the same way. If a block isn’t blocking, check the fields first.

When the hook runs at the wrong time

10. The matcher doesn’t filter

A matcher is a regex, and it doesn’t apply everywhere. It’s ignored for UserPromptSubmit, Stop and Interrupt, and not supported for PreModelRequest and PostModelRequest. For file edits, apply_patch also matches Edit and Write. Hosted tools such as web search don’t trigger PreToolUse or PostToolUse at all, and PermissionRequest doesn’t run for commands that don’t need approval.

11. It runs twice

Codex loads every layer, so the same command in ~/.codex/hooks.json and .codex/hooks.json runs twice. So does one layer with both a hooks.json and an inline [hooks] table. Keep each command in exactly one place.

12. Async or SessionEnd hooks don’t finish

async: true runs a hook in the background, up to 8 at a time per session. An async hook can’t block, approve or continue anything, and unfinished ones are cancelled when the session ends. SessionEnd always runs synchronously, doesn’t support MCP tool hooks, and fires on archive or delete, a normal close, or after 30 minutes idle. It doesn’t fire when you just switch to another conversation.

MCP tool hooks have one more catch: they use an existing connection and don’t start servers. If the server isn’t running, the hook is skipped without blocking anything.

A hook that just works

If you only wanted a sound or a banner when Codex finishes, the guide to how Codex hooks work has a full, tested hooks.json. Or let an installer write it for you.

IdlePal is a Mac menu bar app with short games and a desktop pet named Pip. When Codex starts a turn, a panel of games drops from your menu bar or MacBook notch, and when the turn ends it tucks itself away. A free, open-source installer merges its hooks (UserPromptSubmit, Stop, Interrupt, SessionEnd and PermissionRequest) into ~/.codex/hooks.json and keeps your other hooks:

curl -fsSL https://raw.githubusercontent.com/initiums/idlepal-integrations/main/codex/install.sh | sh

Run /hooks once after installing to trust them. The hooks only send “started”, “finished” or “needs you”, plus a session id, and never read your prompts or code.

Codex hooks not working: questions

What should I check first when Codex hooks stop working?

Most often the hook isn't trusted yet. Codex records trust against a hash of each hook, so a new or edited hook is skipped until you review it in /hooks in the CLI, or under Review hooks or Settings > Hooks in the desktop app.

Why does my Codex Stop hook say the output is invalid?

Stop and SubagentStop expect JSON on stdout when the hook exits 0, so plain text is invalid. Print echo '{}' as the last line and send anything else to /dev/null or stderr.

Why do my project's .codex/hooks.json hooks not load?

Project hooks only load from trusted project layers. Trust the project in Codex, make sure the file sits in a .codex folder between the project root and your working directory, then review the hooks in /hooks.

Why does my Codex hook run twice?

Two layers register the same command, for example ~/.codex/hooks.json and .codex/hooks.json, or a hooks.json plus an inline [hooks] table in the same layer. Codex loads every layer, so keep each command in one place.

Why doesn't my matcher filter the event?

Matchers are ignored for UserPromptSubmit, Stop and Interrupt, and aren't supported for PreModelRequest and PostModelRequest. For file edits, apply_patch also matches Edit and Write.

How do I test a Codex hook without trusting it?

Start Codex with --dangerously-bypass-hook-trust. Enabled hooks run for that one invocation without saving any trust, which is handy while you're still editing the script.

Do hooks work in the Codex desktop app?

Yes. The app reads the same hooks.json and config.toml files. When hooks need review it shows Review hooks in the composer, and you can manage them under Settings > Hooks.

Pip is waiting in the Mac App Store.

Five games are free for good. One $9.99 unlock opens the rest, plus every game we add later.

Download on the Mac App Store

IdlePal is a Mac app. Open this page on your Mac, or send yourself the link.

macOS 14 or later. No subscription, no account.