Desktop app: context overflow can terminate a turn before any compaction runs, then reset status to '100% left (0 used / 760K)' and finish with no agent message

Resolved 💬 4 comments Opened Mar 6, 2026 by DMontgomery40 Closed Jun 29, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

Codex Desktop / app-backed session
cli_version: 0.108.0-alpha.12

What subscription do you have?

Pro

Which model were you using?

gpt-5.4

What platform is your computer?

macOS (Desktop app-backed session)

What issue are you seeing?

I hit:

Codex ran out of room in the model's context window. Start a new thread or clear earlier history before retrying.

But this does not appear to be the same failure mode as the existing remote compaction failures.

In my case, the turn appears to overflow before compaction runs at all:

  • the local session JSONL contains zero type:"compaction" events
  • immediately after the failure, the UI/status showed:
  • 100% left
  • 0 used / 760K
  • the turn then ended with task_complete and last_agent_message: null

So from the user side it looks like Codex both:

  1. says it ran out of context, and
  2. simultaneously says there is effectively a fresh / empty context window.

That combination is misleading and makes this look different from:

  • remote compaction failing with context_length_exceeded
  • compaction loops
  • post-compaction percentage display bugs

Why I think this is a distinct issue

Related issues I found:

  • #8190
  • #12468
  • #13271
  • #9800
  • #11440
  • #9417

Those are close, but this report is specifically about:

  • no compaction attempt being recorded at all
  • a silent task termination
  • a reset/misleading status readout after failure (100% left, 0 used / 760K)
  • likely a single oversized in-flight turn/tool payload that overflows before auto-compaction can trigger

What steps can reproduce the bug?

I do not have a minimal repro yet, but this happened in a fresh thread while the agent was doing web/doc lookups.

The pattern seems to be:

  1. Start a fresh thread in Codex Desktop
  2. Ask Codex to inspect/open multiple large docs/web pages and keep working in the same turn
  3. The turn eventually errors with the normal "ran out of room" message
  4. Instead of showing a compaction attempt/failure, the session:
  • records no compaction events
  • resets the visible status to 100% left (0 used / 760K)
  • ends with no last agent message

What is the expected behavior?

One of these should happen instead:

  • auto-compaction should run before the turn is terminated, or
  • Codex should surface a clear pre-compaction overflow error saying the current in-flight request was too large to compact, or
  • the UI should not reset to 100% left / 0 used immediately after a context overflow if that is not actually the usable state

Additional information

Affected session ID:

019cc407-9cbf-7f40-9586-1c5f12f5a7bf

Local session inspection found:

  • compaction_events = 0
  • final token/status events showing model_context_window = 760000
  • then a reset-like status event with 0 used / 760K
  • then task_complete with last_agent_message = null

This looks like:

pre-compaction turn overflow + misleading post-failure context status + silent task completion

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 5 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #12468
  • #12790
  • #13659

Powered by Codex Action

yassirusa · 4 months ago

When will this be worked on. Codex-5.3 and codex-5.3-spark are completely useless and they keep churning tokens without editing any code until they "run out of room"

mySebbe · 3 months ago

I have an additional related case from Windows/Codex Desktop. It is not an exact match to the original "zero compaction events" detail, because this rollout had earlier context_compacted events, but the tail failure has the same user-visible shape: turns complete successfully with last_agent_message: null and no assistant output.

Environment from local session_meta / turn_context:

originator: Codex Desktop
source: vscode
cli_version: 0.130.0-alpha.5
model: gpt-5.5
model_context_window: 258400
OS/shell: Windows / PowerShell
approval_policy: never
sandbox_policy.type: danger-full-access
session id: 019e0c01-a67f-7be1-ade2-0f0e9b8c92ad
rollout path shape: %USERPROFILE%\.codex\sessions\2026\05\09\rollout-2026-05-09T11-11-35-019e0c01-a67f-7be1-ade2-0f0e9b8c92ad.jsonl

Relevant tail sequence:

2026-05-16T22:36:51.131Z task_started turn_id=019e32ef-6747-7e12-b3f9-1105bbb29320
2026-05-16T22:36:51.345Z user_message "So machen wir weiter, wo genau hängt's?"
2026-05-16T22:36:51.874Z token_count last_token_usage={input_tokens:197455,cached_input_tokens:195968,output_tokens:112,reasoning_output_tokens:0,total_tokens:197567}, model_context_window=258400, rate_limit_reached_type=null
2026-05-16T22:36:51.946Z task_complete turn_id=019e32ef-6747-7e12-b3f9-1105bbb29320, duration_ms=814, last_agent_message=null
2026-05-16T22:38:21.589Z token_count last_token_usage={input_tokens:0,cached_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:207414}, model_context_window=258400, rate_limit_reached_type=null
2026-05-16T22:38:21.589Z thread_rolled_back num_turns=1
2026-05-16T22:38:22.021Z task_started turn_id=019e32f0-cb43-7573-8831-6506f8727b32
2026-05-16T22:38:22.035Z user_message "So machen wir weiter, wo genau hängt's?"
2026-05-16T22:38:22.813Z token_count last_token_usage={input_tokens:0,cached_input_tokens:0,output_tokens:0,reasoning_output_tokens:0,total_tokens:207414}, model_context_window=258400, rate_limit_reached_type=null
2026-05-16T22:38:22.890Z task_complete turn_id=019e32f0-cb43-7573-8831-6506f8727b32, duration_ms=869, last_agent_message=null

Other local checks:

rollout lines: 23538
context_compacted occurrences: 37
"out of room" / "context_length_exceeded" text: 0
task_started: 107
task_complete: 105
last_agent_message null: 16
unmatched earlier task_started turn_ids:
- 019e0d78-a154-7841-b3f2-ea0f0e52f97a
- 019e1350-1041-7a43-8fff-ba82a917af75

Notes:

  • Several earlier scheduled heartbeat turns also ended with last_agent_message: null; that might be expected for quiet heartbeats.
  • The important part here is that a normal user message at the end also ended twice with task_complete and no assistant message, once before and once after thread_rolled_back.
  • There was no tool call, tool output, stack trace, or rate-limit marker near the failure.

This looks like either a related context-accounting failure or a session lifecycle/replay issue where the app/core marks the turn complete even though no assistant item was produced.

etraut-openai contributor · 1 month ago

Thanks for reporting this problem. Until recently, Codex used a separate endpoint and server-side logic for compaction. We recently switched to a more robust approach where the compaction logic is moved locally using the same endpoint as normal turns. This eliminates "remote compaction" errors and increases the stability and reliability of compaction operations. If you see further problems with compaction, please use /feedback and open a new bug report.