Codex Hook Review Finds Four Built-In Paths Outside Pre-Execution Checks
A bounded review of Codex’s current core source finds strong coverage for local function tools, but exclusions in code-mode controls, tool discovery and hosted web search complicate claims of comprehensive governance.
The checked source supports a bounded finding: hooks cover most enumerated static built-in handler types, but selective exclusions and hosted paths mean they are not a complete action-governance boundary.
Explore the full researchListen to this story
The audio brief
Story brief
3 key pointsAn OpenAI Codex source review at the September 20 cutoff maps hook coverage across 34 static built-in handlers: 30 support fresh PreToolUse checks and 31 emit PostToolUse events. Four paths—write_stdin, tool_search, Code Mode exec, and Code Mode wait—fall outside fresh pre-execution coverage, while hosted WebSearch bypasses local hooks entirely. The result is a bounded capability inventory, not an execution audit....
- 01
Code Mode exec sends a Custom payload containing raw JavaScript, so generic Function-tool hook behavior does not apply.
- 02
write_stdin can emit a post-hook for the original command but no new pre-hook; tool_search has neither hook.
- 03
Hosted WebSearch is supplied as a model tool specification; an extension-based web.run path may receive generic hooks.
Codex’s hook system can inspect most of the static built-in tool handlers in its current public core source before they run. But a bounded source review finds that four of 34 handlers do not emit PreToolUse payloads, leaving fresh pre-execution hook checks unavailable for write_stdin, tool_search, Code Mode execution and Code Mode wait controls. Hosted WebSearch sits outside the local hook system altogether.
That is not evidence that hooks are ineffective. It is a clearer map of what they govern. The dominant path is a locally dispatched function tool: Codex’s CoreToolRuntime supplies default pre- and post-hook payloads for that payload type and can rebuild an invocation after a pre-hook rewrites its input. The review found 30 of 34 static built-in handler types can use that pre-hook path, and 31 can emit a post-execution payload.
A strong default, with a defined perimeter
The denominator matters. The review counted 34 distinct static built-in CoreToolRuntime handler types in the public source at the September 20 cutoff. It excluded external MCP tools, dynamic tools, extension tools and hosted tool specifications. So these percentages describe a bounded core inventory, not every action that a particular Codex desktop, plugin, provider or configuration might expose.
The exceptions are not all the same kind of gap
The most consequential contrast is between a normal tool call and a specialized control surface. Code Mode’s outer execution handler receives a Custom payload containing raw JavaScript source, rather than the Function payload that triggers the runtime’s generic hook defaults. Its separate wait handler also opts out of both hook payloads because it controls an existing code cell rather than presenting a standalone action.
What falls outside a fresh pre-hook check
- write_stdin: It deliberately emits no new PreToolUse payload because it continues or polls an existing command. It can still produce a Bash post-hook payload when that original command finishes.
- tool_search: The discovery path has neither pre- nor post-tool hook coverage in the reviewed inventory.
- Code Mode: The outer JavaScript execution path and its wait or termination control do not emit the generic hook payloads.
These are narrower exceptions than an account of unrestricted tool activity would suggest. They are concentrated in transport, discovery and runtime-control paths. Meanwhile, several categories that might appear unusual—including update_plan, view_image, MCP resource operations and the native agent-orchestration handlers—use Function payloads in the current core source and inherit the generic pre-hook, post-hook and input-rewrite behavior.
A hosted lane follows a different route
Hosted WebSearch is a separate case, not merely another uncovered local handler. Codex appends it as a hosted model tool specification rather than sending it through the local registry dispatch path. That leaves it outside both PreToolUse and PostToolUse. A standalone extension-based web.run path can take the other route and receive generic function-tool hooks, so the boundary depends on how the capability is supplied.
The documentation supports the narrower reading
Codex’s official hooks documentation describes the system as an extensibility framework for actions such as logging, scanning prompts and validation. It also explicitly warns that hooks are a guardrail rather than a complete enforcement boundary, identifies hosted WebSearch as outside tool coverage, and notes that specialized paths can opt out. That framing aligns with the source-level result: broad protection for an important local pathway, not a promise that every possible action is mediated by one event.
There is also a reason not to overstate the review. It is a source-capability inventory, not an execution test. The reviewed main-branch snapshot had no recoverable commit hash, and it cannot establish that every desktop-owned, plugin-owned or provider-specific pathway reaches the core registry. A September 11 GitHub issue alleged that a Windows Desktop task-creation path bypassed disabled-tools settings and a trusted pre-hook, but that report remains unconfirmed in the supplied evidence.
What to watch next
The key question is whether Codex makes these boundaries easier to see and govern as its action surface expands. For users building policy around hooks, the immediate task is more basic: identify which tools use the local Function path, which rely on specialized controls, and which are hosted. A coverage percentage is useful only when paired with that map—and with the recognition that post-execution review cannot prevent an action that has already occurred.
Editorial analysis
Our Read
The important split is not between “hooks work” and “hooks fail.” It is between a local function-tool control plane and the broader set of ways an agent can act. The review shows the first plane has substantial coverage, including argument rewriting, while Code Mode, discovery and hosted tools introduce different boundaries. Teams considering hooks as an enterprise control should watch whether future Codex changes make those exceptions visible in one policy and audit model—or continue to document them as specialized paths. That distinction matters for products built around runtime tool governance.
Citation desk / original work
Cite this
Citation desk / original work
Cite this
Official documentation now explicitly characterizes hooks as a useful guardrail rather than a complete enforcement boundary and identifies hosted WebSearch and specialized opt-outs. Describing hooks alone as comprehensive Codex action governance would conflict with the documented boundary.
/posts/codex-hook-review-finds-four-built-in-paths-outside-pre-execution-checks#finding-claim-8
30 of 34 built-in handler types, 88.2%, can emit PreToolUse payloads. The four exceptions are write_stdin, Code Mode exec, Code Mode wait and tool_search.
/posts/codex-hook-review-finds-four-built-in-paths-outside-pre-execution-checks#finding-claim-2
31 of 34 built-in handler types, 91.2%, can emit PostToolUse payloads. Code Mode exec, Code Mode wait and tool_search are the three exceptions; write_stdin can emit the completed original command's Bash post-hook payload.
/posts/codex-hook-review-finds-four-built-in-paths-outside-pre-execution-checks#finding-claim-3
Sources
- github.comcodex/codex-rs/core/src/tools/spec_plan.rs at main · openai/codex
- github.comcodex/codex-rs/core/src/tools/registry.rs at main · openai/codex
- github.comcodex/codex-rs/core/src/tools/code_mode/execute_handler.rs at main · openai/codex
- github.comcodex/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs at main · openai/codex
- github.comcodex/codex-rs/core/src/tools/code_mode/wait_handler.rs at main · openai/codex
- learn.chatgpt.comHooks | ChatGPT Learn
- github.com[Windows Desktop] create_thread bypasses disabled_tools and trusted PreToolUse hook, freezes UI, and hides the child task · Issue #44707 · openai/codex
Reader comments
Newest comments first. Replies stay oldest first.