codex - 💡(How to fix) Fix Hooks stop firing after rate-limit stops or live hooks.json edits [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#21160Fetched 2026-05-06 06:25:41
View on GitHub
Comments
0
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×5unlabeled ×2

Error Message

  • or surface a clear warning/error when hooks are disabled or skipped.

Root Cause

  • The appropriate stop/session lifecycle hook should still run when Codex stops because of a rate limit, or Codex should explicitly document and surface that hooks are skipped for that stop reason.
  • Hook-driven cleanup, logging, or continuation workflows should not fail silently.

Fix Action

Fix / Workaround

This is more severe than hooks not hot-reloading. After a live hooks.json update, the session appears to lose hook execution altogether. The only reliable workaround I have found is to restart the Codex session.

RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI / TUI

Which version are you using?

codex-cli 0.128.0

What operating system are you using?

  • Ubuntu 24.04 LTS on WSL2
  • Kernel: 6.6.87.2-microsoft-standard-WSL2
  • Node: v22.22.0
  • npm: 11.12.1

Bug description

Hooks can stop firing in a live Codex session under two conditions:

  1. When Codex hits a rate limit and stops, the expected lifecycle hook does not appear to run.
  2. When hooks.json is edited while Codex is already running, hooks stop firing entirely for the remainder of that session.

This is more severe than hooks not hot-reloading. After a live hooks.json update, the session appears to lose hook execution altogether. The only reliable workaround I have found is to restart the Codex session.

The hook configuration file is valid JSON. In the affected workspace, the repo-local hook file exists at .codex/hooks.json, and jq validates it successfully.

Expected behavior

For rate-limit stops:

  • The appropriate stop/session lifecycle hook should still run when Codex stops because of a rate limit, or Codex should explicitly document and surface that hooks are skipped for that stop reason.
  • Hook-driven cleanup, logging, or continuation workflows should not fail silently.

For live hooks.json edits, one of these behaviors would be acceptable:

  • Keep using the previously loaded hook configuration until the session restarts.
  • Hot-reload the updated hook configuration safely.
  • Detect the change, report that hooks require a restart, and keep the previous working hook set active.

What should not happen is that all hooks silently stop firing for the rest of the live session.

Actual behavior

Observed behavior:

  • After a rate-limit stop, the stop-related hook does not appear to run.
  • After modifying hooks.json during an active session, no hooks appear to run again in that session, even though the resulting hooks.json remains valid JSON.
  • Restarting Codex/session restores hook behavior.

Steps to reproduce

Scenario A: rate-limit stop

  1. Configure a simple hook that produces a visible side effect, such as appending a timestamp to a temporary log file.
  2. Start a long-running Codex CLI/TUI session with hooks enabled.
  3. Continue working until Codex hits a rate limit and stops.
  4. Check whether the stop/session lifecycle hook ran.

Scenario B: live hooks.json edit

  1. Configure a simple hook that appends to a temporary log file on each relevant event.
  2. Start a Codex CLI/TUI session and verify the hook fires.
  3. Edit .codex/hooks.json while the session is still running. Keep the file syntactically valid.
  4. Continue the same session and trigger more hook events.
  5. Observe that hooks no longer fire until the Codex session is restarted.

Impact

This breaks long-running workflows that rely on hooks for:

  • cleanup after stop/session lifecycle events
  • logging and audit traces
  • user-defined guardrails
  • continuation or handoff generation when a run stops unexpectedly

The failure mode is particularly costly because it is silent. The user may assume the hook-based workflow is still active when it is not.

Related issues

Possibly related, but not the same failure mode:

  • #17636 requests hot-reloading hook configuration during a live session.
  • #17532 reports repo-local hooks not firing in interactive sessions.
  • #18607 mentions missing Stop / SessionStop hooks in codex exec.

This report is specifically about hooks becoming non-functional in an existing CLI/TUI session after a rate-limit stop or after editing hooks.json during the live session.

Additional notes

A robust fix could be either:

  • keep the previous validated hook registry active until restart,
  • hot-reload hooks transactionally only after successful validation,
  • or surface a clear warning/error when hooks are disabled or skipped.

extent analysis

TL;DR

Restarting the Codex session is currently the most reliable workaround to restore hook functionality after a rate-limit stop or live hooks.json edit.

Guidance

  • Verify that the hooks.json file remains valid JSON after editing, as the issue only occurs with valid JSON configurations.
  • Test whether hooks fire as expected when the Codex session is started with the updated hooks.json configuration to confirm the issue is session-specific.
  • Consider implementing a workaround to detect changes to hooks.json and prompt the user to restart the Codex session to ensure hooks continue to function.
  • Review related issues (#17636, #17532, #18607) to see if they provide additional insight or potential solutions to the hook functionality issue.

Example

No code snippet is provided as the issue does not specify a particular code-related fix, but rather a session management or configuration issue.

Notes

The issue seems to be related to how Codex handles session state and hook configuration updates. A robust fix would require changes to the Codex session management or hook loading mechanism, which is not specified in the provided information.

Recommendation

Apply workaround: Restart the Codex session after editing hooks.json or when a rate-limit stop occurs, as this is the most reliable method to restore hook functionality until a more permanent fix is implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

For rate-limit stops:

  • The appropriate stop/session lifecycle hook should still run when Codex stops because of a rate limit, or Codex should explicitly document and surface that hooks are skipped for that stop reason.
  • Hook-driven cleanup, logging, or continuation workflows should not fail silently.

For live hooks.json edits, one of these behaviors would be acceptable:

  • Keep using the previously loaded hook configuration until the session restarts.
  • Hot-reload the updated hook configuration safely.
  • Detect the change, report that hooks require a restart, and keep the previous working hook set active.

What should not happen is that all hooks silently stop firing for the rest of the live session.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING