codex - 💡(How to fix) Fix Codex local history index becomes stale and recent sessions cannot be resumed [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#19822Fetched 2026-04-28 06:36:30
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4closed ×1commented ×1

Codex VSCode/local history sometimes fails to show or resume recent sessions even though the actual session data still exists on disk.

This appears to be an index synchronization bug in Codex's local history management.

Root Cause

Recent Codex conversations can disappear from the visible history/resume list. This causes repeated context loss and additional token usage because the agent cannot reliably load the immediately prior work.

RAW_BUFFERClick to expand / collapse

Bug Report: Codex local history index becomes stale and recent sessions cannot be resumed

Summary

Codex VSCode/local history sometimes fails to show or resume recent sessions even though the actual session data still exists on disk.

This appears to be an index synchronization bug in Codex's local history management.

Environment

  • Product: Codex VSCode integration / local Codex
  • CLI version observed in session metadata: 0.125.0-alpha.3
  • Platform: Linux
  • Source in local thread DB: vscode
  • Model configured: gpt-5.5

Impact

Recent Codex conversations can disappear from the visible history/resume list. This causes repeated context loss and additional token usage because the agent cannot reliably load the immediately prior work.

This is especially costly for long-running coding and research sessions where continuity is expected.

Evidence

Recent sessions existed in the local Codex data store:

  • ~/.codex/state_5.sqlite
  • ~/.codex/sessions/YYYY/MM/DD/rollout-...jsonl

However:

  • ~/.codex/session_index.jsonl was stale and only listed sessions up to the previous day.
  • The current-day session was missing from the visible/resume history index.
  • state_5.sqlite integrity check returned ok.
  • logs_2.sqlite integrity check returned ok.

Additionally, an internal approval-review/guardian thread was inserted into the normal threads table:

  • source: {"subagent":{"other":"guardian"}}
  • model: codex-auto-review
  • title: began with The following is the Codex agent history whose request action you are assessing...

This internal review thread appeared alongside user-facing threads and polluted the history table.

Observed State Before Repair

The local threads table contained the recent user-facing thread:

  • archived: 0
  • source: vscode
  • rollout_path: pointed to an existing ~/.codex/sessions/.../rollout-...jsonl

But session_index.jsonl did not include it until manually rebuilt.

Manual Repair Performed

The following local repair was performed:

  1. Backed up:
    • config.toml
    • session_index.jsonl
    • state_5.sqlite
    • logs_2.sqlite
  2. Rebuilt session_index.jsonl from state_5.sqlite.
  3. Marked internal guardian / codex-auto-review threads as archived so they do not appear as normal user history.
  4. Ran SQLite WAL checkpoints.

After repair, the missing recent session appeared in session_index.jsonl.

Expected Behavior

  • Recent user-facing sessions should always appear in the history/resume list if the session exists in state_5.sqlite and the rollout JSONL exists.
  • session_index.jsonl should stay synchronized with state_5.sqlite.
  • Internal approval-review / guardian / codex-auto-review threads should not be inserted into, or at least not surfaced through, normal user-facing history.
  • If session_index.jsonl is stale or corrupt, Codex should rebuild it automatically from state_5.sqlite and/or sessions/**/*.jsonl.

Actual Behavior

  • Recent sessions existed on disk but were missing from the history index.
  • The visible history could not reliably load the latest work.
  • Internal review-agent threads appeared in the same local thread store as normal user sessions.

Requested Fix

Please fix Codex local history handling so that:

  1. session_index.jsonl is transactionally updated or automatically regenerated when stale.
  2. Recent sessions are discovered from state_5.sqlite / rollout JSONL even if the index is stale.
  3. Internal guardian / approval-review threads are excluded from user-facing history.
  4. WAL/checkpoint behavior cannot leave the UI with a stale history list after a normal session.

Severity

High for paid users relying on Codex continuity. The issue causes context loss, duplicate work, and avoidable token spend.

extent analysis

TL;DR

The most likely fix involves ensuring session_index.jsonl is transactionally updated or automatically regenerated when stale, and excluding internal guardian threads from user-facing history.

Guidance

  • Verify the integrity of state_5.sqlite and logs_2.sqlite to ensure data consistency.
  • Check for any existing mechanisms to rebuild session_index.jsonl from state_5.sqlite and consider automating this process.
  • Implement a filter to exclude internal approval-review threads (marked as codex-auto-review) from the user-facing history.
  • Review the WAL/checkpoint behavior to prevent stale history lists after normal sessions.

Example

No specific code snippet can be provided without knowing the exact implementation details, but a potential approach could involve periodically checking the last update time of session_index.jsonl against the latest session data in state_5.sqlite and rebuilding the index if it's stale.

Notes

The provided information suggests a synchronization issue between session_index.jsonl and state_5.sqlite, potentially complicated by the inclusion of internal review threads in the user history. The exact fix may depend on the specifics of the Codex local history management implementation.

Recommendation

Apply a workaround to periodically rebuild session_index.jsonl from state_5.sqlite and filter out internal guardian threads until a permanent fix is implemented, as this addresses the immediate issue of stale session indexes and polluted history.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING