Skip to content

Context Compaction Hanging #14346

Closed
Closed

Description

@RiddleMeThis3

What version of the IDE extension are you using?

latest

What subscription do you have?

Pro

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 25.2.0 arm64 arm

What issue are you seeing?

On 5.4, Extra High, the context window is filling up with one semi-large request. Then, whenever it goes to automatically compact, it hangs indefinitely.

What steps can reproduce the bug?

Create a chat on a relatively large codebase, make a request on a medium scale with Extra High Reasoning.

What is the expected behavior?

The context window will fill up before the request is handled, and fail to compact, simply hanging on "Automatically compacting context window"

Additional information

No response

Activity

  1. added
    extension
    on Mar 11, 2026
  2. geokal commented on Mar 11, 2026

    @geokal

    same issue

  3. JJLiebig commented on Mar 11, 2026

    @JJLiebig

    This does not appear to be extension-specific. I’ve now seen it in both the app and the TUI, so I dug into it locally after hitting it a few times over the last several hours.

    My hunch now is that there's two different issues at play:

    1. A mid-turn auto-compaction sequencing bug
      When a tool result is appended near the compaction threshold, Codex only checked auto-compaction after successful model responses using the previous usage snapshot. If the function_call_output itself pushed the next follow-up request over the limit, that follow-up could fail with context_length_exceeded before compaction ran. That path then stopped instead of compacting and retrying, which leaves the agent looking stuck.

      I tested a local patch for this in my fork:

      • treat “tool finished, follow-up still pending” as its own compaction checkpoint
      • preflight compact before the next follow-up request if needed
      • if the server still returns context_length_exceeded, compact and resume instead of bailing out

      Commit: JJLiebig@e8bd465

      Then I tested this and it still happened. I think it's still a useful fix for this edge case, so I'll keep it in my fork for now. But obviously there's another problem.

    2. Silent Compaction that hangs
      Even with the above patch already compiled in, I still hit the “Working...” stall again. In that later case, the thread sat there for some time, I CTRL-C'd out of it, restarted the TUI, egged it on again and nothing happened while my agent was collecting diagnostics and suddenly, about 15 minutes and then suddenly resumed with a Context compacted message and continued normally.

      That makes me think the more common issue here is a separate slow/silent compaction path, not just the post-tool context_length_exceeded bug above.

    Observed example:

    • Thread ID: 019cde72-5132-7a40-81e9-31dc0a19b4dd
    • behavior: appeared stuck on Working...
    • then, after roughly 15 minutes, it resumed on its own and started with a compaction message

    So conclusion is:

    • there is a rare edge case bug with mid-turn compaction
    • but the main issue behind this report seems to be a different bug where compaction can hang silently for a long time and only later complete, Took a first stab at fixing this but testing locally for now
  4. aemotyka commented on Mar 11, 2026

    @aemotyka

    Same issue. Have only encountered this on GPT5.4, but it happens regardless of the reasoning effort.

  5. rahenderson commented on Mar 11, 2026

    @rahenderson

    same issue, it's basically unusable like this. linux fedora silverblue 42.xx, pro account, 5.4 various levels

  6. etraut-openai commented on Mar 11, 2026

    @etraut-openai
    Contributor

    If you're seeing this, could you please use /feedback to upload your logs and session details, then post the thread ID here? That will help us investigate. Thanks!

  7. mhemmings commented on Mar 11, 2026

    @mhemmings
    Contributor

    @etraut-openai Here's one example 019cde75-630c-78d0-9302-63aa9ca632de (This chat is a bit messy, I had to stop, quit, reopen, switch models, and anything I could to get it into a responsive state)

  8. aemotyka commented on Mar 11, 2026

    @aemotyka

    @etraut-openai

    019cde5f-c559-7440-add6-6a4513296fd6

    Note that I did change models during the conversation. Maybe that has something to do with it?

    Thank you!

  9. rahenderson commented on Mar 12, 2026

    @rahenderson

    seems like the issue either improved throughout the day or it is/was mostly confined to VScode. 2 sessions have been running more or less constantly for the last few hours 🚀

  10. alandyc8888 commented on Mar 12, 2026

    @alandyc8888

    Hitting this issue in my session today. and cannot get out of it even after close the session and resume it.
    ■ Error running remote compact task: stream disconnected before completion: error sending request for url
    (https://chatgpt.com/backend-api/codex/responses/compact)

  11. gvelesandro commented on Mar 12, 2026

    @gvelesandro

    @RiddleMeThis3 I run Agents Need Context and I'm researching one specific failure mode: compaction doesn't just fail technically, it breaks task continuity mid-run.

    This thread is a strong example because the session looks alive while the state handoff silently stalls. If you're open to it, I'd value a short written postmortem here: https://www.agentsneedcontext.com/agent-failure-postmortem

    Most useful detail: what the agent was in the middle of, what context needed to survive compaction, what recovery steps you tried, and what the hang cost. No pitch, just research.

  12. milankubin commented on Mar 13, 2026

    @milankubin

    Hitting this issue in my session today. and cannot get out of it even after close the session and resume it. ■ Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

    Concur.
    Today was fine, yesterday it was persistent hanging, and recovery a dice-roll.
    Only thing that reliably worked was switching to Codex 5.3 to get it unstuck.

  13. Grallen commented on Mar 13, 2026

    @Grallen

    If you're seeing this, could you please use /feedback to upload your logs and session details, then post the thread ID here? That will help us investigate. Thanks!

    ID 019ce575-d283-7962-9bea-6575adf2115a

    It's working for 2m34s then does the error "Error running remote compact task: timeout waiting for child process to exit"
    Reproduced a least a few times in the log.

  14. 1 remaining item

  15. Grallen commented on Mar 14, 2026

    @Grallen

    I switched models from 5.4 to 5.3-codex (medium) and the compact passed (on the context that 5.4 filled).

  16. timteh commented on Mar 17, 2026

    @timteh

    If part of the performance issue is related to waiting for manual approvals that stall the pipeline, I built Antigravity Autopilot — OS Level — auto-clicks Accept/Run/Continue/Allow buttons at the OS level using Windows UI Automation.

    No CDP, works across VS Code, Cursor, Windsurf, Antigravity. Helps keep long agent sessions flowing without constant manual intervention.

    GitHub: https://github.com/timteh/antigravity-autopilot

  17. UserAvan commented on Mar 23, 2026

    @UserAvan

    Error running remote compact task: stream disconnected before completion

    What happened
    A remote compact task was started, but the stream disconnected before completion. The request appears to fail while sending or maintaining the connection to: https://chatgpt.com/backend-api/codex/responses/compact

    Expected behavior
    The remote compact task should complete successfully, or at minimum return a clearer actionable error and retry behavior.

    Actual behavior
    The task aborts with:
    ■ Error running remote compact task: stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses/compact)

  18. Grallen commented on Mar 23, 2026

    @Grallen

    There is a good chance that this MacOS codex needs the same fix as I am trying to get applied for Linux. #14860 (comment)
    Everyone please do what you can to get this attention as we already have the solution.

  19. mazukabz commented on Apr 1, 2026

    @mazukabz

    Same issue here on macOS in VS Code Codex.

    Symptoms:

    This suggests the compact failure is sometimes followed by a thread restore/history rendering problem, not only a compaction failure.

    Related bug I filed for the UI/history-loss side:

    Environment:

    • platform: macOS
    • surface: VS Code Codex
    • model/reasoning: happened in long-running thread; high reasoning made it easier to reproduce
    • local evidence: ~/.codex/sessions/...jsonl and ~/Library/Logs/com.openai.codex/...

    Happy to provide exact session/log snippets if useful.

  20. alexman commented on Apr 15, 2026

    @alexman

    same issue ...
    feedback uploaded as existing open issue: 019d8d76-9f84-7c72-8e47-36835cdfc651

  21. lasertiger commented on Apr 22, 2026

    @lasertiger

    019db1fd-7d09-7370-bea2-7e518769131e for what it is worth. every session today just froze and broke so you ruined my day folks.

  22. infiloop2 commented on Apr 22, 2026

    @infiloop2

    same issue, happening consistently for all my threads today

  23. AlexanderBich commented on Apr 23, 2026

    @AlexanderBich

    same issue, very annoying

  24. mahdikayvan commented on May 10, 2026

    @mahdikayvan

    @RiddleMeThis3 Hey — this issue felt painfully familiar. It is very close to the trust/drift problem I’m trying to solve.

    I’m building AgaveCore, and I’d like to let a few early people use it for free while I shape it into something stronger.

    It helps when a coding agent starts to drift, loses important context, or gives you an output you do not fully trust.

    In practice, it works through two habits:

    • tell the agent to remember-progress or remember-this when something important should not be lost
    • use consult-brain when the current task needs more grounded feedback on what to do next

    Over time, as useful journals, decisions, and failures pile up, the product should help the agent make sharper decisions and take better actions with less drift.

    If this sounds relevant, reply here and I’ll send the exact steps. You can also use the email or Telegram on my profile.

    Cheers,
    Mads.

  25. added
    bug
    context
    on May 14, 2026
  26. nos1609 commented on May 27, 2026

    @nos1609

    caught same issue - 10 minutes+ "Compacting" in thread 019e6323-0edb-73d3-a73d-1d1a35c1fa52

  27. 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.

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

    bugcontextextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions