codex resume --last can start a fresh session even when codex resume picker can continue the intended thread
What version of Codex is running?
codex-cli 0.118.0
What subscription do you have?
Plus
Which model were you using?
_No response_
What platform is your computer?
Windows
What issue are you seeing?
codex resume works as expected when I pick the intended prior session from the interactive picker, but codex resume --last starts what appears to be a fresh session instead of continuing that same session.
This does not look like an expected UX difference between picker mode and --last. From reading the open-source code, --last appears to apply additional filtering when resolving the latest session (for example cwd / source kind / model provider), and when that lookup fails the result is effectively a fresh session.
That makes resume --last behave very differently from what users usually expect from "resume the last session", especially when the plain resume picker can still find and continue the expected thread.
What steps can reproduce the bug?
- Start a Codex session in a repository / workspace.
- Exit Codex.
- Run
codex resume, choose the most recent expected session from the picker, and confirm that it resumes correctly. - Exit again.
- Run
codex resume --lastfrom the same environment. - Observe that Codex starts what appears to be a fresh session instead of continuing the same thread.
What is the expected behavior?
codex resume --last should continue the same most recent session that a user would reasonably expect from the picker flow, or at minimum fail clearly instead of silently falling back to a fresh session.
Additional information
Related UX discussion: #4545
I think there are two separate concerns here:
- Bug:
resume --lastcan behave like a fresh session even though the picker can still resume the intended thread. - UX / semantics: users are likely to interpret
--lastas "resume the globally latest session" rather than "resume the latest session matching hidden filters".
Even if the filtering is intentional, silently landing in a fresh session seems wrong.
7 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
resume --lastis intended to use the same filtering logic as the default resume picker.resume --lastalso pairs with--allwhich eliminates some of the filters (notably, the cwd filter).Can you say more about which differences you're seeing in filtering between
resume --lastand the resume picker?Thanks, that clarified it.
I tested
codex resume --last --all, and that behaves as I expected. It correctly restored the same session state after restarting Codex.So it seems the behavior I was seeing is tied to the default filtered behavior of
codex resume --last, rather than--lastin general.That said, from a user perspective, I think it is natural to expect
codex resume --lastto resume the same session that would be selected as the most recent one incodex resume.Now that I understand the distinction, I can use
--allwhen I want that behavior. Thanks for the clarification.A correction to my earlier comment: my interpretation of
--allwas mistaken.It was not that
codex resume --last --allconsistently gave me the behavior I wanted. It only appeared to do so in cases where the latest global session happened to match what I wanted to resume.I think I found a more specific explanation for what I was seeing on Windows.
The resumed session path was shown as:
\\?\C:\Users\info\source\repos\TerminalHubwhile my current working directory was:
C:\Users\info\source\repos\TerminalHubSo these appear to refer to the same directory, but with different path representations.
After reading the source more closely, it looks like
resume --lastgoes throughthread/listwith acwdfilter, and that filter currently appears to compare paths directly in the app-server path:summary.cwd == expected_cwdBy contrast, the picker-side filtering appears to use normalized path comparison.
If that reading is correct, then on Windows this could explain why
codex resume --lastfails to match a session in the same directory when one side uses an extended path form like\\?\C:\...and the other uses the normalC:\...form.So my current guess is that the issue may be a Windows path normalization mismatch in the
cwdfilter used byresume --last.<img width="709" height="54" alt="Image" src="https://github.com/user-attachments/assets/2e071e56-e848-4e79-9123-8245aa164f0f" />
Here is the prompt I saw on Windows. The session directory is shown as
\\?\C:\...while the current directory is shown asC:\..., even though they refer to the same location.Thanks for the bug report. This will be addressed in the next release.
Thanks for the quick fix and for closing the loop on this.
I appreciate the investigation and the Windows path normalization fix. I'm glad the issue was identified and addressed so quickly.