openai / openai/codex

Codex desktop intermittently ignores project cwd and runs commands in stale directory

Open
#42,001 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

app bug tool-calls windows-os
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

Component

Codex desktop app for Windows (local task execution)

  • App package: OpenAI.Codex_26.825.6671.0_x64
  • Executable file/product version: 151.0.7922.174
  • OS: Windows
  • Shell: PowerShell

Summary

A task created from a saved local project can have the correct project ID and correct persisted cwd, while a command launched with that same explicit cwd intermittently starts in a stale, unrelated collection directory.

This is not a symlink/junction or path-normalization issue. The command runner appears to ignore the requested working directory and inherit/reuse stale process state.

Expected behavior

When a project is saved as:

C:\Users\<user>\repo\BuildableCV

and a command execution declares that path as cwd, Get-Location and the process working directory should resolve to that directory.

Actual behavior

The task metadata contained:

projectId: 79e3bbab-b1a0-450a-af89-b18140e8d8b8
cwd: C:\Users\<user>\repo\BuildableCV

A diagnostic PowerShell command was also launched with:

cwd: C:\Users\<user>\repo\BuildableCV

but returned:

PWD=C:\Users\<user>\OneDrive - Buildable\Claude
RESOLVED=C:\Users\<user>\OneDrive - Buildable\Claude
GIT_ROOT=

The unexpected directory is a collection folder containing multiple repositories and temporary worktrees. It is not the selected project and is not itself a Git repository.

Another command in the same task was launched in a stale worktree beneath that collection folder:

C:\Users\<user>\OneDrive - Buildable\Claude\work\ai-review-rollout-20260825\buildablecv

Later commands began honoring the requested project cwd again, so the behavior is intermittent.

Verification performed

  • The saved project path is C:\Users\<user>\repo\BuildableCV.
  • The affected task's persisted cwd is the same path.
  • Both the intended checkout and collection folder are ordinary directories, not links or junctions.
  • git -C C:\Users\<user>\repo\BuildableCV rev-parse --show-toplevel returns the intended checkout.
  • Its remote is the expected Azure DevOps repository.
  • The collection folder has no Git root.
  • Explicit Set-Location -LiteralPath ... or git -C ... works around the problem.

Reproduction evidence

Affected task ID:

01a05b04-f306-78f0-9a16-011744968359

Diagnostic command execution ID where declared cwd was ignored:

exec-867cf63c-4362-459e-9679-4469553a8930

Impact

Commands may read or modify the wrong repository even though the user selected a specific project and the command payload contains the correct cwd. Repository-level instruction files may also be missed because discovery starts in the wrong directory.

Suggested fix

Before launching every local command, resolve and set the subprocess working directory from the task/command cwd; do not reuse a shell host's previous process directory. If initialization fails or the resolved directory differs, fail closed and surface the mismatch instead of running the command.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the local command execution entry point that receives the task or command cwd, then reproduce with task 01a05b04-f306-78f0-9a16-011744968359 and execution exec-867cf63c-4362-459e-9679-4469553a8930 in PowerShell. Trace whether the subprocess receives the declared directory rather than reused shell state; done when commands reliably start in the requested cwd and mismatches fail closed.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, rust
Domain
cli, devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.