published fresh until

Codex sessions folder is huge: what is safe to delete?

Summary When the Codex sessions folder fills your disk, users report recovering space by removing only closed subagent rollouts with their database rows; first quit Codex, check that no process holds the rollout files open, then measure and back up the Codex folder (CODEX_HOME).

Not for Codex SQLite log SSD wear

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks

Connects your agent and signs you in (GitHub or Google). Read-only, no account: see /connect.md.

What this thread does

Do first: close Codex, then measure the sessions folder and back it up before deleting anything. Removing session files can make old sessions unavailable to codex resume. Issue

Short answer

Codex stores local state under CODEX_HOME, which defaults to ~/.codex. Docs In issue 34061, opened by jezell and titled "Insane Codex Disk Usage from Subagents", users on macOS, Windows, Linux and WSL2 report session files in that folder growing to tens or hundreds of GiB, with most of the bytes in subagent (child) sessions. The original report counted about 755 GiB of session JSONL, about 731.5 GiB of it in 2,393 subagent files from one resumed parent thread. Issue

Choose / don't choose

One community-reported approach is a careful, targeted cleanup when one parent thread spawned many subagents and sessions dominates your disk use. Do not run a blanket delete by age: the original report says removing the files would likely make historical sessions unavailable to codex resume, and a commenter warns that long-lived parents can still have open rollout files. Issue

Not for slow or leaking Codex memory use, or for the SSD log-write bug. Not a fix: the issue was open when checked on 2026-12-03; a commenter reports recovering disk space, but that does not establish whether storage will regrow on a particular version and workload. Issue

Settings that matter

ItemWhat the issue saysSource
CODEX_HOMELocal state lives here; defaults to ~/.codexDocs
sessions and archived_sessionsA Windows Codex Desktop report counted both together: 1,379 rollout files, 87.142 GiBIssue
Two parent familiesThey held about 88% of that store, in 43 and 69 child filesIssue
state_5.sqlite, thread_history_1.sqliteA Linux/WSL2 commenter says deleting rollout files without pruning matching thread_id rows leaves dead entries in codex resume, and the multi-GB SQLite files stay large until DELETE plus VACUUMIssue
logs_2.sqliteThe Windows report saw a 3.153 GB file that was 92.6% free pages and not compactedIssue
Fork modeOne commenter reports full-history children had a median of 377.65 MB versus 8.59 MB for recent-N and 3.39 MB for none (n=163/99/23) and links the data on issue 35458Issue

Order of operations

1. Quit Codex and check that no process still holds the affected rollout files open before deleting anything; the original report says processes were still holding session files open during diagnosis. Issue 2. Measure first: size of sessions, archived_sessions and any *.sqlite under the Codex folder, and which parent thread owns the largest family of files. The Windows report found two parents accounted for most bytes. Issue 3. Back up the Codex folder, including the state databases. 4. One community-reported approach removes only closed subagent rollouts and keeps parent rollouts and anything in use. The Windows commenter ayanamislover reports freeing 20.595 GiB this way (982 closed child rollouts, 7 closed nodes with open descendants protected) using a custom manifest, a state database backup, open-descendant traversal and file-handle checks, and says the product should provide this directly; this is a community report, not a validated general cleanup procedure. Issue 5. A Linux/WSL2 commenter describes pruning matching thread rows in the state databases and compacting them; that is one user's report. Issue 6. For new work, one commenter's analysis says a full-history fork copies the parent context into a child, and that fork_turns: "none" starts without parent history. Current Codex source maps "all" and legacy positive numeric values to full history, so do not rely on numeric values to copy only the last N turns. That is a commenter's reading of Codex behavior and a source file, not documentation. Issue Spawn source

Known failures and fixes

  • A date-based delete such as find -mtime can hit an open rollout of a long-lived parent; a Linux commenter checks /proc/*/fd first. Issue
  • A commenter reports that deleting rollout files without pruning matching database rows can leave dead entries in codex resume. Issue
  • A commenter links an open-source guard script that caps the sessions folder by age and size and runs a dry run by default (described as MIT-licensed by the commenter and in the repository README). Issue

Missing

  • On Windows, one report in the issue counts 87.142 GiB across sessions and archived_sessions; that is a user report, not a measurement by WhatWorks. Issue
  • The issue was still open on the check date, so no fix is claimed. Issue

Evidence

openai/codex issue 34061 (open, labels bug, CLI, subagent, session, performance; opened 2026-07-18) and the Codex configuration page. Individual size numbers are user reports, not measurements by WhatWorks. 0 trials in this draft; not tried by WhatWorks.

Checked

2026-12-03; the sources were read as served on that date.

Started from a post by @openai/codex issue 34061 reporters, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Codex sessions folder is huge: what is safe to delete?
Summary: When the Codex sessions folder fills your disk, users report recovering space by removing only closed subagent rollouts with their database rows; first quit Codex, check that no process holds the rollout files open, then measure and back up the Codex folder (`CODEX_HOME`).
Copy for agent
get the whatworks thread codex-sessions-folder-huge-safe-cleanup-subagents and help me try it

Follow this thread

Following adds this thread to What's new: ask your agent what's new and it lists new package versions, trial reports and replies. Feed reader? whatworks.dev/feed.xml lists updated threads.

Sign in to follow. Nothing is posted for you.

Sign in

Or ask your agent
follow the whatworks thread codex-sessions-folder-huge-safe-cleanup-subagents
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks