codex - 💡(How to fix) Fix Clarify or fire Stop hook when a turn is interrupted with Esc [1 pull requests]

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…

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI / TUI

Which version are you using?

codex-cli 0.130.0

What operating system are you using?

Linux Fedora 42, kernel 6.17.8-200.fc42.x86_64

Bug description

When an active Codex turn is interrupted or aborted mid-run, for example by pressing Esc, the Stop hook does not appear to run.

I am not sure whether this is intended behavior. The hooks documentation lists Stop as a supported hook event, and the app-server interrupt docs describe interrupted turns as completing with status interrupted. From an integration point of view, it is unclear whether an interrupted turn should be considered a stop/completion for hook purposes.

This matters for integrations that use hooks as the source of truth for external session state. In https://github.com/njbrake/agent-of-empires/issues/1126 , for example, a Codex Stop hook writes the session status back to idle. If UserPromptSubmit, PreToolUse, or PostToolUse previously marked the session as running, then pressing Esc can leave the external status stuck on Running even though Codex is no longer doing work.

Expected behavior

One of these would be reasonable:

  1. Stop fires when a running turn is interrupted with Esc.
  2. Codex documents that Stop only fires for normally completed turns, not interrupted turns.
  3. Codex exposes a separate hook/event for interrupted or cancelled turns, so integrations can reliably clear running state.

Actual behavior

After interrupting an active turn with Esc, the configured Stop hook does not appear to run. External hook-driven state can remain stuck in a running state until another hook event fires or the session is restarted.

Steps to reproduce

  1. Configure a simple Stop hook in ~/.codex/hooks.json that appends a timestamp to a log file.
  2. Start Codex CLI/TUI.
  3. Submit a prompt that runs long enough to interrupt.
  4. Press Esc while Codex is actively working.
  5. Check the hook log file.

Expected: the Stop hook either runs, or there is a documented separate interrupt/cancel event.

Actual: no Stop hook entry appears to be written for the interrupted turn.

Impact

This makes hook-based lifecycle integrations hard to keep correct. A tool can observe that a turn started, but cannot reliably observe that it ended if the user interrupts it.

If skipping Stop on interrupt is intentional, documenting that explicitly would help. If not intentional, firing Stop or adding an interrupt-specific hook would make the lifecycle contract much clearer.

Related context

Possibly related but not the same failure mode:

  • #21160 reports hooks not firing after rate-limit stops or live hook config edits.

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

One of these would be reasonable:

  1. Stop fires when a running turn is interrupted with Esc.
  2. Codex documents that Stop only fires for normally completed turns, not interrupted turns.
  3. Codex exposes a separate hook/event for interrupted or cancelled turns, so integrations can reliably clear running state.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Clarify or fire Stop hook when a turn is interrupted with Esc [1 pull requests]