What version of Codex are you using?
Codex CLI 0.147.0
The affected local thread row reports:
source: cli
history_mode: paginated
model: gpt-5.5
reasoning_effort: medium
What issue are you seeing?
When I go back to an earlier prompt and try to branch before the selected prompt, Codex shows:
Failed to branch before the selected prompt: the selected prompt was not found in the persisted thread
The selected prompt text is present in the persisted thread. The problem appears to be that the visible timeline message id differs from the persisted UserMessage item id stored in thread_history_1.sqlite.thread_items.
Local evidence
Thread id:
01a00acd-8ff0-7901-8ad5-c5cccde4a8c7
The thread exists in both:
~/.codex/state_5.sqlite: threads.id
~/.codex/thread_history_1.sqlite: thread_turns/thread_items/thread_history_projection_state
The persisted thread contains the user prompts, but the JSONL response_item user message ids do not match the persisted UserMessage ids:
| Prompt |
JSONL response_item id |
persisted UserMessage id |
turn_id |
a fejlécek sorrendjével mi van? |
msg_01a00ace-dbf9-71a1-a3f3-04a4e126b8c7 |
01a00ace-dbfb-7581-96ce-54f947d4a5d9 |
01a00ace-dbb3-7df2-b3bf-6f038c4a77a8 |
most hasonlítsd a http2-vel! |
msg_01a00ad0-393b-7770-89a5-68e27dd0f8c7 |
01a00ad0-393c-7692-87b6-8113732b1f15 |
01a00ad0-38fd-79d3-9cf5-376b515f7524 |
most vészhelyzet van, elfogytak a szerver erőforrásai. |
msg_01a00ad1-4547-7203-b105-15af3ae5f6a7 |
01a00ad1-4547-7203-b105-15b6ce03a343 |
01a00ad1-4500-7333-9554-ecb484e767e5 |
én ezt raktam be: |
msg_01a00ad2-ae81-7913-9f4b-112224bd4417 |
01a00ad2-ae81-7913-9f4b-11367269869b |
01a00ad2-ae30-7d60-840d-94360d691efd |
nyomozd ki, ha visszamegyek a prompt-okban... |
msg_01a00ad8-80eb-7893-bb64-7d614acbb249 |
01a00ad8-80ec-70b3-85e9-0a3f19a28e08 |
01a00ad8-8098-72c2-a7a5-4915a9a2e513 |
The thread_history_1.sqlite row for the current thread also shows the paginated projection state exists:
thread_history_projection_state:
('01a00acd-8ff0-7901-8ad5-c5cccde4a8c7', 1024120, 212)
thread_items max/count:
(208, 68)
thread_turns max/count:
(124, 6)
Why this looks like a bug
The error says the selected prompt was not found in the persisted thread, but the prompt is present. It looks like the branch-before-selected-prompt path may be looking up the selected visible msg_... id in the persisted item table, where the stored user message id is the non-msg_... 01a... id.
Expected behavior
Branching before a selected prompt should work when that prompt exists in the persisted paginated thread, even if the UI-visible message id and persisted UserMessage item id are different.
At minimum, the lookup should normalize or map the visible timeline item id to the persisted UserMessage id for the same turn/prompt.
Actual behavior
Codex refuses to branch and shows:
Failed to branch before the selected prompt: the selected prompt was not found in the persisted thread
Possible related area
This seems adjacent to paginated thread history / app-server fork or branch-before-prompt handling. I found open issue #17708 about app-server lifecycle/fork state becoming stale, but I did not find an existing issue for this specific selected-prompt/persisted-item id mismatch.
What version of Codex are you using?
Codex CLI
0.147.0The affected local thread row reports:
source:clihistory_mode:paginatedmodel:gpt-5.5reasoning_effort:mediumWhat issue are you seeing?
When I go back to an earlier prompt and try to branch before the selected prompt, Codex shows:
The selected prompt text is present in the persisted thread. The problem appears to be that the visible timeline message id differs from the persisted
UserMessageitem id stored inthread_history_1.sqlite.thread_items.Local evidence
Thread id:
The thread exists in both:
The persisted thread contains the user prompts, but the JSONL
response_itemuser message ids do not match the persistedUserMessageids:response_itemidUserMessageida fejlécek sorrendjével mi van?msg_01a00ace-dbf9-71a1-a3f3-04a4e126b8c701a00ace-dbfb-7581-96ce-54f947d4a5d901a00ace-dbb3-7df2-b3bf-6f038c4a77a8most hasonlítsd a http2-vel!msg_01a00ad0-393b-7770-89a5-68e27dd0f8c701a00ad0-393c-7692-87b6-8113732b1f1501a00ad0-38fd-79d3-9cf5-376b515f7524most vészhelyzet van, elfogytak a szerver erőforrásai.msg_01a00ad1-4547-7203-b105-15af3ae5f6a701a00ad1-4547-7203-b105-15b6ce03a34301a00ad1-4500-7333-9554-ecb484e767e5én ezt raktam be:msg_01a00ad2-ae81-7913-9f4b-112224bd441701a00ad2-ae81-7913-9f4b-11367269869b01a00ad2-ae30-7d60-840d-94360d691efdnyomozd ki, ha visszamegyek a prompt-okban...msg_01a00ad8-80eb-7893-bb64-7d614acbb24901a00ad8-80ec-70b3-85e9-0a3f19a28e0801a00ad8-8098-72c2-a7a5-4915a9a2e513The
thread_history_1.sqliterow for the current thread also shows the paginated projection state exists:Why this looks like a bug
The error says the selected prompt was not found in the persisted thread, but the prompt is present. It looks like the branch-before-selected-prompt path may be looking up the selected visible
msg_...id in the persisted item table, where the stored user message id is the non-msg_...01a...id.Expected behavior
Branching before a selected prompt should work when that prompt exists in the persisted paginated thread, even if the UI-visible message id and persisted
UserMessageitem id are different.At minimum, the lookup should normalize or map the visible timeline item id to the persisted
UserMessageid for the same turn/prompt.Actual behavior
Codex refuses to branch and shows:
Possible related area
This seems adjacent to paginated thread history / app-server fork or branch-before-prompt handling. I found open issue #17708 about app-server lifecycle/fork state becoming stale, but I did not find an existing issue for this specific selected-prompt/persisted-item id mismatch.