OpenAI lets Codex CLI hooks stop a tool running if a check fails
OpenAI’s 2 December release notes say supported synchronous hooks for commands and MCP tools can use onFailure = block. The default is still continue. Codex also now shares MCP connections by default.
A hook is a script or MCP tool that Codex runs at a set point in a session. Codex runs a PreToolUse hook before a tool call. The hook could already reject the call, for example by exiting with code 2. What is new is what happens when the check does not work at all.
OpenAI’s release notes, published on 2 December, say supported synchronous command and MCP tool hooks can use the setting onFailure = "block". A failed PreToolUse check then prevents the tool from running. Hooks are defined in a hooks.json file or in the [hooks] section of config.toml, the Munder Difflin blog said.
The blog examined the pull request and source code behind the change. It said the default is still continue, which keeps the old behaviour. A PreToolUse command hook is marked failed if it exits with any code other than 0 or 2. Codex skips a new or changed hook that administrator policy does not manage until the user approves it in the /hooks view.
In the blog’s example, a script guarding Bash commands uses exit code 2 to block commands that touch the .env file. If the jq program the script relies on is missing, the script exits with an error. Without the block setting, the command would then pass unchecked.
With the block setting, a failed PostToolUse check withholds the result of a tool that has already run, but does not undo the changes the tool made, the blog said. Codex does not load a hook with the block setting if the hook is asynchronous or runs on the SessionEnd, PreModelRequest or PostModelRequest event.
The blog noted that OpenAI’s hook documentation had not yet mentioned the onFailure setting as of 2 December. It quoted the documentation’s advice to treat tool hooks as a useful extra safeguard rather than airtight enforcement. In the blog’s own view, checking the text of a command is easy to get around.
Among the other changes, the most significant is that Codex now shares MCP connections by default and supports older local MCP servers that require an initialize request first. Running threads now pick up updated approval requirements and Guardian policies when the configuration is reloaded or the user signs in or out. The TurboAI site points out that a policy changed mid-task takes effect only after one of these.
Administrators can block both scheduled and manual daemon updates with features.daemon_updates = false in a managed requirements.toml file or in a local MDM policy. The release also brings status line alignment, Markdown rendering improvements and smaller npm packages.
Read more: How an agent works · Agent map