Expand description
Codex session discovery, from the rollout transcripts Codex writes.
§Why there is no process here
Claude Code writes ~/.claude/sessions/<pid>.json per session, so
liveness is exact: the pid either exists or it does not. Codex has no
such file, and — measured on a real machine — no usable process mapping
either. The ChatGPT desktop app runs Codex as one long-lived
codex … app-server process serving every session, alongside 27 Electron
helpers. A terminal codex would be its own process, but nothing
distinguishes which session a given process owns.
So a Codex session is discovered from its transcript, and the consequences are honest rather than papered over:
- There is no pid, so
ClaudeSession::pidis 0 and the session is not actionable — seeClaudeSession::is_actionable. Sending input to it or killing it is not merely unimplemented; with the app there is no process that would mean the right thing. - There is no cost. Codex is subscription-billed and rollouts record
tokens only, so
cost_usdstays 0 withusage_metrics_availablefalse — absent, rather than a$0.00that would understate a fleet total. - There is no session-end event.
task_completeends a turn, not a session, and a session the user closed is byte-identical to one sitting idle. Liveness is therefore a recency window, and a crashed session mid turn reads as working until that window expires.CODEX_SESSION_TTL_SECSis the whole of the liveness model, and that is a property of what Codex records, not a shortcut.
§Layout
~/.codex/sessions/YYYY/MM/DD/rollout-<ISO-ts>-<uuid>.jsonlOne JSON object per line: {timestamp, ordinal, type, payload}. The types
this module reads are session_meta (identity and cwd),
event_msg/token_count (usage and the context window),
event_msg/{task_started,task_complete,turn_aborted} (status), and
response_item/{function_call,custom_tool_call} (the pending tool).
Structs§
- Rollout
Summary - What one rollout transcript says about its session.
Enums§
- Lifecycle
- The lifecycle state the transcript last recorded.
Constants§
- CODEX_
SESSION_ TTL_ SECS - How long after its last write a rollout still counts as a live session.
Functions§
- parse_
rollout - Parse a rollout transcript. Pure, so it is testable without a filesystem.
- scan
- Every rollout whose last write is within
ttl_secsofnow_secs, parsed. - sessions_
root ~/.codex/sessions.