Codex CLI cannot reliably resume session

Open 💬 4 comments Opened Aug 9, 2026 by zipus
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

Codex CLI 0.147.0

What subscription do you have?

Pro

Which model were you using?

_No response_

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

_No response_

Codex doctor report

What issue are you seeing?

Codex CLI 0.147.0 cannot reliably resume session
019fe795-f21e-7583-a83d-06db6cc575a9.

Environment:

  • Linux Mint 22.1 x86_64
  • Model: gpt-5.6-sol
  • ChatGPT authentication
  • Region/Cloudflare edge: MAD

The session rollout is 20.4 MB. A single custom_tool_call_output is
19.3 MB and contains 8 inline base64 images.

On resume, Codex repeatedly:

  1. Disconnects WebSocket before response.completed.
  2. Falls back to HTTPS.
  3. Returns 503 Service Unavailable / remote connection failure.
  4. Sometimes returns 502 Bad Gateway.

This persisted for more than 30 minutes. New and smaller Codex sessions
work normally, and codex doctor reports HTTP reachability plus a
successful WebSocket handshake (HTTP 101).

Observed cf-ray values include:

  • a28860974e880390-MAD
  • a288664ee9f00775-MAD
  • a2886f36c90d0402-MAD
  • a2889a52ea660270-MAD
  • a288989a4f9c3eaf-MAD

Expected behavior:
Codex should compact, omit, or reference large image tool outputs when
resuming instead of resending enough inline image data to make the
session unusable.

What steps can reproduce the bug?

Uploaded thread: 019fe795-f21e-7583-a83d-06db6cc575a9

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

4 Comments

github-actions[bot] contributor · 18 days ago

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

  • #37694

Powered by Codex Action

shleder · 14 days ago

I’ve now shipped Codex Rescue 0.1.0a3 with regression coverage for this exact oversized persisted-output pattern. It detects oversized JSONL records locally, keeps the original rollout untouched, and fails closed with REVIEW_REQUIRED — it does not claim to fix the WebSocket/502/503 failure itself.

If you still have the affected session, would you be willing to try:

pipx install codex-rescue==0.1.0a3
codex-rescue doctor --latest

If it identifies the affected rollout, a sanitized doctor / salvage --fork / verify result would be very useful. Please don’t post the raw rollout, images, prompts, databases, or credentials.

https://github.com/shleder/codex-rescue

jdcodes1 · 9 days ago

Your 19.3 MB custom_tool_call_output is the whole story, and the mechanism is a byte-vs-token budget mismatch.

Rollout persists tool outputs verbatim — there is no byte cap at persist time — and resume rebuilds the model request from the full history, so every attempt re-sends ~20 MB of inline base64. Codex's context management is token-denominated: images are counted as patches/image tokens (core/src/image_preparation.rs#L29-L36 resizes by dimension/patch limits, not payload bytes), so the session can pass every token check while the serialized request body is far beyond what the gateway accepts. That's why you see the WebSocket drop before response.completed, the HTTPS fallback, and then 502/503 from the edge — and since these surface as generic stream failures, the retry loop just re-sends the same oversized body for 30+ minutes. Smaller sessions work because they're under the byte limit; codex doctor passes because the handshake is fine — only the request body is rejected.

Fix outline: (1) cap/externalize large tool outputs at persist time (store images as files, reference them); (2) add a serialized-request byte guard that triggers compaction or image dropping before send; (3) treat oversized-payload gateway rejections as terminal, not retryable.

shleder · 4 days ago

For the large rollout and inline payload case, please record whether Vetto fails closed on a budget or returns a bounded diagnostic rather than reading unbounded content.

Thanks for the detailed report. This is a good candidate for a bounded recovery check. Vetto 0.2.0-alpha.2 is available from npm and adds a read-only, copy-only Codex rescue adapter. It does not resume Codex, edit rollout files, or write vendor SQLite. On a disposable copy, try: npm install --global @shleddy/vetto@next; vetto rescue --adapter codex --root <CODEX_HOME> --json scan; then use the exact returned key with diagnose and snapshot ... --output ./vetto-recovery/session.jsonl. Please report OS, Codex/Vetto versions, sanitized JSON, and source SHA-256 before/after; never upload raw transcripts, auth/config, prompts, or tokens. An explicit unavailable/unsupported result is useful too.