AI News Daily한국어
← AI tool tips
Codex✓ Confirmed in official docsAdded Dec 2

How to make a failing Codex hook block the tool with onFailure

Starting with Codex CLI 0.173.0 (December 2), each command hook and MCP tool hook handler can set onFailure. The default, continue, keeps today's behavior: if the hook fails, Codex moves on. With block, a hook that fails to run or doesn't return a usable result applies the event's blocking behavior.

Use it for hooks that must not be skipped, such as security checks. Add one line to the handler in hooks.json.

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ~/.codex/hooks/check_command.py",
            "onFailure": "block"
          }
        ]
      }
    ]
  }
}

If a PreToolUse check fails, the tool doesn't run. If a PostToolUse check fails, Codex withholds the result of a tool that already ran. It applies only to supported synchronous hooks, and Codex still reports the reason and the failure diagnostics.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →