AgentFixFind a fix
CodexOpen issueUpdated Sep 23, 2026

thread history projection expected ordinal N, got N-1

Recover safely when a long Codex thread cannot fork or resume because its thread-history projection ordinal is out of sync.

Exact error

Match the message before using the fix

thread-store internal error: thread history projection ... expected ordinal 192591, got 192590 (code -32603)failed to prepare paginated forkFailed to start side conversation: thread/fork failed during TUI bootstrap

Quick answer

Start here

Copy the intended side-message before retrying. Stop using `/btw` or fork on the affected thread: one report shows the payload can fall through into the active main turn after the fork fails. Continue urgent work in a fresh thread and preserve the damaged thread for diagnosis. Do not edit SQLite projection cursors or delete rollout files; no supported repair is confirmed.

Diagnosis

Why it happens

  • The exact error shows the live writer and stored projection disagree by an ordinal in a paginated thread.
  • The source report passed database-integrity and rollout/state-parity checks, so a generic database corruption check may not detect this logical mismatch.
  • In one failure-containment report, the failed `/btw` payload was delivered to the main active turn instead of remaining isolated.

Safest first

Fixes, in order

01

Protect the active thread from misrouted input

Applies when: A fork or `/btw` just failed with expected/got ordinal

Retrying the control command can interrupt the main turn in the documented failure branch.

  1. Copy the side-message to a local editor.
  2. Do not resend `/btw <message>` or inline `/feedback` in that active thread.
  3. Tell the main agent to ignore any misrouted side-message if it already appeared.
  4. Wait for the current main turn to reach a safe stopping point.

Expected: The active task is not repeatedly redirected by failed side-chat payloads.

02

Move work to a fresh thread

Applies when: The affected long thread cannot fork or resume reliably

A new thread avoids writing more data into the wedged projection while preserving evidence.

  1. Create a concise handoff summary without private data.
  2. Start a fresh thread and paste the handoff plus the intended new request.
  3. Keep the original thread unmodified until a supported repair exists.

Expected: Work continues in a healthy thread without destructive state edits.

03

Capture a bounded diagnostic report

Applies when: You can reproduce on a current Codex build

Huge rollouts can also make in-product feedback attachments exceed upload limits.

  1. Record CLI version, thread age/size, history mode, expected and actual ordinal, and triggering command.
  2. Use the feedback dialog without large diagnostics if the full bundle is rejected with HTTP 413.
  3. Report the redacted signature and related issue IDs through an official channel.

Expected: The issue is traceable without uploading gigabytes of conversation history.

Verification

Prove the fix worked

  1. Use fork or side chat in the fresh thread and confirm it creates a separate conversation.
  2. Confirm the side-message does not appear in the main active turn.
  3. Leave the original thread available for future supported recovery testing.

Escalation

If it still fails

  • Do not manually change `thread_history_projection_state` ordinals in SQLite.
  • Do not delete the rollout, state database, or whole `.codex` directory.
  • Do not attach an unbounded private rollout to public feedback; summarize the ordinal signature instead.

Scope

Environment and version notes

  • The detailed report used CLI 0.149.1 on Linux with a six-day paginated thread and a roughly 1.1 GB rollout.
  • The thread's database integrity checks reported OK despite the projection mismatch.
  • Related underlying projection issues remained open when rechecked September 23, 2026.

Evidence

Sources

Source labels describe the evidence available on the checked date. A closed issue is not automatically a shipped fix.