Codex CLI freezes near auto-compaction threshold and drifts with very large context windows
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, possiblycontext
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:
- Near the context compaction threshold, Codex CLI can freeze hard during normal interactive work.
- 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:
- Run Codex CLI on Windows with a long interactive session.
- Accumulate substantial tool output, repository scans, log reads, or model/debug output.
- Continue working when
/statusshows low remaining context or token logs show input around 75-85% of the effective window. - Observe freezing or stalled progress near automatic compaction.
- Increase
model_context_windownear1000000. - 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_windowfrom1000000to400000. - Added local rules requiring agents to checkpoint and start a fresh session before compaction risk.
- Added a local
context-handoff-governanceskill 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
- Codex CLI docs: https://developers.openai.com/codex/cli
- Codex configuration reference: https://developers.openai.com/codex/config-reference
- Official Codex repository / issues: https://github.com/openai/codex/issues
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗