Repository navigation
[Bug] Paginated thread history projection stops at a token_count record #40342
Description
What version of the Codex App are you using (From “About Codex” dialog)?
Bundled runtime: codex-cli 0.145.0 (desktop build not included), 0.149.0 same
What subscription do you have?
Not disclosed for privacy
What platform is your computer?
Linux x86_64 (host and kernel identifiers omitted)
What issue are you seeing?
Several completed local chats display only the initial user message and the assistant's first progress update. Later tool activity, turns, and final answers are missing from the conversation pane even though the durable rollout still contains the complete transcript.
The failure occurs while materializing paginated thread history. The projection stops at an early token_count record and does not process later rollout records.
Sanitized errors:
invalid type: map, expected f64
thread history projection expected ordinal 17, got 18
failed to project durable rollout during shutdown
What steps can reproduce the bug?
- Use Codex App with the bundled codex-cli 0.145.0 runtime and paginated thread history.
- Run a local task that emits a token_count event containing structured rate-limit data.
- Allow the task to continue through later turns and produce a final answer.
- Close and reopen the chat.
- Observe that the conversation pane contains only the messages before the rejected token_count event.
In the observed cases, restarting the app retries projection but does not repair the incomplete history.
What is the expected behavior?
The complete conversation, including later turns and final answers, should be reconstructed from the durable rollout and displayed after reopening the chat.
Additional information
History mode: paginated.
The projection cursor remains at ordinal 17. The next record is skipped, producing the subsequent ordinal-gap error.
The durable session data remains present; this appears to be a history-index/projection failure rather than transcript deletion.
The same failure pattern was observed in multiple local chats.
Privacy: No transcript, prompt, screenshot, filesystem path, account identifier, task/thread/session ID, repository name, hostname, raw log, token usage value, or private project information is attached or included.
Activity
github-actions commentedon Aug 24, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
maxstralin commentedon Aug 24, 2026
Additional reproduction evidence from the same failure family:
26.818.618090.149.1A local diagnostic mitigation forced unknown-conversation recovery to call full paginated hydration (
hydrateBackgroundThreads([threadId], { includeTurns: true })) before replaying deferred live notifications. The patched bundle was installed, its marker verified, and the app-server restarted. Mobile still displayed the truncated transcript.This narrows the remaining failure below a renderer-only unknown-conversation recovery path: likely the remote
thread/readhistory projection/index or the data returned to Remote clients. In affected tasks, a read can reporthasMore: falsewhile returning only the first visible turn even though the durable rollout has many later completed turns.This also overlaps the visible symptom in #39011 (completed messages disappearing after steered follow-ups), though the durable projection failure here persists across reconnect/restart and devices.
maxstralin commentedon Aug 24, 2026
Confirmed local recovery and narrowed the invariant failure further.
For two affected tasks,
thread_history_projection_stateshowed:next_rollout_ordinal = 18next_rollout_byte_offsetexactly equaled the end byte offset of rollout ordinal 18So the projector had consumed ordinal 18's bytes without advancing its ordinal checkpoint. Every subsequent append then failed with
expected ordinal 18, got 19; 0 rejected rollout lines cannot cover that gap.Transactionally advancing only
next_rollout_ordinalby one, with the database backed up and rollout JSONL untouched, immediately restored an inactive task: its projection advanced from one visible turn/four items to the complete history.The active task exposed a second restart-related invariant failure: duplicate ordinals were written around service restarts, initially
token_countplusthread_settings_appliedsharing ordinals 149 and 743. After backing up the rollout and removing only the duplicatetoken_countrecords, projection advanced to ordinal 1053 and restored 25 turns/339 items. A later restart produced another duplicate ordinal 1052. Advancing only the byte checkpoint past the already-accounted duplicate, while retainingnext_rollout_ordinal = 1053, resumed projection normally; it advanced to ordinal 1087 with 26 turns/350 items.This confirms two related correctness issues:
Suggested regression coverage:
token_countline;All repairs were performed against backed-up local state. No transcript content was deleted or reconstructed.
richardwhatever commentedon Aug 24, 2026
need fix
CharlesZHEN commentedon Aug 25, 2026
Independent sanitized confirmation from another Codex Desktop environment.
Environment
0.146.0-alpha.3.1history_mode=paginatedObserved behavior
For a completed affected thread:
interruptedturn and reports no additional page;task_complete;inProgressturn and four projected items;token_countrecord with ordinal N, whilenext_rollout_ordinalremains N;The recurring sanitized log signatures are:
Restart and shutdown retries did not reconcile the projection.
Aggregate scope
A read-only scan of the 14 most recent user-created paginated threads in this environment found the same boundary in 14 of 14 cases:
token_countrecord;inProgressturn;task_complete.This confirms a repeatable projection/index failure rather than transcript deletion or renderer-only state.
A supported repair or automatic re-projection path for already-wedged threads would be valuable, in addition to preventing the byte and ordinal checkpoints from diverging.
Privacy note: this report intentionally excludes prompts, transcript text, screenshots, task or thread identifiers, project and filesystem names, host information, account details, credentials, raw logs, and database files.
Daily0715 commentedon Aug 25, 2026
I can confirm that I am experiencing the same issue in Codex Desktop
connected to a remote Ubuntu 24.04 host running codex-cli 0.145.0.
Additional evidence from read-only diagnostics on this host:
invalid type: map, expected f64This suggests that the issue affects paginated history materialization,
rather than being caused by transcript deletion or SQLite corruption.
thedch commentedon Aug 25, 2026
Seeing this as well, pretty significant user experience issue
catlaverdure commentedon Aug 26, 2026
Independent reproduction on 2026-08-26 that closely matches this issue and extends it to ChatGPT iOS Remote:
codex_chatgpt_ios_remotecodex-cli 0.145.0response_itemassistant message with phasefinal_answer, immediately followed bytask_complete.read_threadreconstruction reports that same turn asinProgressand stops after the commentary item; it omits the later final answer and completion.token_countrecord occurs at the cutoff boundary and contains structuredrate_limitsdata (including primary, secondary, and credits objects), matching the projection-failure pattern described here.This is therefore not model-output loss: the completed response remains in the host rollout, while the reconstructed/mobile history is truncated before the token-count boundary.
The private thread ID, screenshots, and exact transcript timestamps are available through OpenAI Support if maintainers need them.
gn2554115-png commentedon Aug 26, 2026
I can independently reproduce what appears to be the same paginated thread-history projection bug on two separate new threads.
2 independent new paginated threads affected
Thread 1:
next_rollout_ordinal = 15
next_rollout_byte_offset = 119292
record at byte offset = ordinal 16
Thread 2:
next_rollout_ordinal = 14
next_rollout_byte_offset = 125677
record at byte offset = ordinal 15
raw rollout = intact
state metadata = intact
SQLite integrity_check = ok
projection = permanently stalled
Codex CLI/app-server = 0.146.0
Both affected threads remain present in the raw rollout/state metadata, but disappear or become incomplete in the Codex App history UI after reload.
No database repair, reindex, cleanup, or manual modification has been performed.
I can provide additional timestamps or metadata if useful.
BananaMeow-del commentedon Aug 26, 2026
Additional Windows ChatGPT Work reproduction, cross-referenced as #40907:
Thinkingstate, consistent with a completion/later-turn record not being projected.The user has not modified local rollout files or SQLite state. Exact runtime/build and private thread diagnostics are not yet available.
Based on the symptoms and the evidence already collected in this issue, the leading hypothesis is the same byte-offset / ordinal checkpoint divergence at a structured
token_countrecord: the durable rollout may contain the later turns while the paginated projection remains permanently stalled.Please correlate #40907 with this issue and check the affected Windows Work thread for
history_mode=paginated, records after the visible cutoff,thread_history_projection_stateconsistency, and the knowninvalid type: map, expected f64/ ordinal-gap signatures. A privacy-scrubbed screenshot is available.onovich commentedon Aug 26, 2026
I can reproduce the same class of paginated-history failure on Windows Codex Desktop.
Environment:
I have two affected local threads. I am omitting thread IDs, paths, and transcript contents for privacy.
Case A:
Case B:
Both state_5.sqlite and thread_history_1.sqlite pass SQLite quick_check. The rollout files and authoritative thread rows are still present; this appears to be a stale or wedged thread-history projection rather than transcript deletion.
Expected behavior:
I have not modified the databases. Could you confirm whether these cases belong to the same projection bug tracked here, and whether there is a supported repair path for already-wedged projections?
WjzZwd commentedon Aug 28, 2026
I can confirm this issue on a remote Linux app-server used from Codex Desktop on macOS over SSH, with a larger blast radius and a successful recovery path.
Environment
codex-cli 0.145.0codex-cli 0.150.1paginatedSymptoms
Forking is not available for threads using paginated history yet.Projection evidence
This was not isolated to one thread:
thread_history_1.sqlitecontained only 17 turns total: exactly one projected turn per affected thread.invalid type: map, expected f64thread history projection expected ordinal N, got N+1This matches the token-count/schema failure described in the issue: after rejecting the structured value, the cursor never advanced, and all subsequent records became unreachable through paginated history.
Version-skew detail
Upgrading the npm CLI alone did not replace the running server. Immediately after the upgrade:
{ "status": "running", "cliVersion": "0.150.1", "appServerVersion": "0.145.0", "managedCodexVersion": null }The old
0.145.0app-server was an unmanaged persistent process holding the control socket.codex app-server daemon restartcorrectly refused with:app server is running but is not managed by codex app-server daemonAfter terminating the old unmanaged instance and bootstrapping the managed daemon, both versions reported
0.150.1.Recovery that restored all affected threads
thread_history_1.sqliteplus its WAL/SHM files aside (no rollout data was removed).0.150.1daemon.Suggested product improvements
thread_history_*.sqliteexplicitly as a rebuildable derived index and automatically retry/rebuild when the cursor is far behind a valid canonical rollout.cliVersion != appServerVersionand clearly warn or safely replace an unmanaged incompatible server.history doctor/rebuildcommand that scans all affected paginated threads, rather than requiring a manual database move and lazy reopening of every thread.No private prompts, hostnames, repository names, absolute paths, credentials, or thread IDs are included here.
JH-builds commentedon Aug 28, 2026
Additional Windows reproduction with a clearer interruption/power-off trigger (2026-08-28).
Environment
codex-cli 0.150.0-alpha.8Trigger pattern
This has now occurred in two separate long local chats:
In the latest occurrence, the stale message said that a proof-of-concept was only about to begin, while the repository's durable Git state already contained the later completed and validated implementation. This confirms that the project data was not rolled back; the Desktop history/task projection was stale.
Expected behavior
After an interrupted turn followed by an unclean host shutdown, startup recovery should:
This looks consistent with the projection/restart invariant failures already documented in this issue, but adds a repeatable user-level trigger: interrupt an active command, then shut down before the turn fully settles.
No session IDs, project names, paths, transcript text, screenshots, credentials, rollout files, or database contents are included. Local rollout/database state was not modified.
garpunzel commentedon Aug 28, 2026
Confirming the same failure mode on macOS with Codex Desktop 26.820.60940 (build 7119).
After restart/reopen, an existing local thread renders blank. Read-only inspection shows no raw history loss:
thread_history_projection_stateis stalled atnext_rollout_ordinal=1046/next_rollout_byte_offset=13389464event_msg/token_counthasMore:falsethread/read,thread/resume,thread/turns/list, andthread/items/listsucceeding; restart did not rebuild the projectionNo private thread ID, paths, or conversation content included here. This appears to be the same paginated projection bug, and the UI presents it as total history loss. A supported re-projection/rebuild action would help users recover without touching raw storage.
mjaerdevi commentedon Aug 29, 2026
Independent Remote SSH reproduction with the exact frozen projection boundary (2026-08-29).
Environment
0.145.0User-visible result
interrupted, setscompletedAt: null, and reportshasMore: false.task_completeevents.This is the concrete projection failure behind the Remote SSH symptom described in #40515 for this occurrence.
Read-only projection evidence
14,577,410bytes /1,865physical linesthread_history_1.sqlitepassesPRAGMA quick_checkthread_history_projection_stateis frozen at:16is anevent_msg/token_countwhoserate_limitsvalue is a structured object.84637is already ordinal17(event_msg/item_completed). In other words, the projector advanced the byte cursor past rejected ordinal16without advancingnext_rollout_ordinal.final_answerandtask_completerecords are present. They are unreachable through the Desktop/thread-reader projection.The rollout also contains one malformed partial tool-output record later in the file, but the projection was already frozen at ordinal
16, well before that record. It is therefore not the trigger for this missing-history symptom.Expected recovery behavior
token_countrecord consistently.hasMore: false.No prompts, repository names, local paths, hostnames, credentials, raw transcripts, databases, or thread IDs are included. The underlying evidence is retained locally if OpenAI needs it through a private diagnostic channel.
This comment was prepared and posted by OpenAI Codex at the user's request.
SenlerBot commentedon Aug 29, 2026
Observed a similar history-projection failure in an active Codex Desktop task on Windows with a local WSL workspace.
Previously visible messages disappeared from the task UI. The task itself remained active and accepted new messages; the user explicitly reported that the chat had disappeared and asked the assistant to resend the latest messages. The durable local rollout JSONL for the task still exists, and the assistant retained enough conversation context to reconstruct the missing content.
This looks like a display/history projection loss rather than deletion of the underlying transcript. I cannot confirm that the disappearance happened specifically at a
token_countboundary, but the persistence/UI mismatch matches this report.g453607063-blip commentedon Aug 30, 2026
I've encountered this bug four times in a row. It causes this issue where subsequent chat history isn't displayed when the context of the conversation is compressed; I have to recreate the conversation each time to use it.
Jay2109 commentedon Aug 31, 2026
Additional occurrence observed on 2026-08-31 UTC in the Codex app:
This appears consistent with a transcript history/projection or rendering-persistence failure rather than intentional context management. No transcript, repository content, task/thread ID, logs, account identifiers, or internal project details are included here for privacy.
sri299792458 commentedon Sep 2, 2026
Independent Remote SSH reproduction with a disk-full/interrupted-write trigger and a successful per-thread recovery (2026-09-02).
Environment
26.831.215370.145.0paginatedUser-visible result
The remote root filesystem filled while a long task was active; even a
.codex/tmppath could not be created. After space was freed and Desktop reconnected, the task reopened with only the first user message, the first assistant progress message, and the first command. The remainder of the conversation was still in the canonical rollout.Durable-rollout and projection evidence
9,169,819bytes /1,150physical lines.1,149valid records with a contiguous ordinal sequence0..1148.task_startedand 6task_completeevents, 46 assistant/user message items, 158 custom tool calls, and 158 matching outputs.thread_history_projection_stateremained frozen atnext_rollout_byte_offset=102062andnext_rollout_ordinal=17.inProgressturn and four projected items.event_msg/token_countrecord whose structuredrate_limitsvalue included object-valuedprimaryandcreditsfields.The projection was therefore already stuck near the start of the file, hundreds of records before the later malformed partial append. Repairing the malformed JSON alone could not recover the thread; the
token_countschema rejection was an independent blocker.Recovery that restored the full task
All source and database files were backed up first. The old remote app-server also had to be stopped: it was a persistent unmanaged process, so
codex app-server daemon stopreported:For this single affected task:
event_msg/token_countrecord, onlypayload.rate_limitswas replaced withnull; no record or ordinal was removed.thread_items,thread_turns, andthread_history_projection_statein the derived history database.The history projection rebuilt successfully and the full conversation reappeared in Desktop.
This was an unsupported manual recovery performed against backups, not a proposed end-user procedure. A supported
history doctor/rebuildoperation would be much safer. It would also help if Desktop surfaced both disk-write failures and projection failures instead of presenting the early prefix as the complete task.No prompts, transcript text, task IDs, repository names, usernames, hostnames, absolute paths, credentials, or raw data are included here. The original and repaired artifacts are retained privately if maintainers need a narrowly scoped diagnostic.
This comment was prepared and posted by OpenAI Codex at the user's request.
clancy-Li commentedon Sep 2, 2026
I am seeing a related regression on macOS in the ChatGPT desktop app.
Environment:
Observed behavior:
This is not a sidebar filter or archived-thread issue. Refreshing/reopening the task does not restore the missing days. No transcript content, account information, project path, task ID, or raw logs are included here for privacy.
The symptom appears consistent with an interrupted history persistence/projection path on a newer desktop build. I can provide sanitized diagnostic excerpts privately if useful.
old-li-tou commentedon Sep 3, 2026
Independent Windows reproduction observed on 2026-09-03.
Environment
26.901.1978.00.149.010.0.22621User-visible behavior
Read-only evidence
Expected behavior
Privacy note: no prompt text, screenshot, task/thread identifier, project name, filesystem path, account details, raw logs, database, or token-usage values are included. A screenshot and narrowly scoped diagnostics are retained locally if maintainers need them through a private channel.
This comment was prepared and posted by OpenAI Codex at the user's request.
bbar commentedon Sep 4, 2026
Confirmed on 0.153.2: persisted checkpoint mismatch survives upgrade/restart; targeted recovery verified
Independent reproduction and recovery on 2026-09-04.
Environment and symptoms
cli_version=0.145.0,history_mode=paginated.hasMore=false, andnextCursor=null, although the canonical JSONL contained the later completed work.Exact inconsistent checkpoint
The affected
thread_history_projection_staterow inthread_history_1.sqlitecontained:Read-only byte-boundary inspection showed:
The byte position already points to ordinal 18 while the saved ordinal expects 17.
Sanitized log errors:
The ordinal-gap error continued under the verified 0.153.2 runtime. The transcript was valid JSONL and retained later completed turns. This proves the checkpoint mismatch, not the precise field causing every f64 deserialization error.
Controlled tests on isolated copies
Only this task's metadata/history rows and transcript were copied to temporary Codex homes; credentials and live configuration were not copied. Separate 0.153.2 app-server processes were used, with no model turn submitted.
next_rollout_byte_offsetfrom1608697back to1607901, retaining ordinal 17, then resumed the copied task. All eight turns in that snapshot, 287 indexed items, and seven final replies became available.Backed-up live recovery and user confirmation
After user authorization, a consistent SQLite backup and transcript-prefix backup were created and checked. A guarded transaction corrected one checkpoint row's byte offset, after revalidating the task identity and exact boundaries.
The running projector caught up without a remote daemon restart. At verification:
task_completerecords exactly.No canonical transcript edits, task deletions, global database replacement, or modifications to other task rows were needed.
Safety: These offsets describe one occurrence; they must not be applied to other tasks. Manual SQLite edits are not a general supported recovery procedure. Backups, exact boundary checks, and concurrency safeguards were used here.
Requested product behavior
Please prevent inconsistent byte-offset/ordinal checkpoints and recover checkpoints already left inconsistent by older runtimes. A supported per-task re-projection/recovery action and a visible history-load error would avoid presenting this as permanent conversation loss.
This confirms a recovery failure for an already-affected task on 0.153.2; it does not establish that 0.153.2 created the original inconsistent checkpoint.
Privacy: no prompts, conversation text, screenshots, task IDs, hostnames, project names, absolute paths, raw logs, databases, credentials, or token-usage values are included.
Prepared and posted by Codex at the user's request, using measured diagnostics and the user's post-repair confirmation.
yangzhao1230 commentedon Sep 4, 2026
Additional Linux confirmation with a larger local sample. This appears to reproduce the same failure pattern exactly.
Environment:
codex-cli 0.146.0.0.153.2, but the active app-server was started before the upgrade and continued running the old executable./proc/<pid>/exepoints to a deleted pre-upgrade binary.paginated.Read-only store-wide results:
next_rollout_byte_offsetwas exactlynext_rollout_ordinal + 1.event_msg/token_count.PRAGMA quick_checkreturnedokfor both the state and thread-history databases, and the cursor-adjacent JSONL records were valid JSON.The live logs repeatedly contain both forms of the failure:
A newly created thread also wedged at ordinal 17 after its first tool activity, so opening a fresh chat did not help while the stale
0.146.0app-server remained active. The raw rollout continued to grow while the projected UI history remained at the first turn/four items.The stale server also retries projection on subsequent writes and emits a large warning burst, causing the local logs database to grow rapidly. Low disk space can therefore become an amplifier/consequence even when there is no
SQLITE_FULLerror or physical database corruption.This also closely matches the stale-runtime behavior documented in #38792 and the legacy representation incompatibility in #41276. No repair or mutation has been attempted on this store yet. A supported self-healing projection rebuild and a reliable way for an upgraded CLI/app to replace or reject stale app-server runtimes would both help.
pabloruano commentedon Sep 9, 2026
Independent sanitized confirmation observed on 2026-09-09.
Environment
0.145.0paginatedObserved behavior
Conversation interrupted.final_answer, immediately followed bytask_complete.This appears to match the failure already documented in this issue and provides a fresh confirmation that restart alone does not recover an affected thread.
Privacy: this confirmation intentionally excludes prompts and conversation content, screenshots, task/thread/session IDs, project or repository names, filesystem paths, account information, device identifiers, credentials, and raw logs.
Prepared and posted by Codex at the user's request.
Barry-886 commentedon Sep 9, 2026
Additional native Windows occurrence observed on 2026-09-09, with a reused ordinal at the exact frozen projection checkpoint.
Environment
OpenAI.Codex 26.901.6511.0.cli_version:0.153.4(this is thread metadata, not a separately verified version of the currently serving executable).10.0.26200, x64; local Windows workspace.history_mode=paginated.Symptoms
The user reports that later messages have disappeared and the conversation has jumped back to an earlier point. Two read-only calls to the app-provided
read_threadsurface, requesting the newest page withturnLimit=8and thenturnLimit=1, also return an old turn asinProgresswithcompletedAt=null. The thread's metadata update time advances, but the newest returned turn remains the one started at 2026-09-08T16:01:15Z.The canonical rollout contains the later assistant final messages and their completion records. This is an observed existing-session failure; a minimal synthetic reproduction and the precise initial trigger have not been established.
Exact read-only checkpoint evidence
Only this affected thread was queried. Both SQLite connections used
mode=roandquery_only=ON; projection state and projected turns were read in one transaction.next_rollout_byte_offset21534739next_rollout_ordinal21791263,inProgress, no completion timestamptask_completerecords after the checkpointThe byte boundary aligns exactly with these consecutive durable records:
In other words, the checkpoint expects ordinal 2179, but the next durable record reuses ordinal 2178. The previous record has already consumed that ordinal. More than 20 MB of later rollout data exists after this boundary. JSON decoding succeeded for every line during the read-only pass.
This appears relevant to the duplicate-ordinal/restart variant discussed earlier in this issue. Unlike the original skipped-ordinal example, this case has a reused ordinal at the next byte offset. The evidence does not establish what caused the ordinal to be reused, whether a restart was responsible, or whether the original
invalid type: map, expected f64error also occurred.Expected behavior
Later valid messages and completed turns should remain available through the conversation UI and history reader. Please investigate duplicate ordinal handling and a supported recovery path for already-stalled projections that preserves the durable records.
No app restart, database modification, rollout rewrite, or local repair was attempted during this diagnosis. This comment contains only sanitized structural evidence; no conversation text, task/thread IDs, local paths, credentials, screenshots, or raw logs are attached.