Where AI coding agents keep their sessions
Paths, file formats and the fields the AgentsOfMine collector reads for OpenCode, Claude Code, Codex and Pi, with the version each was checked against.
Checked
Why this matters. If you write a tool that reads your own sessions (a backup, an export, a viewer), or you wonder why one stopped showing new ones, you need to know where each agent keeps them and in what shape. This page gives you that for four agents, with the version each was checked against.
The AgentsOfMine collector, an open-source program that uploads a copy of your coding sessions to your private workspace, reads files your agents already write. This page says where they are, what shape they have, and which fields the collector uses. Paths in the lists are for macOS, the only system I ran anything on. Windows and Linux has what the vendors document for them, which I did not run.

| OpenCode | Claude Code | Codex | Pi | |
|---|---|---|---|---|
| Format | SQLite (WAL mode) | JSONL | JSONL | JSONL |
| One file per | one database for all sessions | session | session, in a folder per day | session, in a folder per project |
| Checked here against | 2.3.0 (read) | not on this machine | rollouts from 0.169.0-alpha.11.1 (read) | 0.79.1 (read) |
Table: the shape of each agent’s storage. “Read” means I opened the files on a real install and looked at their structure on 19 November 2026; I looked at key names and counts, not at message content.
Where the collector looks, on macOS:
- OpenCode:
~/.local/share/opencode/opencode.db, opened read-only. - Claude Code:
~/.claude/projects/<project>/<session>.jsonl, one directory deep. - Codex: every
rollout-*.jsonlbelow~/.codex/sessions/, which is organised asYYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl. Files ending in.jsonl.zstare not read. - Pi: every
*.jsonlbelow~/.pi/agent/sessions/, organised as--<project>--/<timestamp>_<uuid>.jsonl.
Who needs this
Possible scenario. You want a nightly copy of everyone’s agent sessions in one folder, to search later. The four agents keep them in different shapes: one SQLite database, and JSONL files per session, per day or per project. A script that assumes one shape silently skips the others.
| Role | What changes for them |
|---|---|
| DevOps or platform engineer | Gets the path and the shape per agent for one backup job, with the version each was read at. |
| Senior software engineer | Knows which fields the collector uses, so their own tool can read the same ones. |
| Architect | Treats each format as an interface that can change, and sees which versions this page was checked against. |
Table: who gains what, my reasoning, not measured. I did not measure time saved for any role.
OpenCode
OpenCode keeps everything in one SQLite database. The collector opens it read-only. OpenCode 2.x moved sessions to new tables and stopped writing the old ones; on the database I checked, the old tables were last written on 5 October 2026. The collector uses session_v2 and session_message when session_v2 exists, and the older session, message and part tables otherwise. The full evidence, with the queries, is in the blog post on the move.
| Table | What the collector takes from it |
|---|---|
session_v2 | One row per session: id, project, directory, title, version, creation time, model |
session_message | One row per turn, with the content in a JSON data column. The collector reads the user and assistant types |
project | The project’s working directory |
The vendor says OPENCODE_DB can move the database. The collector does not read that variable: it opens the default path only.
Claude Code
Claude Code writes one JSONL file per session under ~/.claude/projects/<project>/, where <project> is the working directory with each character that is not a letter or digit replaced by - (the vendor’s description). The vendor also says the line format is internal and changes between versions, so a reader can break on any release. Because the folder name comes from the working directory, a session started in another folder is stored under another name; how to resume one from a different folder was tested on two Claude Code versions.
Not checked here. On the machine used for this page, ~/.claude/projects/ was empty, so I could not open a real Claude Code session file. What follows is what the collector’s code and tests read:
- Lines whose
message.roleisuserorassistant. - Content blocks of type
text,thinking,tool_use,tool_resultandimage. A tool result arrives in a lateruserline and is matched to its call bytool_use_id. - The working directory from a line’s
cwd, and the model from the firstmessage.model.
Subagent transcripts are written under <session>/subagents/ and are not read: the collector looks one directory deep only. Sessions are also deleted after 30 days by default; see Claude Code deletes sessions after 30 days.
Codex
Codex writes one rollout file per session into a folder per day. Each line has a top-level type, and most of the content sits in a payload. On the files I opened, the top-level types were session_meta, event_msg, response_item, turn_context, token_usage_record and world_state.
| Line type | Inside it | Used by the collector |
|---|---|---|
session_meta | session id, start time, working directory, cli_version | yes: id, start time and project |
turn_context | working directory | only when session_meta had none |
response_item | payload.type is message, reasoning, function_call, function_call_output or additional_tools | message with role user or assistant, as text only; function_call named exec_command, to estimate changed files |
event_msg, token_usage_record, world_state | progress, token counts, state | no |
Codex also keeps a SQLite index, ~/.codex/state_5.sqlite, with a threads table. The collector does not read it. Codex compresses older rollout files with zstd and renames them to rollout-….jsonl.zst, and the index keeps the old .jsonl path. On my machine the index listed 199 threads. The stored path existed for 10 of them; for the other 189 the same path with .zst added existed, and none was missing. The collector accepts only file names ending in .jsonl, so it does not read the compressed ones, and it does not look in archived_sessions/ at all. I did not check when or why Codex compresses a file.
Pi
Pi writes one JSONL file per session into a folder named after the working directory, wrapped in --. The folder name replaces / with -, which cannot be reversed when a path itself contains -, so the collector prefers the cwd in the file’s first line when it has read it.
On the file I opened, the line types were session (first line: version, id, timestamp, cwd), model_change, thinking_level_change and message. Messages carry a role of user, assistant or toolResult, and content blocks of type text, toolCall or image. A tool result is a separate message, matched to its call by id. pi --session-dir can move the storage; the collector does not read that option.
For turning a session into a readable file, see Export OpenCode, Codex and Claude sessions to Markdown.
Windows and Linux
Assumed, not tested. I ran nothing on Windows or Linux. Each line comes from a vendor page, an issue tracker or the collector’s source, read on 20 November 2026, and is labelled documented (the vendor’s page), reported (an issue or third-party guide, with the version it was about) or assumed (my reading). The only thing I ran is the OpenCode override commands, on macOS.
The short version. On Linux, the vendors’ pages give the same paths as above (the OpenCode text lists ~/.local/share/opencode/ for “macOS/Linux”). On Windows, the same folders sit under the user profile (%USERPROFILE%, such as C:\Users\<you>). Two things differ: project folder names also replace \ and :, and a tool run inside WSL keeps its data in that distribution’s Linux home.
- OpenCode. Windows:
%USERPROFILE%\.local\share\opencode\opencode.db(documented in the vendor’s troubleshooting text; two reports on 1.x versions agree, and I tested 2.3.2 on macOS only). On macOS,opencode debug paths dbfollowedXDG_DATA_HOMEandOPENCODE_DB(tested). Theopencode db pathcommand in the V1 docs does not exist in 2.3.2. - Claude Code. Windows:
%USERPROFILE%\.claude, andCLAUDE_CONFIG_DIRmoves it (documented). The vendor lists Windows 10 1809 or later, Ubuntu 20.04 or later, Debian 10 or later and Alpine 3.19 or later (documented). The project folder name replaces every character that is not a letter or digit with-(documented), soC:\Users\me\projshould becomeC--Users-me-proj(assumed: rule applied by hand). - Codex.
CODEX_HOME, default~/.codex(documented); the vendor’s Windows setup page usesC:\Users\alice\.codexas its example. An open July 2026 report says the Windows desktop app ignoresCODEX_HOMEwhile the command line honours it (reported), so the two could end up in different folders (assumed). Thesessions/YYYY/MM/DD/layout is not documented per system; I assume it is the same. - Pi.
~/.pi/agent/sessions/(documented).%USERPROFILE%\.pi\agent\on Windows comes from a third-party install guide (reported); I did not find it on the vendor’s own Windows page. The vendor says the folder name replaces/,\and:with-(documented), soC:\Users\me\projshould become--C--Users-me-proj--(assumed).PI_CODING_AGENT_SESSION_DIR,--session-dirandsessionDirmove the sessions (documented). - WSL. A tool installed in WSL uses that distribution’s Linux environment (documented for Pi, assumed for the others), so its sessions sit in that Linux home, not under
%USERPROFILE%, and a Windows program that looks only there will not see them (assumed). - The collector. Its paths are the home directory plus the Unix-style names above, and it reads none of the override variables (searched at commit 897f7db). Its README lists macOS and Linux as supported, says Windows is not supported, and says Linux has not been run end to end (the path code is unchanged since the commit this page was checked against). So on Linux with default settings it should read these paths (assumed). Paths do not look like what blocks Windows (assumed); its cross-platform note lists the open items.
What this page does not tell you
- Formats change. None of these is a published, versioned contract for readers; the Claude Code vendor says so explicitly. If a field here no longer matches, open an issue.
- Only what exists on disk. If an agent or you deleted a session file, there is nothing to read.
- One machine. The key names and counts above come from one person’s install.
- Windows and Linux. Nothing was run there. The section above is documentation and reports, with the version each one was about. A Windows report from OpenCode 1.x does not prove 2.x.