Repository navigation
feat(sessions): read OpenAI Codex CLI sessions - #67
Merged
Merged
Conversation
Parse Codex rollouts (~/.codex/sessions, archived_sessions, $CODEX_HOME) from the openai/codex rust-v0.163.0 schema: per-response usage from token_usage_record (token_count fallback), per-turn model from turn_context, OpenAI long-context and Fast tiers, tool calls with exit codes, fork de-duplication and subagent nesting. Add --agent and --codex-home, agent-aware report labels, and OpenAI list prices.
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
agentdiffnow reads OpenAI Codex CLI sessions alongside Claude Code and runs the same findings on them: long context, cache rebuilds, stuck retries, repeated failures, re-reads.Why
Roadmap P1.4. Covering more than one agent doubles the audience. It's also the defence against any one vendor building this into its own tool: no vendor will analyse a competitor's sessions.
How
The reader is built from the openai/codex source at rust-v0.163.0.
sessions/codex.pydocuments the format notes; the main points:sessions/**/rollout-*.jsonlplusarchived_sessions/, recursively.{timestamp, type, payload}(Codex 0.33+). Older unwrapped files carry no usage and are skipped..jsonl.zstfiles are read whencompression.zstd(Python 3.14) orzstandardis available.token_usage_record, one per API response and de-duplicated byresponse_id.event_msg/token_countlast_token_usage, skipping repeats and rate-limit-only events.input_tokensalready includes cached tokens, andoutput_tokensalready includes reasoning tokens. Both are handled.turn_context, so it can change mid-session.thread_settings_applied.service_tier == "priority"marks the Fast tier.long_context_tokensfield: above 272K input, input is billed at 2x and output at 1.5x, per OpenAI's pricing page.function_call/custom_tool_call/local_shell_callare paired with their outputs bycall_id.Process exited with code N/Exit code: N) or taken from paginateditem_completedCommandExecution events.sessions/dedupe.pyand is shared by both agents. Legacy forks copy their parent's usage lines, and those are counted once. Threads withparent_thread_idnest under their parent.exec_command,shell,local_shell), thecmdarguments they use, andbash -lc '…'wrapping.CODEX_HOMEandCLAUDE_CONFIG_DIRat empty directories, so no test can read a developer's real logs.Testing
What the tests cover:
token_countfallback, including skipping repeats and null events;token_count;By hand: my real Claude-only report is unchanged. A combined Claude + Codex demo renders the new header, the Agent column and the estimate note.
codex # do any small task npx @kerrshift/agentdiff --agent codex --since 1dChecklist
make lintpassesuv run python -m pytestis greenCHANGELOG.mdentry added under[Unreleased](if feat/fix)type(scope): summary