Windows Codex Desktop Local mode: agent commands run from C:\ while integrated terminal uses project directory
What version of the Codex App are you using (From “About Codex” dialog)?
26.429.30905
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
In Codex Desktop on Windows, I opened a project with Add Project / Open Project and started a Local mode thread under that project.
The integrated terminal is correctly opened in the project directory:
D:\path\to\project
However, when I ask the Codex agent in the chat to run:
Get-Location
the agent command output returns:
C:\
So the integrated terminal and the agent-run command environment appear to have different current working directories.
This is confusing because the UI shows the thread is under the project and Local mode is selected, but agent-run PowerShell commands do not start in the project directory.
What steps can reproduce the bug?
Uploaded thread: 019ded06-0f99-7473-9e89-b2073dfee992
Steps to reproduce:
- Open Codex Desktop on Windows.
- Use Add Project / Open Project.
- Select a project folder, for example:
D:\path\to\project
- In the left sidebar, click the project entry and create a new thread from that project.
- Make sure the bottom mode selector shows Local mode.
- In the Codex chat, ask the agent to run:
Get-Location
- Observe that the chat/tool output returns:
C:\
- Open the integrated terminal in the same thread.
- Run:
Get-Location
- Observe that the integrated terminal returns the correct project path:
D:\path\to\project
The integrated terminal cwd is correct, but the agent command runner cwd is C:\.
What is the expected behavior?
In a Local mode project thread, agent-run PowerShell commands should start in the selected project directory, matching the integrated terminal cwd.
For this project, when the agent runs:
Get-Location
I expect it to return:
D:\path\to\project
instead of:
C:\
The integrated terminal and the agent command runner should use the same project working directory, or the agent command runner should inherit the Local project cwd.
Additional information
Screenshots show:
- The thread is under the project in the sidebar.
- Local mode is selected at the bottom of the composer.
- The integrated terminal returns the correct project path:
D:\path\to\project
- The agent-run chat command Get-Location returns:
C:\
Workaround:
If I explicitly prepend every agent command with:
Set-Location -LiteralPath "D:\path\to\project";
then commands work as expected. But this has to be done inside the same command invocation, because the next agent-run command may again start from C:\.
4 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I am seeing the same symptom in Codex Desktop on Windows: in a Local project thread, agent-run PowerShell commands start from
C:\instead of the selected project directory.In my case, the issue occurs under Default permissions / native Windows sandbox. With Full access,
Get-Locationreturns the correct project path.I first reproduced this in an existing project located under Dropbox:
I then completely reinstalled Codex App and rebuilt the
.codexdirectory from scratch, but the issue still reproduced.To determine whether this was specific to my existing project, I created multiple empty projects at different paths on the same machine and asked the agent to run
Get-Location.Paths where the agent returned
C:\:Paths where the agent returned the correct project directory:
In this environment, the failure appears to be triggered by projects located under the actual Dropbox-synced folder where a Dropbox-relative path segment begins with
_.I do not know whether the original reporter is also using Dropbox or another cloud-synced folder, so this may not be the same root cause. However, it seems potentially relevant because the visible symptom is identical: the project is opened correctly in the app, but the agent-run command environment falls back to
C:\.Additional observations:
.codexstate.writable_rootsentry makes access to that project possible without approval, but does not correct the initialGet-Locationresult.C:\does not appear to become broadly writable in my testing, so this may be a workspace/cwd handoff or sandbox writable-root registration problem rather than a complete sandbox bypass.Just to add another data point: I’m hitting what looks like the same issue on Windows.
My project is opened in Codex Desktop Local mode under:
D:\47065\Documents\wasm-optimization
But when the agent runs a command from chat, the working directory is still:
C:\
For example,
Get-Locationfrom the agent returnsC:\.I also tried changing my default terminal to CMD, but that didn’t change the agent-run command environment. Running
cmd /c cdfrom the agent also returnsC:\, so this doesn’t look like just a PowerShell-vs-CMD thing.One extra detail: in my case, under the default sandbox/permissions, even explicitly running:
Set-Location -LiteralPath "D:\47065\Documents\wasm-optimization"; Get-Location
can hit
Access is denied. But if I approve/run the same check with elevated access, it can enter the project directory correctly.So this seems very close to what’s described here: the project/thread is tied to the right folder, but the agent command runner starts from
C:\instead of the project cwd. Also, each agent command seems to start fresh, so changing directory in one command doesn’t carry over to the next one.I am seeing what appears to be the same issue in a newer Codex Desktop build. I was able to narrow it down further: the agent command runner's process working directory is correct, but sandboxed Windows PowerShell's own provider location is incorrectly initialized to
C:\.Environment
26.721.4979.00.146.0-alpha.3.1Microsoft Windows NT 10.0.26200.0, x645.1.26100.8875C:``
toml
``[windows]
sandbox = "elevated"
Provider location and process CWD disagree
The agent ran this with the repository explicitly supplied as the command
workdir:The result was:
Test cases
I compared several execution paths using the same requested workdir:
| Execution path | Reported location |
|---|---|
| Sandboxed PowerShell:
(Get-Location).Path|C:\|| Sandboxed PowerShell:
[Environment]::CurrentDirectory| Correct repository || Sandboxed PowerShell with login-shell behavior disabled | Same mismatch |
| Sandboxed
cmd.exe:cd| Correct repository || PowerShell outside the sandbox | Both values are the correct repository |
However, I have only noticed the issue intermittently during normal Codex use. I have not been routinely inspecting the agent's command traces, so I cannot yet say whether the trigger is nondeterministic or whether some earlier event puts a thread or sandbox session into this state. Once triggered here, it was stable across the repeated calls.
Workaround attempts
In this occurrence, explicitly changing location did not provide the workaround described in the issue:
PowerShell returned:
At the same time, commands using absolute paths could read files in the repository, and Codex could edit files there.
Disabling login-shell behavior did not change the result, which makes a PowerShell profile script less likely to be the cause. Bypassing the sandbox did correct it, but that is not an appropriate routine workaround.
This also appears to be the same underlying problem reported later in #21606.
Trace and suggested fix
See: https://github.com/openai/codex/issues/21606#issuecomment-5089399505