Codex CLI freezes near auto-compaction threshold and drifts with very large context windows

Resolved 💬 3 comments Opened Apr 23, 2026 by huanxxxx Closed Apr 23, 2026

Codex CLI Context Freeze / Context Drift Report

Date: 2026-04-23

Suggested Title

Codex CLI freezes near auto-compaction threshold and may drift to earlier turns with very large context windows

Product Area

  • Product: Codex CLI
  • Labels likely relevant on openai/codex: bug, CLI, agent, windows-os, possibly context

Environment

  • OS: Windows, native PowerShell environment
  • Codex CLI version: codex-cli 0.122.0
  • Codex latest version cache: 0.122.0
  • Model: gpt-5.4
  • Reasoning: high
  • Collaboration mode: Default
  • Permissions: Full Access / danger-full-access
  • Session id with observed near-limit behavior: 019db918-157d-7c82-ad0a-ae7d7d62a592

Local Model Catalog Evidence

codex debug models reports for gpt-5.4:

context_window: 272000
max_context_window: 1000000
effective_context_window_percent: 95

This matches the observed /status effective window around 258400.

Symptoms

Two related long-context failure modes have been observed repeatedly:

  1. Near the context compaction threshold, Codex CLI can freeze hard during normal interactive work.
  2. With a manually enlarged context window near 1000000, the session may avoid early compaction but can experience context drift: the assistant suddenly responds to an earlier turn or older task state instead of the latest user instruction.

The second behavior feels like the model or runtime is over-weighting older context after a large window is enabled. The user-facing outcome is worse than a missing-summary problem because the agent appears to continue working, but on a stale thread of intent.

Evidence From Local Session Log

Source log:

C:\Users\Administrator\.codex\sessions\2026\04\23\rollout-2026-04-23T14-47-36-019db918-157d-7c82-ad0a-ae7d7d62a592.jsonl

Relevant token-count tail:

timestamp             last_input   total      window
2026-04-23 08:39:08   204040       14017502   258400
2026-04-23 08:39:17   204249       14221938   258400
2026-04-23 08:39:24   204586       14426674   258400
2026-04-23 08:39:58   204586       14426674   258400
2026-04-23 08:40:19   204752       14632324   258400
2026-04-23 08:42:17   204752       14632324   258400
2026-04-23 08:42:41   207047       14840141   258400
2026-04-23 08:42:52   209512       15049769   258400
2026-04-23 08:43:21   210155       15260977   258400
2026-04-23 08:46:31   210155       15260977   258400
2026-04-23 08:46:46   209622       15471074   258400
2026-04-23 08:46:57   211057       15682313   258400

The session was already around 79-82% of the effective context window, then continued to run large diagnostic/model/search commands. The turn was later manually interrupted after becoming unproductive.

Reproduction Pattern

This is not a deterministic one-command reproduction, but it appears with this pattern:

  1. Run Codex CLI on Windows with a long interactive session.
  2. Accumulate substantial tool output, repository scans, log reads, or model/debug output.
  3. Continue working when /status shows low remaining context or token logs show input around 75-85% of the effective window.
  4. Observe freezing or stalled progress near automatic compaction.
  5. Increase model_context_window near 1000000.
  6. In later long sessions, observe context drift where the assistant answers an earlier turn or continues an older task state instead of the newest user request.

Expected Behavior

  • Near context threshold, the CLI should compact predictably or ask for a safe handoff without freezing.
  • With a larger context window, the agent should continue prioritizing the newest user instruction and current task state.
  • If stale-context conflict is detected, the runtime should bias toward the latest user turn and current tool state.

Actual Behavior

  • Near compaction threshold, the session can freeze hard enough that the user must interrupt or abandon the session.
  • With very large context enabled, old instructions or older task state can appear to regain priority, causing context drift.

Privacy / Redaction Notes

  • Do not attach full session logs without redaction. They may contain repository paths, prompts, code, tool outputs, and account-specific data.
  • The evidence above intentionally includes only version, config-level context data, token counts, session id, and a high-level behavior summary.

Mitigation Tried Locally

  • Reduced model_context_window from 1000000 to 400000.
  • Added local rules requiring agents to checkpoint and start a fresh session before compaction risk.
  • Added a local context-handoff-governance skill to force external handoff for long-running Codex CLI work.

These mitigations reduce user impact but do not address the underlying runtime behavior.

Official References

View original on GitHub ↗

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