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.

By 4 min read
Original researchCan Codex Hook Policies See the Tool Calls They Claim to Govern?

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 research
Codex Hook Review Finds Four Built-In Paths Outside Pre-Execution Checks
Superpower DailyOriginal research
Codex Hook Review Finds Four Built-In Paths Outside Pre-Execution Checks

Listen to this story

The audio brief

About 1:40
0:001:40
Read transcript
Four built-in Codex paths sit outside fresh pre-execution hook checks, according to a bounded review of its public core source. The exceptions are write_stdin, tool_search, and Code Mode’s exec and wait controls. Hosted WebSearch follows a separate route and bypasses local hooks entirely. The review counted thirty-four static built-in handlers at the September twentieth cutoff. Thirty can receive a fresh PreToolUse check, and thirty-one can emit a PostToolUse event. Most follow the normal local Function-tool path, where CoreToolRuntime supplies default checks before execution, after execution, and—when allowed—after a hook rewrites the input. The exceptions reflect different kinds of control. write_stdin continues or polls an existing command, so it can produce a post-hook for that original command but no new pre-hook. tool_search has neither event. Code Mode exec sends raw JavaScript in a Custom payload, so generic Function-tool behavior does not apply; its wait control also opts out because it manages an existing code cell. WebSearch is different again: it is supplied as a hosted model tool specification, not dispatched through the local registry. An extension-based web.run path may receive generic hooks instead. The review excluded MCP, dynamic, and extension tools, lacked a recoverable commit hash, and did not test runtime behavior. A reported desktop bypass remains unconfirmed. The practical takeaway is a map, not a blanket guarantee: policy teams need to distinguish local tools, specialized controls, and hosted capabilities. The key question is whether Codex makes those boundaries easier to govern as its action surface expands.

Story brief

3 key points

An 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....

  1. 01

    Code Mode exec sends a Custom payload containing raw JavaScript, so generic Function-tool hook behavior does not apply.

  2. 02

    write_stdin can emit a post-hook for the original command but no new pre-hook; tool_search has neither hook.

  3. 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

Permanent attributionView citation
Finding 01

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
Finding 02

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
Finding 03

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

  1. github.comcodex/codex-rs/core/src/tools/spec_plan.rs at main · openai/codex
  2. github.comcodex/codex-rs/core/src/tools/registry.rs at main · openai/codex
  3. github.comcodex/codex-rs/core/src/tools/code_mode/execute_handler.rs at main · openai/codex
  4. github.comcodex/codex-rs/core/src/tools/handlers/unified_exec/write_stdin.rs at main · openai/codex
  5. github.comcodex/codex-rs/core/src/tools/code_mode/wait_handler.rs at main · openai/codex
  6. learn.chatgpt.comHooks | ChatGPT Learn
  7. github.com[Windows Desktop] create_thread bypasses disabled_tools and trusted PreToolUse hook, freezes UI, and hides the child task · Issue #44707 · openai/codex

Loading discussion...

YOUR READING SPACE

Notifications