Module codex_session

Module codex_session 

Source
Expand description

Codex session file parsing for Codex CLI JSONL files.

This module parses Codex CLI session files (JSONL format) to extract events as a data source alongside hooks and OTEL.

Codex session files provide rich data that hooks don’t:

  • Token usage with cached and reasoning tokens
  • Full tool call arguments and outputs
  • User and agent messages
  • Git context (branch, commit, repo)

Session files are located at: ~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<UUID>.jsonl

Structs§

CodexSessionEntry
A single entry in a Codex session JSONL file.
CodexSessionParser
Parser for Codex CLI session JSONL files.
CodexSessionScanner
Orchestrates Codex session file scanning with storage integration.
FilePosition
Tracks file read position for incremental parsing.
FunctionCallInfo
Information about a function call, tracked for enriching output events.
GitInfo
Git repository information.
ParseResult
Result of parsing a Codex session file.
ScanResult
Result of scanning a Codex session file.
SessionMeta
Session metadata from the first entry.
TokenUsage
Token counts.
TokenUsageInfo
Token usage information from token_count events.
TurnContext
Turn context information.

Functions§

codex_sessions_dir
Get the Codex sessions directory path.
extract_session_id_from_filename
Extract session ID from a Codex session filename.
find_session_file
Find a Codex session file by session ID.
list_session_files_in_dir
List all session files in a date directory.
parse_session_meta
Parse session metadata from a session_meta entry.

Type Aliases§

FunctionCallMap
Map from call_id to function call info.