Skip to content

fix(discover): parse Codex sessions with large session_meta#798

Merged
garrytan merged 1 commit intogarrytan:mainfrom
sensdiego:fix/codex-session-large-meta-parse
Apr 5, 2026
Merged

fix(discover): parse Codex sessions with large session_meta#798
garrytan merged 1 commit intogarrytan:mainfrom
sensdiego:fix/codex-session-large-meta-parse

Conversation

@sensdiego
Copy link
Copy Markdown
Contributor

Summary

  • Increase read buffer from 4KB to 128KB in scanCodex() — Codex CLI v0.117+ embeds the full GPT-5 system prompt (~15KB) in the session_meta line of rollout-*.jsonl files. The 4KB buffer truncated this line, causing JSON.parse to fail silently for every Codex session. All three originator types are affected: codex_exec (CLI), Codex Desktop (VSCode-based app), and codex_cli_rs (Rust CLI).
  • Add CODEX_SESSIONS_DIR env var for test isolation (same pattern as other scanners that accept path overrides).
  • 2 new tests: an integration test that creates a fixture with a 20KB session_meta line 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.text field in Codex's session_meta contains 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 that JSON.parse always rejected. Result: /retro global reported 0 Codex sessions for all users.

Test plan

  • bun test test/global-discover.test.ts — 18 pass, 0 fail
  • Manual verification: 174/174 historical Codex sessions now detected (was 0/174)
  • Verified across all three originator types (codex_exec: ~15.9KB, Codex Desktop: ~16.2KB, codex_cli_rs: ~13.6KB)
  • No private/user-specific data in the diff

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants