Skip to main content

Module codex

Module codex 

Source
Expand description

OpenAI Codex CLI: ~/.codex/sessions/YYYY/MM/DD/rollout-<ts>-<id>.jsonl.

Format notes (verified on Codex CLI 0.149, 2026-09-03):

  • The first line is session_meta with payload.cwd, payload.id, payload.cli_version and payload.originator.
  • event_msg / token_count carries info.total_token_usage, which is cumulative for the session; info is null on rate-limit-only events. input_tokens includes cached_input_tokens.
  • task_started / task_complete / turn_aborted bracket a turn.
  • response_item with payload.type function_call or custom_tool_call is one tool call; the matching *_output item carries the same payload.call_id, and the two lines’ timestamps bracket the call. That pairing is the trace.
  • task_started and task_complete bracket a turn span. An inference span runs from a user message item or a *_output item to the next thing the model produced: a call, a reasoning item, a web_search_call, or an assistant message.
  • response_item web_search_call is one server-side web search.

Codex model prices are not in the static table, so cost is reported as unpriced tokens.

Structs§

CodexAdapter
The Codex adapter: a process is matched to the rollouts it holds open, and only where the platform cannot say to the cwd and activity heuristics. See DEC-006.
CodexTranscript

Functions§

codex_dir
read_meta
Cheap header read: cwd and start time from the first line only.
recent_rollouts
Every rollout written since since.
rollout_id
The id in rollout-2026-05-14T21-37-50-<id>: what follows the fixed-width timestamp. A file named some other way is matched on its whole stem.
rollouts_open_by
Rollout files modified after since. Walks YYYY/MM/DD and prunes by directory mtime so the walk stays cheap on a long history. Rollouts the process has open: the app-server’s live threads, or the CLI’s one conversation. None when the platform cannot say. Filtered to the sessions directory so an unrelated file the process holds (a log, a config) is never mistaken for a thread, and mapped back under the un-canonicalised sessions directory so the paths compare equal to those from recent_rollouts.
sessions_dir