codex - 💡(How to fix) Fix Codex CLI freezes near auto-compaction threshold and drifts with very large context windows [3 comments, 3 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#19116Fetched 2026-04-24 06:00:38
View on GitHub
Comments
3
Participants
3
Timeline
14
Reactions
0
Author
Timeline (top)
cross-referenced ×4labeled ×4commented ×3unlabeled ×2

Root Cause

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.

Fix Action

Fix / Workaround

Mitigation Tried Locally

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

Code Example

context_window: 272000
max_context_window: 1000000
effective_context_window_percent: 95

---

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

---

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
RAW_BUFFERClick to expand / collapse

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

extent analysis

TL;DR

Reducing the model_context_window and implementing a context handoff governance strategy may help mitigate the Codex CLI freezing and context drift issues.

Guidance

  • Review the model_context_window setting and consider reducing it to a value below 400000 to prevent context compaction threshold issues.
  • Implement a local rule to checkpoint and start a fresh session before compaction risk to minimize user impact.
  • Develop a context-handoff-governance skill to force external handoff for long-running Codex CLI work, ensuring the agent prioritizes the newest user instruction and current task state.
  • Monitor session logs and token counts to detect potential context drift and adjust the model_context_window setting accordingly.

Example

No code snippet is provided as the issue is related to configuration and runtime behavior.

Notes

The provided mitigations may not address the underlying runtime behavior, and further investigation into the Codex CLI and model configuration may be necessary to fully resolve the issue.

Recommendation

Apply the suggested workarounds, such as reducing the model_context_window and implementing a context handoff governance strategy, to mitigate the freezing and context drift issues. This approach can help minimize user impact while a more permanent solution is developed.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING