Context Compaction Hanging

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

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_

View original on GitHub ↗

26 Comments

github-actions[bot] contributor · 4 months ago

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

  • #14342
  • #14120
  • #14321
  • #14292
  • #12874

Powered by Codex Action

geokal · 4 months ago

same issue

Pimpmuckl · 4 months ago

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: https://github.com/Pimpmuckl/codex/commit/e8bd46565285849fa20a46e37e999c4890538978

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.

  1. 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
aemotyka · 4 months ago

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

rahenderson · 4 months ago

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

etraut-openai contributor · 4 months ago

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!

mhemmings contributor · 4 months ago

@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)

aemotyka · 4 months ago

@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!

rahenderson · 4 months ago

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 🚀

alandyc1994 · 4 months ago

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)

gvelesandro · 4 months ago

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

milankubin · 4 months ago
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.

Grallen · 4 months ago
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.

oneslash · 4 months ago

ID: 019cec56-3e12-7692-8911-4feb6b334546

I have it now on Codex App, happens a lot lately.

Subscription: Pro
Model: GPT-5.4
Effort: XHigh

EDIT: It finished, just now, it felt like it was stuck, for a long time.

Grallen · 4 months ago

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

timteh · 4 months ago

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

UserAvan · 3 months ago

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)

Grallen · 3 months ago

There is a good chance that this MacOS codex needs the same fix as I am trying to get applied for Linux. https://github.com/openai/codex/issues/14860#issuecomment-4089079621
Everyone please do what you can to get this attention as we already have the solution.

mazukabz · 3 months ago

Same issue here on macOS in VS Code Codex.

Symptoms:

  • auto-compact triggers
  • then fails with:

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

  • after the hang, the UI may lose the most recent visible part of the thread, but the missing turns are still present in local session JSONL under ~/.codex/sessions/...

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:

  • #16413

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.

alexman · 3 months ago

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

lasertiger · 3 months ago

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

infiloop2 · 2 months ago

same issue, happening consistently for all my threads today

AlexanderBich · 2 months ago

same issue, very annoying

mahdikayvan · 2 months ago

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

nos1609 · 1 month ago

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

etraut-openai contributor · 21 days 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.