# Where OpenAI Codex CLI stores your session history

> Codex CLI saves each session as a rollout JSONL file in ~/.codex/sessions by date and compresses old ones to .jsonl.zst. How to find, resume, archive and delete them.

Source: https://groundedby.com/agents/codex (updated 2026-10-29)

Codex CLI records each session as a rollout file, filed by date. Unlike Claude Code, it does not delete old sessions; it compresses them.

## Where the files are

```text
~/.codex/
├── sessions/
│   └── 2026/10/29/
│       ├── rollout-2026-10-29T09-14-02-<id>.jsonl
│       └── rollout-2026-10-21T17-40-55-<id>.jsonl.zst   # compressed when cold
├── archived_sessions/
├── session_index.jsonl         # id, thread name, last update
├── state_*.sqlite              # thread list: path, cwd, title, model, tokens
└── config.toml
```

The layout is the same on macOS, Linux and Windows. Set `CODEX_HOME` to move it.

Count your sessions, compressed ones included:

```bash
find ~/.codex/sessions -name 'rollout-*.jsonl*' | wc -l
```

## What is inside a rollout file

Each line is a record with a `type` and a `payload`:

| Record | What it holds |
| --- | --- |
| `session_meta` | Session id, working directory, CLI version, model |
| `turn_context` | Settings for a turn: model, approval and sandbox policy |
| `response_item` | Messages, reasoning, and tool calls (`function_call`) with their output |
| `event_msg` | Events such as task start, token counts, task complete |

Shell commands appear as `function_call` items named `shell` or `exec_command`, with the command in the arguments.

## Compressed sessions

A background worker compresses cold rollouts in place to `.jsonl.zst`. Older sessions are usually the compressed ones. To read one:

```bash
zstd -dc ~/.codex/sessions/2026/10/21/rollout-...jsonl.zst | head
```

## Resume, fork and archive

```bash
codex resume                 # pick from a list
codex resume --last          # the most recent session
codex resume <ID>
codex fork                   # start a new session from an old one
codex archive <ID>           # hide from the list, keep the file
codex unarchive <ID>
```

`codex exec resume` and `codex exec fork` do the same for non-interactive runs.

## Delete history

```bash
codex delete <SESSION>
codex exec --ephemeral "..."   # a run that saves nothing
```

The prompt history file is controlled by `history.persistence` (`save-all` or `none`) and `history.max_bytes` in `config.toml`.

## Privacy notes

- Rollouts include command output and file contents the agent read. [Redact before sharing](/guides/redact-secrets-from-agent-logs).
- On personal ChatGPT plans, the "Improve the model for everyone" setting also covers Codex. Business, Enterprise and Edu workspaces are not used for training by default.

## Measure it

The [evaluator](/evaluate) reads `~/.codex/sessions`, compressed files included, and counts sessions, hours and tool calls in your browser.

## Questions

**Where does Codex CLI save conversations?**

In ~/.codex/sessions, sorted into year, month and day folders. Each session is a file named rollout-<date-time>-<id>.jsonl. CODEX_HOME moves the whole ~/.codex folder.

**Why do some Codex session files end in .zst?**

Codex compresses older rollout files in place with zstd to save space. Tools that only read .jsonl files miss them; the groundedby evaluator reads both.

**How do I resume a Codex session?**

Run codex resume to pick from a list, codex resume --last for the most recent one, or codex resume <ID>. codex fork starts a new session from an old one.

**How do I delete Codex history?**

Run codex delete <SESSION>, or codex archive to move a session out of the list without deleting it. To run without saving, use codex exec --ephemeral.

## Sources

- [OpenAI Codex docs, developer commands](https://learn.chatgpt.com/docs/developer-commands?surface=cli)
- [OpenAI Codex docs, config reference](https://learn.chatgpt.com/docs/config-file/config-reference)
- [openai/codex source, rollout storage](https://github.com/openai/codex/tree/main/codex-rs/rollout/src)
