codex exec does not dispatch repo hooks from .codex/hooks.json

Open 💬 3 comments Opened Jun 4, 2026 by AbdusM

Summary

codex exec on @openai/codex@0.137.0 does not appear to dispatch repo hooks from <repo>/.codex/hooks.json, even when --dangerously-bypass-hook-trust is supplied. The invocation accepts the bypass flag and completes, but the configured hook command is never called and no runtime hook log is created.

Environment

  • Package: @openai/codex
  • CLI version: codex-cli 0.137.0
  • Package metadata:
  • repository.url = git+https://github.com/openai/codex.git
  • bugs.url = https://github.com/openai/codex/issues
  • Repo path used for proof: /Users/abdusmuwwakkil/Development/codex-skills

Repo Hook Config

Repo hook file: <repo>/.codex/hooks.json

Configured events:

  • SessionStart
  • UserPromptSubmit
  • SubagentStart
  • SubagentStop
  • Stop

Each event invokes:

{
  "type": "command",
  "command": "/usr/bin/env node \"$(git rev-parse --show-toplevel)/.codex/hooks/log_codex_runtime_event.mjs\"",
  "timeout": 10
}

The hook script appends sanitized event metadata to:

docs/skill-system/artifacts/codex-runtime-hook-log.jsonl

Local Hook Verification

The repo's direct hook verifier passes:

node scripts/verify_codex_runtime_hooks.mjs

Observed output:

Codex runtime hook verification passed.

That verifier checks the .codex/hooks.json entries, directly invokes .codex/hooks/log_codex_runtime_event.mjs with a sample UserPromptSubmit payload, verifies JSON stdout, verifies one JSONL log line is written, and confirms raw prompt text is not persisted.

Reproduction

codex exec --sandbox read-only --dangerously-bypass-hook-trust --json \
  --cd /Users/abdusmuwwakkil/Development/codex-skills \
  "Return exactly: OK"

Observed JSON output:

{"type":"item.completed","item":{"id":"item_0","type":"error","message":"`--dangerously-bypass-hook-trust` is enabled. Enabled hooks may run without review for this invocation."}}
{"type":"item.completed","item":{"id":"item_1","type":"agent_message","text":"OK"}}

I also ran the same command without the bypass flag:

codex exec --sandbox read-only --json \
  --cd /Users/abdusmuwwakkil/Development/codex-skills \
  "Return exactly: OK"

It also completed successfully with OK and did not create the hook log.

Expected Result

At least one configured hook event should run during the codex exec invocation, for example SessionStart, UserPromptSubmit, or Stop, and the hook command should append at least one event to:

docs/skill-system/artifacts/codex-runtime-hook-log.jsonl

Actual Result

No hook log file is created:

ls: docs/skill-system/artifacts/codex-runtime-hook-log.jsonl: No such file or directory

The repo dashboard reports:

"runtime_hook_log": {
  "event_count": 0,
  "by_event": {},
  "status": "NO_EVENTS"
}

Why This Looks Like Runtime Delivery, Not Hook Script Failure

  • .codex/hooks.json contains the documented hook events and command hooks.
  • The hook script itself works when invoked directly by the repo verifier.
  • codex exec accepts --dangerously-bypass-hook-trust and warns that hooks may run without review.
  • Neither the bypass run nor the no-bypass run dispatches the repo hook command or creates the hook log.

Could you clarify whether codex exec is expected to load and dispatch repo hooks from .codex/hooks.json in 0.137.0? If it is expected, this appears to be a hook-dispatch bug. If it is not expected, the docs for hooks / --dangerously-bypass-hook-trust may need to call out that limitation.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗