`~/.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
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
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:
- #36557 / #31198 / #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). - #33493 — compaction retains unbounded
input_imagepayloads. - #40111 / #32128 — inline base64 image payloads stored verbatim in rollout JSONL.
- #28868 / #30779 / #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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to archived_sessions/ and sessions/ rollout-*.jsonl, especially compacted records containing replacement_history; begin by tracing the compaction writer and the archive lifecycle. Compare the proposed options—deduplication, payload limits, and retention—then define a bounded-storage behavior and verify that long sessions no longer repeatedly reproduce large histories or accumulate without cleanup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100