Subagent spawns duplicate the full parent session history into each child rollout file (quadratic disk growth)
Open 💬 2 comments Opened Aug 2, 2026 by Iceorbz
💡 Likely answer: A maintainer (github-actions[bot], contributor)
responded on this thread — see the highlighted reply below.
Summary
When a session spawns subagents, each child's rollout .jsonl under ~/.codex/sessions/ begins with a complete copy of the parent session's history. Compaction events additionally re-write the entire replacement_history into the same log. For a long-lived session that spawns many subagents, disk usage grows roughly quadratically with session length.
Impact (real numbers from one machine)
- One long-running thread (~3 weeks old, ~100 subagent spawns, ~1,400 compaction events) produced 37 rollout files over 800MB each in a single day — ~30GB/day, measured at ~97% duplicated bytes.
~/.codex/sessions/reached 42GB, and the 1TB disk hit 3.8GB free before the pattern was found.- Session profiling: 93 of 101 rollout files created that day traced to the same parent thread.
Repro
- Start a session; build up a few hundred KB of history.
- Spawn several subagents (any task).
- Observe each new
rollout-*.jsonlstarts with the parent's full serialized history; sizes grow with parent history length, not child work. - Trigger compaction repeatedly; observe
replacement_historyre-written in full each time.
Suggested fixes
- Reference the parent rollout by ID + offset instead of copying history into children.
- Store compaction
replacement_historyas a delta or in a separate file, not appended in full to the live log. - Alternatively: transparent zstd compression of rollout files (we measured 10–20× on this content).
Environment
- Codex CLI with Codex Desktop, macOS (Darwin 25.5), model gpt-5.6-terra, subagents used heavily via the native multi-agent feature.
2 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I can reproduce this on Codex Desktop on Windows with a long-lived development thread using subagents.
Measured local session storage:
%USERPROFILE%\.codex\sessions: approximately 68.0 GB logical sizethread_source = subagent: 225 files / 62.18 GBthread_source = vscode: 4 files / 0.63 GBThe growth is strongly concentrated on days with heavy multi-agent use. For example:
Inspecting the rollout
session_metashowed that the large files are subagent sessions and that 179 of them point to the same parent thread.NTFS compression did not materially help:
This has a significant practical impact because normal multi-agent development can consume 10+ GB of local disk in a single working day, even though the actual repository itself is comparatively small.
It would be very useful if completed subagent rollouts could either:
A disk-usage warning in the Codex UI would also help, because this growth is otherwise silent until the system drive becomes low on space.