Subagent fork sessions persist large JSONL histories indefinitely, causing severe ~/.codex disk bloat
Open 💬 1 comment Opened Jul 1, 2026 by msokolov-meta
What version of Codex CLI is running?
codex-cli 0.141.0
What subscription do you have?
API
Which model were you using?
gpt-5.5
What platform is your computer?
_No response_
What terminal emulator and version are you using (if applicable)?
_No response_
Codex doctor report
What issue are you seeing?
Codex appears to persist every subagent/fork as a normal local thread rollout under ~/.codex/sessions, including full parent history when the agent is created with full-history fork mode. These JSONL files do not appear to be automatically cleaned up when subagents complete.
On one real install, after multi-agent work:
~/.codex/sessions: 54G~/.codex/sessions: 4,468.jsonlfiles~/.codex/archived_sessions: 2.0G~/.codex/logs_2.sqlite: 16G- several individual rollout JSONL files are 400-700 MB
- two parent threads have 548 and 1,797 spawned descendants respectively
This makes local history expensive to scan/load and causes large disk growth over time.
What steps can reproduce the bug?
What steps can reproduce the bug?
- Start a Codex thread and build up a sizable history.
- Spawn many subagents using full-history fork behavior, for example legacy
fork_context: trueor v2fork_turns: "all"/ default full-history behavior. - Let the subagents complete.
- Inspect
~/.codex/sessions.
Useful inspection commands:
du -sh ~/.codex ~/.codex/sessions ~/.codex/archived_sessions ~/.codex/logs_2.sqlite ~/.codex/state_5.sqlite
find ~/.codex/sessions -type f -name '*.jsonl' | wc -l
find ~/.codex/sessions -type f -printf '%s %p\n' | sort -nr | head -20
sqlite3 -readonly ~/.codex/state_5.sqlite \
"SELECT parent_thread_id, COUNT(*) FROM thread_spawn_edges GROUP BY parent_thread_id ORDER BY COUNT(*) DESC LIMIT 20;"
What is the expected behavior?
Closed subagents become archived/cleaned up.
Additional information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗