codex fork --last ignores default cwd filtering and can fork a session from another project
What version of Codex CLI is running?
codex-cli 0.128.0
What subscription do you have?
ChatGPT Pro
Which model were you using?
gpt-5.5
What platform is your computer?
Darwin 25.3.0 arm64 arm
What terminal emulator and version are you using (if applicable)?
cmux 0.63.2 (79) [179b16ce6]
What issue are you seeing?
codex fork --last appears to ignore the default cwd filtering used by nearby session-selection flows.
For local sessions, codex resume --last selects the latest session for the current cwd unless --all is passed. The fork picker also applies cwd filtering by default unless --all is passed.
However, the local codex fork --last path appears to pass no cwd filter when looking up the latest session. As a result, running codex fork --last from one project can select and fork a newer session from a different project.
This makes codex fork --last behave like codex fork --last --all with respect to cwd filtering.
What steps can reproduce the bug?
A minimal scenario is:
- Create or have a recent Codex session in project A.
- Create or have an older Codex session in project B.
cdinto project B.- Run:
codex fork --last
Expected target would be the latest session for project B.
Current behavior appears to allow the latest session from project A to be selected instead, because the local fork --last lookup does not pass a cwd filter.
From code inspection:
resume --lastuseslatest_session_cwd_filter(...).- The fork picker also applies cwd filtering by default unless
--allis passed. - The local
fork --lastbranch passesNoneas the cwd filter.
What is the expected behavior?
For local sessions, codex fork --last should mirror codex resume --last and the fork picker default behavior:
codex fork --lastshould select the latest session for the current cwd.codex fork --last --allshould select the latest session across all cwd values.
This would keep --all as the explicit opt-in for global session selection.
Additional information
I searched for existing issues/PRs around fork --last, cwd filtering, latest session selection, and resume/fork/history cwd behavior, and I did not find an exact duplicate.
Related but different items:
- #19931 moved local resume/fork picker cwd filtering into
thread/list, butcodex fork --lastappears to remain unaffected. - #17302 is about
resume --lastcwd filtering/path normalization and supports the expectation that--lastshould match picker filtering. - #15494 involved provider filtering rather than cwd filtering.
- #14257 is about restored cwd casing under WSL, not source-session lookup.
A narrow fix direction would be to make the local fork --last path use the same latest_session_cwd_filter(...) helper as resume --last, while preserving --all and remote cwd override behavior.