Skip to content

Codex app automatic context compaction fails with context_length_exceeded #24014

Closed as duplicate

Description

@gomdobi

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

26.519.31651 (CFBundleVersion 3017)

What subscription do you have?

Not included in this public report.

Which model were you using?

GPT-5 Codex in the Codex desktop app.

What platform is your computer?

macOS 26.5 (Build 25F71), arm64

What issue are you seeing?

The Codex desktop app repeatedly attempted automatic thread/context compaction, but every automatic compact attempt failed with context_length_exceeded.

The error shown in the thread was:

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" } }

This was not caused by a user-submitted oversized message. It was triggered by the app's automatic context compaction flow. The UI showed multiple automatic compaction markers, each followed by the same remote compact task error.

What steps can reproduce the bug?

  1. Work in a long Codex desktop app thread until automatic context compaction is triggered.
  2. Let Codex attempt automatic context compaction.
  3. Observe that the app-generated remote compact request fails with context_length_exceeded.
  4. The app retries/marks compaction again, but the same failure repeats.

What is the expected behavior?

Automatic compaction should safely chunk, trim, or progressively summarize the thread so the compact request itself never exceeds the target model's context window. The user should be able to continue work after compaction.

What is the actual behavior?

The automatic compact task appears to build an internal compact request that is too large for the model context window, causing context_length_exceeded. Work in the thread is effectively blocked because the app cannot complete automatic compaction.

Additional information

The UI's remaining-context indicator did not make this failure actionable for the user. The user did not submit a large message at the time of failure; the oversized input was the app-generated compact payload.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    contextIssues related to context management (including compaction)
    on May 22, 2026
  2. gomdobi commented on May 22, 2026

    @gomdobi
    Author

    I am leaving this issue open for now rather than closing it as a duplicate, because the current user-facing problem is not only that compaction fails, but that there is no in-thread recovery path after the automatic compact task repeatedly fails.

    The practical impact is that ongoing work is blocked even though the failure was caused by the app-generated compact payload, not by a user-submitted oversized message.

    If this is the same root cause as #23589, the needed resolution should still include a user recovery path, for example safe chunked/progressive compaction, a fallback handoff summary, or another way to continue the thread without requiring the user to manually reconstruct context.

  3. d1sc0v3r commented on May 22, 2026

    @d1sc0v3r

    I can confirm the same failure mode on Windows Codex Desktop as well.

    In my case two existing local threads hit the same error during automatic compaction:

    • thread A: 681 messages, exported markdown around 536 KB
    • thread B: 898 messages, exported markdown around 852 KB

    The user prompt itself was small, but Codex Desktop attempted an automatic remote compact task and failed with:

    context_length_exceeded

    After that, continuing the original thread was effectively blocked. The local thread data was still present and exportable, so this was not data loss, but the app had no usable recovery path inside the same thread.

    The practical workaround was to archive the overloaded thread as source/old and create a new continuation thread with a short handoff prompt plus links to the old thread/export. That works, but it is manual and error-prone.

    So I agree this needs a fallback path: chunked/progressive compaction, a smaller emergency summary, or a safe “continue in new thread from generated brief” flow when automatic compaction cannot fit into the model context.

  4. kpin108 commented on May 22, 2026

    @kpin108

    Same issue on Linux. connected with Context Length Exceeded issue, both triggered by compact. most recent version. never seen before. started to trigger today in different CLI sessions. nothing helps

  5. zalataraglados-prog commented on May 23, 2026

    @zalataraglados-prog

    I’m seeing what appears to be the same issue in the Codex VS Code / IDE sidebar on Windows.

    Environment:

    • Subscription: Plus
    • IDE: VS Code
    • Platform: Windows
    • Mode shown in UI: Local mode
    • Provider shown in UI: openai
    • Model shown in UI: 5.3-Codex
    • Permission mode: full access
    Image

    Observed UI state:

    上下文已自动压缩
    
    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"
      }
    }
    
  6. gomdobi commented on Jun 8, 2026

    @gomdobi
    Author

    Update as of 2026-06-08: I am currently on Codex 26.602.40724 (Released Jun 6, 2026). Since updating to this build, I have not seen the automatic context compaction failure recur in normal use so far.

    I am leaving this issue open for now rather than closing it because I have not seen a maintainer-confirmed fix, a linked closing PR, or documented recovery behavior for already-stuck threads. If maintainers consider this covered by a specific fix/release or want this closed as a duplicate, please point me to the canonical issue/PR and I can close or update accordingly.

  7. ax-openai commented on Jun 12, 2026

    @ax-openai

    Closing as a duplicate of #23589.

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

    appIssues related to the Codex desktop appbugSomething isn't workingcontextIssues related to context management (including compaction)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions