Repository navigation
~/.codex grew to 42 GB (28.6 GB in a single month): compaction re-embeds the full replacement_history in rollout JSONL, and archived sessions are never cleaned up #41806
Description
What version of Codex are you running?
- Codex Desktop: 26.826.12353
- codex-cli: 0.149.1
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5.6-sol
What platform is your computer?
macOS (Apple Silicon, M4 Pro, arm64)
Summary
Between 2026-04-21 and 2026-08-31, ~/.codex grew to ~42 GB across multiple workspaces/sessions, with occasional subagent usage. Usage was heavily back-loaded: the first file dates to 2026-04-21, but 98.8% of the archived volume was produced in August 2026 alone (see timeline below). Almost all of it is rollout session logs:
| Directory | Size | Notes |
|---|---|---|
archived_sessions/ |
28 GB | Largest contributor; focus of this report |
sessions/ |
11 GB | Active sessions; same bloat pattern |
| All other 30+ directories | ~500 MB combined | Normal |
Archived rollouts are never cleaned up, compressed, or pruned, and the per-file analysis below shows the logging itself is unbounded.
Details: archived_sessions/
- 1,145
rollout-*.jsonlfiles stored flat — no subdirectory layout, no sign of any retention policy. - 82 files exceed 100 MB, totaling ~23 GB — 82% of the directory.
- Largest single file: 1.2 GB; plus 4 files around 1 GB each and several in the 300–900 MB range.
- Growth is continuous within the active period, not a one-off spike: on Aug 30 alone, 190 new files were added; on Jul 29, multiple active files in
sessions/each reached 210–270 MB.
Timeline: the volume arrived in one month
File dates span 2026-04-21 → 2026-08-31, but those are only the two extreme endpoints — there are long empty gaps in between:
| Period | Files | Size | Notes |
|---|---|---|---|
| 2026-04-21 | 1 | 43 KB | isolated single file |
| 04-22 → 06-07 | 0 | — | completely empty, ~7 weeks |
| 2026-06-08 | 1 | 78 KB | another isolated file |
| 06-09 → 07-13 | 0 | — | completely empty, ~5 weeks |
| 2026-07-14 → 07-28 | 47 | 30.7 MB | sporadic use (07-25 → 07-27 and 07-29 → 08-02 also empty) |
| 2026-08-01 → 08-31 | 1,096 | 28.6 GB | the real usage period — 98.8% of the total volume |
So this is not slow accumulation over 4 months: it is ~28.6 GB of rollout logs produced in a single month of active use.
Root cause analysis (inside the 1.2 GB file)
The largest file contains 70,902 lines. Its size is dominated by two behaviors:
1. Every compacted event re-serializes the entire conversation history
- The file contains 139
"type":"compacted"records; those 139 lines alone occupy ~794 MB (≈66% of the file). - Each compaction writes the full
replacement_history— the complete conversation, including ~25,000 messages and 1,100+input_imageitems — inline as a single JSON line. The largest single line observed is 13 MB. - Since the history already contains all previous content, every additional compaction rewrites an ever-larger snapshot of the same data. Bytes written to disk grow roughly quadratically with the number of compactions in a long-lived session.
2. Large payloads (base64 images, big tool outputs) are never truncated
- 123 lines exceed 1 MB, dominated by screenshots (
input_image, stored as full base64) and large tool outputs (e.g. big file reads), written verbatim with no size cap. - Combined with (1), each such payload is then re-embedded in every subsequent compaction snapshot, multiplying its footprint.
Impact
- Disk fills up quickly with no user-visible warning: ~28.6 GB of archived rollout logs in one month of active use.
- The archive behaves as an append-only, unbounded store; nothing is ever reclaimed.
- Any tool that scans, copies, backs up, or migrates
~/.codexmust process multi-MB single JSON lines (13 MB max observed).
Relationship to existing issues
This is an independent real-world dataset confirming the same underlying mechanisms reported in:
- Subagent spawns duplicate the full parent session history into each child rollout file (quadratic disk growth) #36557 / Codex Desktop subagent session logs grow to 145GiB from repeated compacted replacement_history #31198 / Codex Desktop 26.810: repeated compacted image snapshots grow rollout to 16.9 GB and app-server to 19.5 GB #39013 — compaction repeatedly rewrites the full
replacement_history/ image snapshots (those reports emphasize subagent fan-out or specific Desktop builds; here the dominant factor is repeated compaction in long-lived sessions across multiple workspaces, with only occasional subagent use). - Local compaction v2 retains unbounded input_image payloads, causing repeated auto-compaction #33493 — compaction retains unbounded
input_imagepayloads. - Rollout JSONL grew to 98 GB from inline Base64 PNG payloads #40111 / Bug Report: Rollout Log Size Explosion from Unbounded Base64 Image Data #32128 — inline base64 image payloads stored verbatim in rollout JSONL.
- Archived session storage should fail fast and support deep archive/cold storage #28868 / Subagent fork sessions persist large JSONL histories indefinitely, causing severe ~/.codex disk bloat #30779 / Desktop: provide supported external/cold archive storage before local rollout history exhausts disk #37216 — archived session storage has no size bound, no fail-fast, and no cleanup/cold-archive path.
Suggested fixes
- Don't re-embed full history on compaction. Store compaction output as a reference/delta (or deduplicate history segments by content hash) instead of serializing the entire
replacement_historyinto everycompactedrecord. - Cap or externalize large payloads. Truncate, hash, or spill base64 images and oversized tool outputs to side storage instead of inlining multi-MB blobs in the rollout stream.
- Add a retention policy for
archived_sessions/— age/size caps, compression (e.g. zstd), and/or a supported command to prune/compact local session storage. - Warn the user when
~/.codexcrosses a size threshold.
Workaround
None built in; the only mitigation is manually deleting old rollout-*.jsonl files, presumably at the cost of losing resume/archive history.
Activity
github-actions commentedon Aug 31, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
[-]`~/.codex` grew to 42 GB in ~4 months: compaction re-embeds the full `replacement_history` in rollout JSONL, and archived sessions are never cleaned up[/-][+]`~/.codex` grew to 42 GB (28.6 GB in a single month): compaction re-embeds the full `replacement_history` in rollout JSONL, and archived sessions are never cleaned up[/+]ariccio commentedon Sep 4, 2026
Disclosure: This comment was generated by Codex, operating fully autonomously in the research and drafting of this comment. GitHub attributes it to the authenticated
ariccioaccount, but Alexander Riccio is not the speaker or author of the technical claims below. His role in this publication is to provide the quoted prompts, choose the publication scope, and explicitly approve the exact text after preview.Verbatim user prompts and publication context
Prompt that initiated this issue census and comment drafting:
Additional public-safe context from the work that prompted this review:
Publication context: These excerpts came from a separate attempt to recover disk space safely while preserving valuable Codex history. Alexander asked Codex to map a fragmented public issue cluster against the pull request’s shipped scope because storage growth was obstructing active development and a safe resolution remained elusive. The quotations record Alexander’s motivation and impact; Codex independently researched and authored each target-specific technical comparison.
Publication control: this exact body was previewed and must be explicitly approved before publication. The technical wording must not be attributed to Alexander.
The archived-rollout compression part of this report now has a direct partial implementation in #42039, shipped in 0.153.0. When the experimental default-off feature is enabled, cold archived rollouts—including shared and forked histories—are eligible for zstd compression, and the PR tests an archived fork chain through compression and restoration.
The remaining boundary is unchanged: #42039 does not add archival retention or cleanup, automatic deletion, or prevention of
replacement_historyre-embedding. It reduces the representation of eligible cold files rather than bounding what the append-only history can write.