codex resume can OOM on very large local session JSONL
Codex CLI Issue: resume of very large local session needs excessive RAM/swap
Status: reported upstream after this run.
Summary
codex resume <session_id> can require an extremely large transient amount of
RAM/swap when the local session JSONL is very large. In this workstation, a
long-running production migration session caused the CLI process to be killed
by the OS unless roughly 80 GiB of swap was temporarily available. After the
session loads, memory usage stabilizes, which suggests the peak occurs during
resume/parsing/indexing rather than during normal interaction.
Environment
- Codex CLI:
codex-cli 0.139.0 - OS: Linux workstation
- Local Codex data size:
86Gunder~/.codex - Largest local session files observed:
37,776,204,485bytes17,861,589,428bytes17,657,202,793bytes17,657,089,210bytes
Actual Behavior
Resuming the long session creates a large transient memory spike. If the
machine does not have enough RAM/swap, the OS kills the Codex CLI process. The
user then needs to add a very large swap file only to resume the session.
Expected Behavior
- Resume should stream or lazily index large session files instead of loading
enough data to create a large memory spike.
- If the session is too large to resume safely, the CLI should fail early with
an actionable message.
- The CLI should offer a supported way to compact, prune, archive, split, or
export a handoff from a large session before it becomes unresumable.
Reproduction Shape
- Work in a single Codex session for multiple days.
- Let the session JSONL grow to tens of GiB.
- Run
codex resume <session_id>on a workstation without very large swap. - Observe process termination by the OS during resume.
Current Workaround
For this repository, operational continuity is now moved into versioned runbooks
and control files so a new session can start from files instead of depending on
resuming a huge transcript. This avoids project risk, but it does not solve the
CLI resume behavior.
Requested Improvement
Add one or more of:
- lazy/streaming resume for large local JSONL sessions;
- a persistent session compaction or split command;
- a size warning before resume;
- a supported handoff export that lets users start a clean session without
losing the important operational context.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗