Harness Notes

Hooks

Updated 2026-11-24,

On this page

Which moments a hook can attach to, and what it can do there. Event names link to each harness’s documentation. “Block”, “deny” and “modify” change what the agent does; “observe only” can watch but not intervene. Where hook files live is on the Locations page.

MomentCodex CLIHook commands
Hook types
  • command
  • mcp_tool
  • prompt (accepted but skipped)
  • agent (accepted but skipped)
Session and workspace
Session starts
SessionStart

add context, stop

Session ends
SessionEnd

observe only

Main thread only; advisory and always synchronous.

Prompt and turn
User submits a prompt
UserPromptSubmit

block, add context

Turn is interrupted
Interrupt

observe only

Runs when you interrupt an active turn on the main thread; not for subagents. The matcher is ignored.

Can only emit a system message; it cannot prevent or reverse the interruption.

Agent finishes its turn
Stop

queue follow-up, stop

decision: "block" queues a continuation prompt; continue: false from any hook takes precedence.

Tools
Before a tool runs
PreToolUse

deny, modify, add context

permissionDecision ask, and allow without updatedInput, fail the hook run; the tool call proceeds.

Covers shell, apply_patch, MCP and local function tools, not hosted tools such as web search.

0.166.0: for local `exec_command` calls, the `cwd` in PreToolUse input is the directory the command will run in, not the session directory. PermissionRequest and PostToolUse input also carry the command cwd where known. Hooks still run in the session directory, and commands on a remote executor still report the host cwd.

After a tool succeeds
PostToolUse

replace, add context

decision: "block" or continue: false replaces the tool result with the feedback and continues; side effects are not undone.

Also runs after shell commands that exit non-zero.

Permissions and questions
Permission is requested
PermissionRequest

allow, deny

Any deny wins. updatedInput, updatedPermissions and interrupt fail closed.

Subagents
Subagent starts
SubagentStart

add context

Subagent finishes
SubagentStop

queue follow-up, stop

Context and compaction
Before context is compacted
PreCompact

stop

continue: false ends the turn before compacting.

After context is compacted
PostCompact

stop

continue: false ends the turn after compacting.

Notes and sources

Codex CLI
  • Matching hooks are launched concurrently, so one hook cannot stop another from starting.
  • Project hooks load only in a trusted project, and every non-managed hook must also be reviewed and trusted by its hash.
  • Background (async) hooks cannot block, approve or rewrite the triggering operation.
  • OpenAI describes tool hooks as a guardrail, not a complete enforcement boundary.
  • Since 0.165.0 an execution environment can bring its own managed hooks from its requirements; they are always required, run on that environment's executor and appear as <environment:ID>/requirements.toml. In 0.166.0, App Server hooks/list with a threadId includes them and marks each with environmentId. The App Server's own environment selection supplies none, so these come only from an environment owner that provides its configuration.
  • 0.167.0 managed prompt-user checkpoint, traced at 0.167.2: requirements.toml prefix rules can require fresh human approval for every execution attempt. Hooks and automatic review cannot satisfy it; approval cache/rule amendments do not replace it. A never/rejecting approval policy or enforced automatic-only review rejects the command instead. This is a managed-rule decision, not a fourth approval_policy mode. No runtime probe.
  • November 16 plugin-format audit at Codex 0.169.0: the local loader parses OpenAI overlay hooks but explicitly skips hook sources for Agent Plugins packages; legacy compatibility packages use the hook loader. Executor-owned inline hooks have a separate cleanup admission policy. This updates the package-loading boundary without redating the older event/handler traces; no runtime probe ran.