Codex Desktop: CLI-trusted PreCompact is not dispatched; blocking auto hook traps task in interrupted-turn loop

Open 💬 0 comments Opened Aug 3, 2026 by eah3699

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.727.51351

What subscription do you have?

Pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

Codex Desktop behaves inconsistently with a user-configured PreCompact hook depending on where the hook is trusted.

A corrected PreCompact hook trusted through the standalone Codex CLI appeared enabled in Desktop Settings → Hooks, but Desktop manual compaction bypassed it. The hook command was not launched, and no diagnostic receipt was produced.

I then changed only the hook’s statusMessage, which created a new trust identity, and trusted that functionally identical hook through Desktop Settings. Desktop subsequently dispatched it during automatic compaction.

That exposed a second problem: when automatic PreCompact returns continue: false, every subsequent prompt retriggers automatic compaction before model sampling. The hook blocks again, the submitted turn is recorded as interrupted, and Desktop produces a blank turn instead of allowing the agent to perform the requested preparation.

This repeats indefinitely until the hook is externally permitted or disabled. The blocking systemMessage is also not presented to the user in a useful way.

What steps can reproduce the bug?

Model:

gpt-5.6-sol, xhigh

Observed context information:

Displayed context window: approximately 258,000 tokens
Observed automatic-compaction threshold: 244,800 tokens
Tokens immediately before the automatic test: 245,289

Reproduction steps:

  1. Add a user-level PreCompact command hook with matcher manual|auto and a 10-second timeout.
  2. Make the hook record each invocation and return a blocking result equivalent to:
{
  "continue": false,
  "systemMessage": "Compaction preparation is required before continuing.",
  "suppressOutput": false
}
  1. Trust the hook through the standalone Codex CLI.
  2. Open Codex Desktop and verify that the hook appears enabled under Settings → Hooks.
  3. While below the automatic threshold, initiate manual compaction from Desktop.
  4. Observe that Desktop compacts without launching the hook command. No hook receipt is created.
  5. Change only nonfunctional metadata such as statusMessage, leaving the matcher, timeout, command, and handler unchanged.
  6. Review and trust the newly identified hook through Desktop Settings rather than through the CLI.
  7. Continue the task until it exceeds the automatic-compaction threshold.
  8. Observe that Desktop now launches PreCompact with trigger=auto.
  9. Allow the hook to return continue: false.
  10. Submit another prompt so the agent can perform the preparation requested by the hook.
  11. Observe that Desktop retriggers automatic compaction before the model can respond.
  12. The hook blocks again, and the submitted turn becomes a blank interrupted turn.
  13. Additional prompts repeat the same cycle.
  14. If one exact hook invocation is externally allowed to return continue: true, compaction completes and normal assistant responses resume.

What is the expected behavior?

Codex Desktop should consistently honor hook trust established through the standalone CLI, or clearly state that Desktop-specific trust is required.

A hook should not appear enabled in Desktop Settings if Desktop will not dispatch it.

When automatic PreCompact returns continue: false:

  • The blocking message should be visibly presented.
  • The task should remain usable long enough for the user or agent to perform the requested preparation.
  • Automatic compaction should not retrigger before every subsequent model turn.
  • The next prompt should be able to reach the model.
  • Desktop could suspend automatic compaction until an explicit retry, provide an actionable resume control, or use another non-deadlocking preparation flow.

A blocking lifecycle hook should not make the task incapable of following the hook’s own instructions.

Additional information

The Desktop-trusted automatic test produced four completed diagnostic receipts with:

hook_event_name=PreCompact
trigger=auto
disposition=blocked

The blocked invocations occurred at approximately:

2026-08-03 04:26:20 UTC
2026-08-03 04:30:31 UTC
2026-08-03 04:31:44 UTC
2026-08-03 04:33:11 UTC

Each intervening user prompt was recorded as interrupted before a model response was generated.

One exact externally authorized invocation later produced:

trigger=auto
disposition=allowed
time=2026-08-03 04:42:44 UTC

The transcript then recorded:

New compacted window: 5
Compacted record: 2026-08-03 04:43:46.242 UTC
context_compacted event: 2026-08-03 04:43:46.290 UTC
Normal visible assistant response: 2026-08-03 04:44:00.427 UTC

The allowed diagnostic receipt identified this process chain:

ChatGPT.exe
  → bundled codex.exe
    → pwsh.exe

Captured versions:

About Codex version: 26.727.51351
Microsoft Store package observed in the process path: 26.727.6591.0
Bundled Codex runtime: 0.146.0-alpha.9.2
PowerShell: 7.6.3

The difference between the “About Codex” version and the Store package version may be normal versioning, but I am including both to avoid ambiguity.

The Desktop-trusted automatic path is confirmed. The equivalent Desktop-trusted manual path was not tested, so I am not claiming that trust origin is conclusively the sole cause of the earlier manual bypass.

The evidence indicates a possible cross-surface trust, hook-registration refresh, or cache-invalidation inconsistency. Suggested areas to inspect:

  • Whether CLI and Desktop share the same hook trust state.
  • Whether Desktop honors trust hashes written through the CLI.
  • Whether Desktop refreshes hook registration after external trust/configuration changes.
  • Why a hook can appear enabled while Desktop manual PreCompact bypasses it.
  • How pre-turn automatic compaction handles a blocking hook result.

I can provide sanitized diagnostic receipts and redacted transcript excerpts if needed. Full local transcripts, personal filesystem paths, and private project contents are intentionally omitted.

I searched for existing reports involving compaction loops, Desktop stalls, and PreCompact, but did not find this exact deterministic reproduction.

View original on GitHub ↗