# Codex history and session logs: where they are, how to read

> Where Codex keeps session files on a Mac, how to resume or archive them, how to read a rollout JSONL file, and how to turn history saving off.

Codex keeps each session as a JSONL file under `~/.codex/sessions/YYYY/MM/DD/`, named `rollout-<timestamp>-<id>.jsonl`. Your typed prompts are in `~/.codex/history.jsonl`. OpenAI’s docs say local state lives under `CODEX_HOME` (default `~/.codex`) but do not document the session file format. The layout below comes from third-party guides and community format notes, so versions may differ.

## The official part

What the OpenAI docs do cover is how to manage sessions. The installed help for Codex CLI 0.166.0 lists these commands.

| Command | What it does |
| --- | --- |
| `codex resume` | Picker by default, or `--last` for the most recent session |
| `codex fork` | Fork a previous session |
| `codex archive` | Archive a saved session by id or name |
| `codex unarchive` | Restore an archived session |
| `codex delete` | Permanently delete a saved session by id or name |

The CLI reference says `codex resume` scopes `--last` to the current working directory unless you pass `--all`. The `/delete` slash command permanently removes the transcript, its saved side chats and spawned descendant sessions. `/archive` keeps the transcript. Resuming reloads a transcript and keeps the original history intact. Forking creates a new chat with a fresh ID and leaves the original untouched.

## Where the files are

The advanced config docs say that by default transcripts are saved under `CODEX_HOME`, for example `~/.codex/history.jsonl`. Third-party guides and the Codex source describe these additional locations.

- `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` for session transcripts
- `~/.codex/archived_sessions/` for archived sessions
- `~/.codex/session_index.jsonl` for thread names

Because these are not in the official docs, confirm them on your own machine with `ls ~/.codex`.

## How to read a rollout file

Each line is one JSON object. Community format notes say lines carry `timestamp`, `type` and usually `payload`. The first line is a `session_meta` record with fields such as `id`, `cwd`, `cli_version` and `model_provider`. After that:

- `response_item` records hold the model’s turn stream and tool calls. Types include `message`, `function_call`, `function_call_output`, `custom_tool_call` and `custom_tool_call_output`.
- `event_msg` records hold lifecycle events, mirrored messages and completed items.

To find commands, filter `response_item` records of type `function_call` or `custom_tool_call`. The command text is in `input` or `arguments`. Match each call to its output record by `call_id` to see what came back. A quick look with `jq` works well.

```bash
jq -c 'select(.type=="response_item")
  | select(.payload.type=="function_call" or .payload.type=="custom_tool_call")
  | {t:.timestamp, name:.payload.name, id:.payload.call_id}' \
  ~/.codex/sessions/2026/11/25/rollout-*.jsonl | head
```

Treat the field names as a guide. Format details can change between releases, so open one file and look before you build a script around it.

## Treat the files as sensitive

Session files record what you typed, what files the agent read and what commands printed. A key that appeared in any of those can sit on disk. Don’t paste a session into a ticket or chat without checking it. Read [Codex API key](https://www.excellent.so/guides/codex-api-key) and [Keeping keys and your email out of agent logs](https://www.excellent.so/guides/keep-keys-and-email-out-of-agent-logs).

## Turn saving off, or clear it

In `config.toml`, the docs list `history.persistence` with `save-all` or `none`, and `history.max_bytes` to cap the size of `history.jsonl`, dropping the oldest entries. Setting `persistence = "none"` disables local history persistence. That also removes the record you would use to check an agent’s work, so choose it only if you have another record. Delete a session you no longer need with `codex delete`, and note that the command is permanent. The `--ephemeral` option on `codex exec` also appears in the installed help.

## Check a task afterward

After a task that changed files or ran network commands, find the session by time and working directory, then compare each command with its output. [Check what your AI agents did](https://www.excellent.so/guides/check-what-your-ai-agents-did) walks through the method. [Read a session by hand](https://www.excellent.so/research/check-what-your-ai-agent-actually-did).

Checked against the vendor documentation on November 25, 2026. [CLI reference](https://learn.chatgpt.com/docs/developer-commands?surface=cli) · [Advanced config](https://learn.chatgpt.com/docs/config-file/config-advanced) · [Config reference](https://learn.chatgpt.com/docs/config-file/config-reference) · [Rollout format notes (community)](https://github.com/daymade/claude-code-skills/blob/main/daymade-claude-code/read-codex-history/references/codex_rollout_format.md)

## Read Codex logs without writing a script

Excellent’s free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code. For a local report without installing an app, [run the free scan](https://www.excellent.so/scan). Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. [See a sample report](https://www.excellent.so/r/sample). The [Mac app](https://www.excellent.so/download) runs on Apple silicon with macOS 14 or later. Manual scanning is free and needs no account.

Source: https://www.excellent.so/guides/codex-session-logs
