Skip to content

codex resume can OOM on very large local session JSONL #28866

Open

Description

@jselvareef

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: 86G under ~/.codex
  • Largest local session files observed:
    • 37,776,204,485 bytes
    • 17,861,589,428 bytes
    • 17,657,202,793 bytes
    • 17,657,089,210 bytes

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

  1. Work in a single Codex session for multiple days.
  2. Let the session JSONL grow to tens of GiB.
  3. Run codex resume <session_id> on a workstation without very large swap.
  4. 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.

Activity

  1. added
    bug
    CLI
    session
    on Jun 18, 2026
  2. jselvareef commented on Jun 18, 2026

    @jselvareef
    Author

    I reviewed the duplicate candidates from the bot:

    This report is specifically about the local CLI codex resume <session_id> path on Linux exhausting memory while hydrating a very large preserved session. The observed workaround is adding a very large swap file just for the initial resume spike; after hydration, memory stabilizes. That points to an unbounded eager load/materialization issue in the resume path, even without using the Desktop surface.

    I am keeping this open unless maintainers prefer consolidating CLI resume memory behavior under one of the Desktop/session JSONL issues.

  3. Necmttn commented on Jun 21, 2026

    @Necmttn

    A useful closeout test would separate "resume enough to continue" from "hydrate the whole JSONL into memory."

    For very large rollouts, the resume path can build a lightweight index first: session_meta, compaction boundaries, latest user/assistant turns, tool-call ids, byte offsets, and token/count metadata. Large bodies such as base64 images, huge tool outputs, and old function outputs can stay as offset-addressed records until the UI/model actually needs them.

    I would expect three behaviors:

    • early warning before trying to resume a file over a size threshold, with a suggested compact/export command;
    • bounded memory fixture against a synthetic huge JSONL that includes long lines and large payload fields;
    • a supported handoff/export path that preserves the latest task state and source pointers without copying every historical body into context.

    That would also make this distinct from the Desktop image-heavy issues: the CLI resume invariant is "stream/index first, materialize bodies lazily."


    Generated with ax.

  4. boombx403-byte commented on Aug 18, 2026

    @boombx403-byte

    Hi @jselvareef, that rollout size is valuable stress evidence. Codex Rescue Alpha5 scans large local session histories with bounded memory and produces aggregate size, media, and compaction diagnostics without loading the whole file into RAM or dumping full payloads.

    If you still have an affected closed rollout, you can test it locally:

    pip install codex-rescue==0.1.0a5
    codex-rescue doctor <path-to-rollout.jsonl>

    No raw session upload is needed; sanitized aggregate output is sufficient.

  5. mekineer-com commented on Sep 22, 2026

    @mekineer-com

    I built a small tool for this exact failure mode: Session Survivor. It keeps the useful chat/recent native tail, strips old bulky tool output/reasoning/compaction baggage, and can fold older dialogue into summaries so the same Codex thread stays resumable.

    https://github.com/mekineer-com/session-survivor

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

    CLIbugperformancesession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions