codex exec resume overrides persisted cwd when -C is omitted
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What version of Codex is running?
Current source at 725b3a44f8d13c8d2f019e1ecbc8ab686466b950; reproduced with standalone Codex 0.149.1.
What happened?
A thread created with an explicit managed-worktree cwd can silently rebind to the caller's current repository workspace when it is resumed without -C.
The app-server protocol already supports the desired behavior: ThreadResumeParams.cwd is optional, and cold resume falls back to the persisted SessionMeta.cwd. However, codex-rs/exec/src/lib.rs currently builds the resume request with:
cwd: Some(config.cwd.to_string_lossy().to_string()),
runtime_workspace_roots: Some(config.workspace_roots.clone()),
After configuration resolution, this no longer distinguishes an explicit -C from the process cwd used as a default. The resume request therefore overrides the persisted checkout even when the user did not request a rebind.
This becomes especially visible after a proxy disconnect or app-server restart, when the thread is cold-resumed from history.
Reproduction
codex exec -C /path/to/managed-worktree "start a task and print pwd"
# Save the thread id, then reconnect or restart app-server.
cd /path/to/repository-workspace
codex exec resume <thread-id> "print pwd"
Expected: the resumed task remains in /path/to/managed-worktree.
Observed: the resume request supplies /path/to/repository-workspace and the task rebinds there.
Suggested correction
Retain whether -C was explicitly supplied when constructing the exec resume request:
- omit
ThreadResumeParams.cwdwhen-Cwas not supplied; - omit the implicit
runtimeWorkspaceRootsoverride in the same case; - preserve explicit
-Cas an intentional rebind; - apply the same rule to any Desktop remote-resume request builder.
The remote TUI path already follows this model by omitting cwd unless there is an explicit remote override.
Acceptance coverage
- Implicit
codex exec resumeemits no cwd or workspace-root override. - Explicit
-Cemits both and still intentionally rebinds. - Cold resume after app-server restart preserves the persisted checkout.
- Warm reconnect to an idle loaded thread preserves the checkout.
- Sandboxed Git and built-in
apply_patchcontinue in the original managed worktree after reconnect.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in codex-rs/exec/src/lib.rs and trace how configuration resolution constructs the resume request, especially ThreadResumeParams.cwd and runtime_workspace_roots. Compare the remote TUI resume request builder, then exercise implicit and explicit -C resumes across cold and warm reconnects. Done means omitted -C preserves the persisted checkout while explicit -C still rebinds it, including sandboxed Git and apply_patch behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100