Part of the AI coding agent security checklist
Where Codex CLI keeps your session history
Claude Code deletes its transcripts after 30 days by default. Codex documents no such limit for its sessions, so every thread you have run since you installed it can still be in ~/.codex, with each command's output. Where the files are, what they hold, and how to cap them.
Paths are the ones ranwhat's Codex reader uses, checked against Codex rust-v0.159.3 and its configuration documentation under Sources. Published .
Where does Codex store session history?
In ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl, one file per thread, or under $CODEX_HOME if you set it.
What is in a Codex rollout file?
The whole thread: each line is one JSON event with a timestamp, a type and a payload.
Does Codex delete old sessions?
Not by any documented rule: the docs give no retention period for the rollout files.
The configuration documentation names [history] persistence = "none" in config.toml to stop saving history, and history.max_bytes to cap it. It does not say whether the rollouts under sessions/ follow it, so check the folder after a new session.
[history] persistence = "none"
For comparison: Claude Code's cleanupPeriodDays defaults to 30 days, and Gemini CLI's general.sessionRetention to "30d".
How much Codex history do I have?
du -sh ~/.codex/sessions gives the total; ls ~/.codex/sessions shows the years it covers.
du -sh ~/.codex/sessions ~/.codex/archived_sessions ~/.codex/history.jsonl ls ~/.codex/sessions ls ~/.codex/shell_snapshots | wc -l
How do I check what Codex ran and which secrets it kept?
Run uvx ranwhat check --source codex: it reads the rollouts, flags risky calls and finds credentials, changing nothing.
How do I delete Codex session history?
Remove the files: there is no purge command, and deleting them only removes your local copy.
Delete a day's folder under sessions/, archived_sessions/ or history.jsonl when Codex is not running. If a thread showed a credential, rotate it first: the copy was readable for as long as it sat there. Rotate a leaked key has each provider's steps.
Common questions about Codex history
Where is Codex CLI history stored?
In ~/.codex/sessions/YYYY/MM/DD/, one rollout-*.jsonl file per thread, plus typed prompts in ~/.codex/history.jsonl. Set CODEX_HOME and it all moves there.
What is ~/.codex/history.jsonl?
The prompts you typed into Codex. history.max_bytes in config.toml caps its size.
Why are some Codex sessions .jsonl.zst files?
Codex compresses a thread with zstd once it has been idle for a week. zstd -dc prints one.
Does Codex keep secrets in its history?
It keeps whatever a session saw: a printed key, a file it read, and the exported variables in its shell snapshots. uvx ranwhat clean --source codex finds them.