codex - 💡(How to fix) Fix Add a recovery option to start a new session from previous context after repeated compact failures [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#21288Fetched 2026-05-06 06:23:48
View on GitHub
Comments
2
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Error Message

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

Fix Action

Fix / Workaround

In my case, automatic compaction failed, retries failed, and manual compaction also failed. The practical workaround was to start a new Codex session and explain the previous context manually.

  • #17392: remote compaction fails with stream disconnected before completion
  • #19558: remote compaction fails and leaves thread unusable
  • #19979: remote compact task times out and the session becomes unusable
  • #8256: resume fails for specific sessions; manual copying context to a new session works as workaround
  • #18884: asks for a manual /recap command
  • #11750 / #17568: related session forking capability
RAW_BUFFERClick to expand / collapse

What variant of Codex are you using?

CLI

What feature would you like to see?

When automatic or manual context compaction fails repeatedly, Codex would better offer a first-class recovery option:

Compaction failed repeatedly. Start a new session with recovered context from this session?

The new session should be initialized from the previous session's persisted history/context, instead of requiring the user to manually open a new session and explain what happened.

Suggested flow:

  1. Keep the original failed session unchanged.
  2. Create a new session or fork from the old session.
  3. Build a recovery context from the old session, including:
    • original user goal
    • latest user instruction
    • current workspace/cwd
    • repo/branch if available
    • files inspected or changed
    • commands/tests already run
    • completed work
    • pending tasks/blockers
    • important constraints from the conversation
  4. Insert that recovery context into the new session.
  5. Let the user continue from the latest pending task.

This should avoid relying on the same failing remote compact path if possible. If the full history cannot be replayed, Codex could create a smaller recovery package from recent turns plus local session metadata.

Additional information

This is motivated by repeated failures like:

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

In my case, automatic compaction failed, retries failed, and manual compaction also failed. The practical workaround was to start a new Codex session and explain the previous context manually.

Related issues:

  • #17392: remote compaction fails with stream disconnected before completion
  • #19558: remote compaction fails and leaves thread unusable
  • #19979: remote compact task times out and the session becomes unusable
  • #8256: resume fails for specific sessions; manual copying context to a new session works as workaround
  • #18884: asks for a manual /recap command
  • #11750 / #17568: related session forking capability

This request is not just another compact failure bug report. It is specifically about the recovery UX after compaction has already failed repeatedly.

Expected behavior:

When Codex cannot compact a long-running session, it should not strand the user. It should provide an explicit recovery path to continue in a new session with enough reconstructed context to avoid starting over.

extent analysis

TL;DR

Implement a recovery option that creates a new session with reconstructed context when compaction fails repeatedly.

Guidance

  • Identify the specific points of failure in the compaction process to determine the best approach for recovery.
  • Consider implementing a session forking mechanism to create a new session with the reconstructed context, including user goal, latest instruction, and workspace information.
  • Develop a recovery context package that includes recent turns, local session metadata, and important constraints from the conversation to facilitate a smoother recovery process.
  • Ensure the new session is initialized with the recovered context, allowing the user to continue from the latest pending task without having to manually recreate the context.

Example

A potential implementation could involve creating a recover_session function that takes the failed session's context and creates a new session with the reconstructed context, using a similar flow to the suggested recovery option.

Notes

The implementation details may vary depending on the specific requirements and constraints of the Codex system, and it may be necessary to consult the related issues (#17392, #19558, #19979, #8256, #18884, #11750, #17568) for additional context and insights.

Recommendation

Apply a workaround by implementing a recovery option that creates a new session with reconstructed context when compaction fails repeatedly, as this approach addresses the specific pain point of users being stranded after repeated compaction failures.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Add a recovery option to start a new session from previous context after repeated compact failures [2 comments, 2 participants]