codex resume <session-name> can resolve same-named session from another cwd
What version of Codex CLI is running?
codex-cli 0.142.5
What subscription do you have?
N/A for this report. The issue is in local CLI session selection before a model request is made.
Which model were you using?
N/A.
What platform is your computer?
Microsoft Windows 10.0.19044.7291
What terminal emulator and version are you using (if applicable)?
Not sure.
What issue are you seeing?
codex resume <session-name> appears to resolve a same-named session from another project/cwd instead of first applying the default current-cwd scoping used by nearby resume flows.
Observed shape:
- Start in project B.
- Run:
codex --dangerously-bypass-approvals-and-sandbox resume MAIN
- There is no intended
MAINsession for the current project/cwd. - Codex resumes a
MAINsession from another project/cwd instead.
This is surprising because the local resume picker and resume --last behavior appear to be cwd-scoped by default, with --all serving as the explicit opt-in for global session selection. Passing an explicit session name seems to bypass that cwd scoping and perform a global name lookup.
What steps can reproduce the bug?
One possible repro shape:
- Create or have a saved session named
MAINin project A. - Create or enter a different project B.
- Ensure project B does not have the intended saved session named
MAIN, or at least that the global name lookup can see a same-named session from project A. - From project B, run:
codex resume MAIN
Current behavior: Codex can resume the MAIN session from project A.
Expected behavior: Codex should first look for a saved session named MAIN in the current cwd/project. If no current-cwd match exists, it should report that no matching session was found for the current cwd and suggest running the picker or using --all/a UUID for global selection.
What is the expected behavior?
For local sessions, name-based resume should preserve the same cwd scoping model as the default resume picker and resume --last:
codex resume <name>should prefer or restrict to the current cwd by default.codex resume --all <name>or another explicit global mode should be required to resolve a same-named session from another cwd.- If multiple same-named sessions exist, the current-cwd match should win over unrelated cwd matches.
- If no current-cwd match exists, Codex should avoid silently resuming an unrelated project session.
This would keep --all as the explicit opt-in for global session selection and avoid accidentally entering the wrong project context when users use common session names like MAIN.
Additional information
I searched for existing issues and did not find an exact duplicate for codex resume <session-name> crossing cwd boundaries. Related but different items:
- #19931 moved local
/resumecwd filtering intothread/list, but explicitly listedcodex resume <id>as not affected. - #21089 fixed
fork --lastcwd filtering and preserved--allas the explicit global latest-session selection. - #20945 reported the corresponding
fork --lastissue where a command could select a session from another project. - #15943 covered name-based resume shadowing/unsaved name entries, but not cwd scoping for same-named sessions across projects.
- #22037 and #28559 cover cwd-filtered
/resumepicker/listing behavior, but not explicit name lookup.
A narrow fix direction may be to apply the same cwd filter used by nearby resume flows before resolving name-based local sessions, while preserving UUID lookup precedence and explicit global behavior under --all.