Skip to content

Codex app /compact fails with context_length_exceeded after UI says “Context compacted” #23589

Closed

Description

@yazan-albaiz

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

26.513.31313 (2867)

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

Product / component:
Codex desktop/app, thread compaction, /compact, remote /responses/compact task

Model:
GPT-5.5 Extra High

Severity:
High. Long-running Codex thread becomes unable to compact, risking loss of working context and making it difficult to continue work.

Summary:
When running /compact in a long Codex thread, the UI first reports “Context compacted”, but then the remote compact task fails with context_length_exceeded. No successful new compact record appears to be written after the failure.

Actual behavior:
The app shows:

Context compacted

Then reports:

Error running remote compact task:
{
"error": {
"message": "Your input exceeds the context window of this model. Please adjust your input and try again.",
"type": "invalid_request_error",
"param": "input",
"code": "context_length_exceeded"
}
}

Local evidence:
The local session JSONL still exists and appears intact.

Observed local metrics around the failed compaction:

estimated_tokens_of_items_added_since_last_successful_api_response=245649
estimated_bytes_of_items_added_since_last_successful_api_response=982594
model_context_window_tokens=258400
failing_compaction_request_model_visible_bytes=1424086
compact_error=context_length_exceeded

There was also a very large recent user message of roughly 601,418 characters, which appears duplicated in the event log. The compaction payload appears to be near the model context window before adding compactor/system overhead, then exceeds the limit once the remote compact request is assembled.

Expected behavior:
Codex /compact should not send a compaction request that exceeds the target model’s context window after overhead is added.

Expected alternatives:

  • Chunk or recursively compact oversized histories.
  • Prune or summarize very large recent event payloads before sending to /responses/compact.
  • Trigger compaction earlier before the thread reaches an unrecoverable size.
  • Fail before showing “Context compacted” if the remote compact task did not actually complete.
  • Provide a recovery path for oversized threads, such as “compact last N turns”, “compact excluding tool/event duplicates”, or “create handoff summary from local session.”

Impact:
The user cannot compact or continue a high-context Codex thread normally. The thread contains important work context, and the failure mode is confusing because the UI initially says compaction succeeded.

What steps can reproduce the bug?

  • Session ID: 019e2c54-f2a2-79b2-ab82-cfa092dca614
  • Compact turn ID: 019e42d3-7176-7990-bbbd-6e6d277be883
  • Request ID: 5dcf980d-43ee-4bc6-98ab-b140ff6585f8

What is the expected behavior?

Codex /compact should not send a compaction request that exceeds the target model’s context window after overhead is added.

Additional information

This was initially noticed around the May 20th OpenAI API incident affecting GPT-5.4/GPT-5.5 https://status.openai.com/incidents/01KS19AHSEE3DAX1HHKNQB166F , but subsequent checks showed the status page had returned to operational. The later failure appears deterministic and tied to context length rather than a transient outage.

Activity

  1. added
    app
    on May 20, 2026
  2. added
    bug
    context
    on May 20, 2026
  3. github-actions commented on May 20, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. gomdobi commented on May 22, 2026

    @gomdobi

    I hit the same class of failure on Codex desktop app 26.519.31651 (CFBundleVersion 3017), macOS 26.5 (Build 25F71), arm64.

    In my case this was triggered by automatic context compaction rather than a user-submitted oversized message. The thread displayed multiple automatic compaction markers, each followed by:

    Error running remote compact task: { "error": { "message": "Your input exceeds the context window of this model. Please adjust your input and try again.", "type": "invalid_request_error", "param": "input", "code": "context_length_exceeded" } }
    

    I opened #24014 before seeing this duplicate. The extra detail from my case is that the user-facing remaining-context state was not actionable: the app-generated compact payload itself appears to exceed the model context window, so the user cannot recover from within the same thread.

  5. zzzjasdawd commented on May 24, 2026

    @zzzjasdawd

    How to downgrade the codex Windows application

  6. etraut-openai commented on Jun 29, 2026

    @etraut-openai
    Contributor

    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.

  7. mmtmn commented on Aug 19, 2026

    @mmtmn

    @etraut-openai On a project I'm working another developer is experiencing this issue, I told him to use the /feedback and I' ve sent him the link to this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugcontext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions