fix(discover): parse Codex sessions with large session_meta#798
Merged
garrytan merged 1 commit intogarrytan:mainfrom Apr 5, 2026
Merged
Conversation
Codex CLI v0.117+ embeds the full GPT-5 system prompt (~15KB) in the session_meta line of rollout-*.jsonl files. The 4KB read buffer truncated this line, causing JSON.parse to fail silently for every Codex session. Increase the buffer from 4KB to 128KB so JSON.parse works on realistic session_meta sizes. Add CODEX_SESSIONS_DIR env var for test isolation. Affected: all three Codex originators (codex_exec, Codex Desktop, codex_cli_rs) across CLI and desktop app channels. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3 tasks
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.
Summary
scanCodex()— Codex CLI v0.117+ embeds the full GPT-5 system prompt (~15KB) in thesession_metaline ofrollout-*.jsonlfiles. The 4KB buffer truncated this line, causingJSON.parseto fail silently for every Codex session. All three originator types are affected:codex_exec(CLI),Codex Desktop(VSCode-based app), andcodex_cli_rs(Rust CLI).CODEX_SESSIONS_DIRenv var for test isolation (same pattern as other scanners that accept path overrides).session_metaline and runs discovery via CLI, and a unit test that proves the 4KB buffer fails while the 128KB buffer succeeds.Root cause
The
base_instructions.textfield in Codex'ssession_metacontains the complete system prompt (15,225 bytes as of v0.117.0). This is standard Codex content, not user-specific. The previous 4KB read buffer captured only ~27% of the first line, producing invalid JSON thatJSON.parsealways rejected. Result:/retro globalreported 0 Codex sessions for all users.Test plan
bun test test/global-discover.test.ts— 18 pass, 0 failcodex_exec: ~15.9KB,Codex Desktop: ~16.2KB,codex_cli_rs: ~13.6KB)🤖 Generated with Claude Code