Aident AI

Codex Session JSONL Filling Your Disk? Clean It Up Safely
If Codex is creating very large JSONL files under ~/.codex/sessions, quit Codex, measure both active and archived sessions, identify one disposable session, and remove it with the supported codex delete command. Do not bulk-delete the sessions folder or edit a rollout file. Codex uses those files to resume conversations, and recent reports show that missing rollout JSONL can orphan otherwise indexed threads.
Archiving is useful for organizing sessions, but it does not reclaim the file's disk space. The current Codex implementation moves the rollout from sessions to archived_sessions. Deletion is permanent, so verify the exact session and preserve anything you may need before confirming it.
This guide was tested against codex-cli 0.144.4 on July 27, 2026. If your CLI does not show the same session commands, update Codex before continuing.
Prerequisites
Before changing session state:
save repository work and copy any important final output out of the conversation;
stop active Codex turns and fully quit the CLI, IDE extension, and desktop app;
make sure you can recognize the project and title of any session you plan to remove;
have enough separate storage for a backup if the session contains unique information;
treat every rollout JSONL as sensitive because it can contain prompts, command output, file paths, code, and accidental secrets.
Do not upload a complete JSONL to an issue or paste it into a public tool. If your repository files may be missing too, preserve the repository first and follow How to Prevent Codex from Deleting Files.
Step 1: Confirm the Supported Session Commands
Run:
Expected result: the help describes archive as archiving one saved session, delete as permanently deleting one saved session, and unarchive as restoring one archived session. All three accept a session UUID or name.
If delete is missing, update Codex through its normal installation method. Do not substitute rm, Remove-Item, or a third-party cleaner.
Step 2: Measure Active and Archived JSONL
On macOS or Linux:
On Windows PowerShell:
Expected result: you get a total for both active and archived storage plus the largest rollout files. The 100M filter is only a triage threshold, not an official Codex size limit. A healthy long session can be large, while a rapidly growing file may indicate repeated raw tool output, compaction history, or subagent activity.
If archived_sessions is large, archiving more sessions will not solve the capacity problem. It moves files out of the active list without deleting their bytes.
Step 3: Stop the Writer Before Cleanup
Fully quit every Codex surface that could own the session. On macOS or Linux, check for remaining processes:
On Windows:
Expected result: no Codex process remains before deletion. If a process is still present, use the app's normal Quit command and check again.
This matters because current Codex storage code rejects an archive operation when a thread still has an active writer. More importantly, cleaning up underneath a live writer creates an avoidable race between the session recorder and the filesystem.
Step 4: Identify One Session, Not One Large Filename
Run:
Find the old session by its title, project directory, and last activity. Exit the picker without resuming it, then write down the exact unique name.
Do not choose a session only because its JSONL is large. Confirm that:
its repository work is already committed, copied, or otherwise preserved;
its conversation contains no unique recovery instructions you still need;
no active task depends on it;
the title is unique in your session list.
If two sessions share a title and you cannot confirm the UUID, stop. A current Codex issue tracks the fact that the picker does not always expose an easily copyable ID. Guessing which duplicate name will resolve is not safe.
Step 5: Archive First When You Are Unsure
For a unique session name:
Expected result: the session leaves the normal active list. Current Codex source moves its rollout into archived_sessions, updates stored state, and refuses to proceed if that thread has an active writer.
Confirm you can reverse the organization change:
Expected result: the session returns to the active list. If archiving or unarchiving fails, keep the files untouched and collect the exact CLI version and error.
Archive is a rehearsal for selecting the right session. It is not a storage cleanup step because the JSONL remains on disk.
Step 6: Back Up Valuable Information
Before permanent deletion, copy unique outputs into the repository or another encrypted location that is not inside the Codex home directory. If you need the entire conversation, preserve the relevant rollout and its metadata on separate storage before deleting it.
Do not put the backup under ~/.codex/sessions or ~/.codex/archived_sessions. Codex may index it again, and you will not reclaim space.
If the session is hundreds of gigabytes and you cannot make a separate backup, delete it only when it is truly disposable. Otherwise stop and wait for an official fix or attach sanitized size and version evidence to the matching OpenAI issue.
Step 7: Delete One Confirmed Session
Use the exact unique session name:
Review the confirmation prompt carefully. Do not add --force; the current CLI reserves that flag for UUID-based deletion without a prompt.
Expected result: Codex permanently removes the selected saved session. The title no longer appears in the session picker, and the corresponding JSONL no longer contributes to the measured total.
Now re-run the commands from Step 2 and compare free space:
Windows users can re-run the PowerShell inventory from Step 2.
If space does not fall, the large file belonged to another session, the filesystem has not released an open handle, or another directory is consuming the disk. Do not keep deleting sessions to test theories.
Common Failure Modes
What you see | What it means | Safe next step |
|---|---|---|
One rollout grows while Codex is open | A live recorder may still be writing | Stop the turn, quit Codex, then measure again |
| The JSONL moved to | Unarchive if needed; delete only a confirmed disposable session |
Two sessions have the same name | Name-based deletion is ambiguous | Stop until you can confirm the UUID |
| A Codex process still owns the thread | Quit every Codex surface and retry once |
| A child session depends on that stored history | Preserve the parent; do not remove its rollout by hand |
A session disappears after raw file manipulation | Its rollout or metadata may no longer agree | Restore the preserved file; do not edit JSONL or SQLite by hand |
Disk usage rises again immediately | The active workflow is still producing large history | Bound raw output and subagent fan-out; start a fresh short session |
A full JSONL contains secrets | Session storage captured sensitive tool or prompt material | Keep it private and rotate any exposed credential |
Why JSONL Can Become So Large
Codex rollout files preserve conversation events needed to resume a session. Public reports have found repeated compacted history, raw tool output, reasoning records, and nested subagent sessions inside unusually large rollouts. One July report measured about 755 GiB of session JSONL across 2,393 child files; another reported individual files between 700 MB and 2 GB.
Those reports establish that extreme growth can happen, but they do not define a universal safe size or prove one cause for every machine. Measure the exact directory, identify the writer, and preserve the session boundary before acting.
For related resource symptoms, use How to Diagnose Codex Usage Spikes. If the active session itself is behaving unpredictably, start a bounded replacement session after preserving repository state instead of repeatedly resuming a multi-gigabyte transcript.
Run One Bounded External Check
After cleanup, test a short read-only integration workflow instead of generating another large local transcript. In Codex, paste:
Then ask:
Expected result: one current schema is inspected, five read-only issue results return, no provider secret appears, and the repository remains unchanged.
Use Aident Loadout for that bounded check. Measure success as five relevant issue results, zero writes, zero pasted secrets, and no new oversized session.
Sources
Insane Codex Disk Usage from Subagents, OpenAI Codex issue, opened July 18, 2026
Codex session logs grow to 700MB-2GB, OpenAI Codex issue, opened May 29, 2026
Rollout JSONL files deleted and threads orphaned, OpenAI Codex issue, opened July 27, 2026
Clarify Codex local session deletion and cleanup UX, OpenAI Codex issue, opened June 14, 2026
Improve session ID and archive/delete UX, OpenAI Codex issue, opened June 17, 2026
Codex local archive implementation, OpenAI Codex source, accessed July 27, 2026
Codex local delete implementation, OpenAI Codex source, accessed July 27, 2026
Codex app-server thread storage reference, OpenAI Codex source, accessed July 27, 2026


