Codex Session JSONL Filling Your Disk? Clean It Up Safely

Codex Session JSONL Filling Your Disk? Clean It Up Safely

Aident AI

A small cyan ribbon repeatedly folds into an enormous translucent amber mass against a dark blue field.

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:

codex --version
codex archive --help
codex delete --help
codex unarchive --help

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:

codex_home_dir="${CODEX_HOME:-$HOME/.codex}"

du -sh \
  "$codex_home_dir/sessions" \
  "$codex_home_dir/archived_sessions" \
  2>/dev/null

find \
  "$codex_home_dir/sessions" \
  "$codex_home_dir/archived_sessions" \
  -type f -name "*.jsonl" -size +100M \
  -exec du -h {} + 2>/dev/null |
  sort -h |
  tail -20

On Windows PowerShell:

$codexHomeDir = if ($env:CODEX_HOME) {
  $env:CODEX_HOME
} else {
  Join-Path $env:USERPROFILE ".codex"
}

$sessionFiles = @(
  "sessions"
  "archived_sessions"
) | ForEach-Object {
  Get-ChildItem `
    -LiteralPath (Join-Path $codexHomeDir $_) `
    -File `
    -Filter "*.jsonl" `
    -ErrorAction SilentlyContinue
}

[pscustomobject]@{
  Files = $sessionFiles.Count
  GiB   = [math]::Round(
    ($sessionFiles | Measure-Object Length -Sum).Sum / 1GB,
    2
  )
}

$sessionFiles |
  Sort-Object Length -Descending |
  Select-Object -First 20 FullName, @{
    Name = "MiB"
    Expression = { [math]::Round($_.Length / 1MB, 1) }
  }

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:

pgrep -fl "Codex|ChatGPT|codex"

On Windows:

Get-Process Codex, ChatGPT, codex -ErrorAction SilentlyContinue |
  Select-Object Id, ProcessName

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:

codex resume --all

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:

codex archive "exact 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:

codex unarchive "exact unique session name"

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:

codex delete "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:

codex resume --all
du -sh \
  "$codex_home_dir/sessions" \
  "$codex_home_dir/archived_sessions" \
  2>/dev/null

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

archive succeeds but disk usage is unchanged

The JSONL moved to archived_sessions

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

archive reports an active writer

A Codex process still owns the thread

Quit every Codex surface and retry once

delete reports a forked-history reference

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:

Follow https://aident.ai/SETUP.md

Then ask:

Check my Aident Loadout account and Vault status.
Find a connected read-only GitHub issue search Action.
Inspect its current input schema, then return five open OpenAI Codex issues
whose title contains "session" or "disk".
Do not create or edit issues, change files, or ask me to paste a provider key.
Stop after the five results

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

Home

Home

Home

Integrations

Integrations

Integrations

Vault

Vault

Vault

Audit

Audit

Audit

Arana Grande

Arana Grande

Arana Grande

Free

Free

Free

30-day audit summary

30-day audit summary

30-day audit summary

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

Daily action-call volume and the latest receipts from the Loadout audit trail.

View Audit

View Audit

View Audit

Loadout usage

Loadout usage

Loadout usage

617 action calls in the last 30 days

617 action calls in the last 30 days

617 action calls in the last 30 days

May 19 - Jun 17

May 19 - Jun 17

May 19 - Jun 17

10 active days

10 active days

10 active days

Less

Less

Less

More

More

More

Recent activity

Recent activity

Recent activity

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Latest action-call receipts from connected agents

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Apr 23, 09:23 AM

Shopify

Shopify

Shopify

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Creates Or Updates An Asset For A Theme

Success

Success

Success

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Apr 23, 09:21 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Success

Success

Success

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Apr 23, 08:53 AM

Shopify

Shopify

Shopify

Update Products Param Product Id

Update Products Param Product Id

Update Products Param Product Id

Failed

Failed

Failed

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Apr 22, 22:13 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Apr 22, 22:12 PM

Shopify

Shopify

Shopify

Create Product Image

Create Product Image

Create Product Image

Success

Success

Success

Connected integration coverage

Connected integration coverage

Connected integration coverage

162

162

162

of 753 accessible connected

of 753 accessible connected

of 753 accessible connected

Callable actions

Callable actions

Callable actions

1,126

1,126

1,126

Vault credentials

Vault credentials

Vault credentials

8

8

8

Explore what's possible

Explore what's possible

Explore what's possible

See all Integrations

See all Integrations

See all Integrations

Google Ads

Google Ads

Google Ads

All available Goolge Ads tools via...

All available Goolge Ads tools via...

All available Goolge Ads tools via...

X (twitter)

X (twitter)

X (twitter)

All available X tools via...

All available X tools via...

All available X tools via...

Github

Github

Github

All available Github tools via...

All available Github tools via...

All available Github tools via...

Notion

Notion

Notion

All available Notion tools via...

All available Notion tools via...

All available Notion tools via...

Slack

Slack

Slack

All available Slack tools via...

All available Slack tools via...

All available Slack tools via...

Firecrawl

Firecrawl

Firecrawl

All available Firecrawl tools via...

All available Firecrawl tools via...

All available Firecrawl tools via...

753 integrations are available for loadouts.

753 integrations are available for loadouts.

753 integrations are available for loadouts.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Plug your entire stack into your AI agents.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.

Skip the integration headache. Plug 750+ tools into Claude Code, Codex, and OpenClaw in one go, and let your agents execute today.