Repository navigation
codex resume <name> can fail after a fresh thread is auto-named, and unsaved name entries can shadow older saved sessions #15943
Description
What version of Codex CLI is running?
codex-cli 0.116.0
What subscription do you have?
Unknown / not relevant to this bug
Which model were you using?
gpt-5.4
What platform is your computer?
Darwin 25.3.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
Zed terminal (TERM=xterm-256color)
What issue are you seeing?
A fresh interactive Codex CLI session can print a resumable thread name before any resumable session data actually exists.
Example observed behavior:
-
Start
codexin a directory namedsmarty-pants -
Codex prints:
Thread renamed to smarty-pants, to resume this thread run codex resume smarty-pants -
Exit before sending the first user message
-
Run:
codex resume smarty-pants -
Codex fails with:
ERROR: No saved session found with ID smarty-pants. Run \codex resume` without an ID to choose from existing sessions.`
Underlying local state shows the thread name was indexed even though no resumable session exists yet:
~/.codex/session_index.jsonlcontains athread_nameentry for the new thread id- there is no rollout file for that thread under
~/.codex/sessions/... - there may also be no corresponding persisted thread row yet
This means the CLI can advertise a name-based resume command for a thread that is not actually resumable.
It also has a worse side effect: if there is an older saved thread with the same name, the newer unsaved name entry can win name lookup and block access to the older saved thread.
What steps can reproduce the bug?
Minimal repro:
- Create or enter a directory named
smarty-pants - Run
codex - Observe that Codex prints a resume hint using the thread name
smarty-pants - Exit before sending the first user message
- Run
codex resume smarty-pants - Observe that resume fails even though Codex just suggested that exact command
Shadowing repro:
- Have an older saved thread already named
smarty-pants - Start a new fresh CLI session in a directory that causes the new thread to also be named
smarty-pants - Exit before the first user message is persisted
- Run
codex resume smarty-pants - Observe that Codex resolves the newest unsaved name entry first instead of resuming the older saved thread
What is the expected behavior?
One of these should happen:
- Codex should not suggest
codex resume <name>until a resumable rollout actually exists - name-based resume should skip unresolved / unsaved name entries and fall back to the newest saved session with that name
- ideally both
A fresh unsaved thread name should not block name-based access to an older saved session.
Additional information
This appears to come from thread names being appended to session_index.jsonl before rollout persistence exists, while name-based resume trusts the newest matching name entry.
A high-level fix direction would be either:
- do not index thread names until the session has persisted resumable state
- or make name-based lookup skip entries that do not resolve to a saved rollout path
A UI follow-up would be to stop printing a resume command in the rename confirmation until the session is actually resumable.
This seems related in spirit to #15870, but it is a different repro:
- Codex can print a session ID but fail to persist any resumable local session artifacts after early transport failure #15870 is about early transport failure after a session id is printed
- this repro happens on a normal fresh interactive session with no transport failure required
I have a tested local patch and regression tests for this if the Codex team wants a PR by invitation.
Activity
github-actions commentedon Mar 27, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
paulbettner commentedon Mar 27, 2026
I reviewed #15870, and I do not think this is a duplicate.
#15870 is about early transport failure after a session ID is printed but no local resumable artifacts are persisted.
This issue reproduces without transport failure:
codexsession in a directory likesmarty-pantscodex resume smarty-pantscodex resume smarty-pantsfailsThe distinguishing detail is that
session_index.jsonlalready contains the newthread_name, but there is still no saved rollout for that thread, so name-based resume resolves an unsaved entry.This also causes a separate shadowing bug: an unsaved latest name entry can block access to an older saved session with the same name.
So this is not just “session shown before persistence”; it is specifically “name-based resume trusts unsaved thread-name index entries”.
raye-deng commentedon Mar 27, 2026
Session name shadowing is a great catch. This falls into a pattern we see frequently with AI coding tools: state that's created optimistically but never validated.
The name gets printed before the session is persisted — so the system tells the user 'here's how to resume' based on a promise, not a verified fact. When the user trusts that promise and tries to resume, they hit an opaque failure.
This is structurally similar to a class of issues we've been cataloging in AI-generated code:
In all these cases, the system creates an artifact (an import, a session name, a cross-file reference) optimistically, and downstream consumers trust it without validation.
A structural fix for the resume case might be to write the session metadata atomically with the name assignment — so the name only exists if the backing data also exists. That way, 'can I resume?' is always a valid question to answer.
More broadly, adding a CI-level check that validates assumptions baked into AI-generated code (registry existence, API currency, cross-file consistency) catches these before they become production incidents.
npx @opencodereview/cli scan . --sla L1if anyone wants to see what that looks like.Alek2077 commentedon Mar 27, 2026
Confirmed a related repro locally on codex-cli 0.117.0 on Linux/WSL.
What I verified:
ERROR: No saved session found with ID ...even though the target session is already persisted.~/.codex/sessions/....thread_nameentry in~/.codex/session_index.jsonl.So this seems broader than only "unsaved thread name shadows older saved session". There may be an additional lookup bug affecting some thread names, especially multi-word names, and the regression appears reproducible on 0.117.0.
Update: after rolling back from codex-cli 0.117.0 to 0.116.0, the same previously failing name-based resume command now works locally. That makes this look more like a 0.117.0 regression than a general long-standing lookup issue.
Skip unsaved thread names during resume lookup
Fix stale thread-name resume lookups (#16646)
etraut-openai commentedon Apr 9, 2026
Thanks for the bug report. This will be addressed in the next release.
Fix stale thread-name resume lookups (openai#16646)
Fix stale thread-name resume lookups (openai#16646)