Problem
Codex appears to rebuild session_index.jsonl by scanning files under archived_sessions during startup. On machines with large archived histories, this makes startup much slower than necessary.
Observed case:
archived_sessions contained about 2.2GB of JSON session data.
- Codex startup rescanned archived files to rebuild the session index.
- Archived sessions were rescanned even when they had already been indexed and had not changed.
- Environment: Windows 11, Microsoft Store Codex App
26.506.3741.0, codex-cli 0.130.0.
Related issues
Expected behavior
Codex should treat the session index as a persistent cache and update it incrementally:
- Load the existing index immediately on startup.
- Only scan metadata for archived session files.
- Only parse JSON for new or modified files.
- Update the index when a session is archived, instead of waiting for the next startup.
- Provide an explicit rebuild command for repair/migration cases.
Suggested design
Add a v2 index with a manifest/state file:
session_index_v2/
meta.json
records.jsonl
state.json
journal.jsonl
Use per-file fingerprints in state.json:
{
"source_path": "archived_sessions/2026/05/session.jsonl",
"size": 123456,
"mtime_ms": 1778760000000,
"head_hash": "sha256:...",
"tail_hash": "sha256:..."
}
Startup flow:
- Load
records.jsonl.
- Display known sessions immediately.
- Start a background reconcile job.
- Reconcile compares file metadata against
state.json.
- Parse only changed or new files.
- Write updates through an append-only journal and compact later.
Acceptance criteria
- If no archived files changed, startup does not parse archived JSON files.
- Adding one archived file causes only that file to be parsed.
- Modifying one archived file causes only that file to be reparsed.
- Deleting an archived file writes a tombstone or removes the index entry.
- Corrupt index/journal rows do not block startup.
- A manual
rebuild-session-index command exists for repair.
Workaround
Move cold archived sessions out of archived_sessions so Codex does not see them during startup. This avoids the startup slowdown but does not fix the underlying indexing design.
Problem
Codex appears to rebuild
session_index.jsonlby scanning files underarchived_sessionsduring startup. On machines with large archived histories, this makes startup much slower than necessary.Observed case:
archived_sessionscontained about 2.2GB of JSON session data.26.506.3741.0,codex-cli 0.130.0.Related issues
~/.codex/sessionsrollout files instead of respecting Desktop-visible session index/state #20864 reports Desktop lag from scanning the hotsessionstree.archived_sessionscan remain on the startup indexing hot path.Expected behavior
Codex should treat the session index as a persistent cache and update it incrementally:
Suggested design
Add a v2 index with a manifest/state file:
Use per-file fingerprints in
state.json:{ "source_path": "archived_sessions/2026/05/session.jsonl", "size": 123456, "mtime_ms": 1778760000000, "head_hash": "sha256:...", "tail_hash": "sha256:..." }Startup flow:
records.jsonl.state.json.Acceptance criteria
rebuild-session-indexcommand exists for repair.Workaround
Move cold archived sessions out of
archived_sessionsso Codex does not see them during startup. This avoids the startup slowdown but does not fix the underlying indexing design.