[Windows] Switching App Agent Environment WSL → Native initializes the sandbox and fixes both App and CLI
What version of the Codex App are you using?
Version 26.616.81150
Released 2026/06/24
What version of Codex CLI are you using?
codex-cli 0.142.0
The CLI was installed globally through npm.
What subscription do you have?
ChatGPT Plus
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
Windows 11
Japanese locale
What issue are you seeing?
The Windows Native sandbox was initially unusable in both the Codex App and Codex CLI.
Commands executed by the Codex App repeatedly failed because the Windows sandbox could not start.
The same failure could be reproduced directly from Codex CLI in PowerShell.
Elevated sandbox test
$cmd = "$env:WINDIR\System32\cmd.exe"
codex -c 'windows.sandbox="elevated"' sandbox windows `
$cmd /c echo CODEX_ELEVATED_OK
Result:
windows sandbox failed: runner error: CreateProcessAsUserW failed: 2
Unelevated sandbox test
codex -c 'windows.sandbox="unelevated"' sandbox windows `
$cmd /c echo CODEX_UNELEVATED_OK
Result:
windows sandbox failed: CreateProcessAsUserW failed: 2
The target executable existed and worked normally outside the Codex sandbox:
Test-Path "$env:WINDIR\System32\cmd.exe"
# True
& "$env:WINDIR\System32\cmd.exe" /c echo DIRECT_CMD_OK
# DIRECT_CMD_OK
codex doctor reported that the following components were healthy:
- CLI installation
- Bundled runtime
- State databases
- Authentication
- Connectivity
Recovery procedure that fixed both the App and CLI
I performed the following steps in the Codex App:
- Opened Settings.
- Changed Agent Environment from Windows Native to WSL.
- Changed Agent Environment back from WSL to Windows Native.
- After switching back, the App displayed the Windows sandbox creation/setup flow.
- Completed the sandbox setup.
After completing the App-triggered setup:
- sandboxed commands in the Codex App stopped failing;
- the same Codex CLI sandbox commands that had previously returned
CreateProcessAsUserW failed: 2started working; - no Codex App or CLI reinstall was performed;
- no CLI downgrade was performed;
- no CLI configuration change was required;
.codexwas not deleted or renamed;- session history was not deleted;
- sandbox directories were not manually reset.
This suggests that the Codex App and CLI use the same underlying Windows sandbox configuration or shared sandbox state.
Changing the Agent Environment in the App appears to have initialized or repaired that shared state.
Steps to reproduce
The exact cause of the initial incomplete state is unknown, but the observed sequence was:
- Start Codex App with Windows Native selected.
- Attempt to execute an agent command that uses the Windows sandbox.
- Observe a Windows sandbox failure.
- Run a direct sandbox test from Codex CLI.
- Observe:
``text``
CreateProcessAsUserW failed: 2
- In Codex App, change Agent Environment from Windows Native to WSL.
- Change Agent Environment back from WSL to Windows Native.
- Observe that the Windows sandbox creation/setup flow now appears.
- Complete the setup.
- Retry commands in the Codex App.
- Retry the direct sandbox tests in Codex CLI.
- Observe that both the App and CLI now work.
Expected behavior
When either Codex App or Codex CLI attempts to use the Windows sandbox, Codex should check whether the sandbox is fully initialized and ready.
If the Windows sandbox is missing, incomplete, or uninitialized, Codex should automatically display or run the required setup flow before attempting sandboxed process execution.
The user should not need to switch the Codex App Agent Environment to WSL and back to initialize a sandbox that is also used by Codex CLI.
Actual behavior
Both Codex App and Codex CLI attempted to use an apparently uninitialized or incomplete Windows sandbox and failed with process-creation errors.
Neither the App nor CLI initially detected the missing setup condition.
The setup flow appeared only after changing the Codex App Agent Environment from Windows Native to WSL and then back to Windows Native.
Completing that App-triggered setup repaired sandbox execution in both the App and CLI.
Additional information
This appears to involve Windows sandbox state shared by Codex App and Codex CLI.
There may be two related problems:
- The shared Windows sandbox was missing or incompletely initialized.
- Its readiness state was cached or incorrectly considered valid by both the App and CLI.
Changing the Agent Environment in the App may invalidate or refresh that state and trigger the previously omitted Windows Native sandbox setup.
Possibly related issues:
- #23894 — WSL app-server remains active after switching back to Windows and breaks Windows sandbox setup
- #28982 — Windows App native sandbox setup helper failure
This case differs because switching from WSL back to Windows Native repaired both the App and CLI by triggering a sandbox setup flow that had not appeared previously.