codex icon indicating copy to clipboard operation
codex copied to clipboard

VS Code extension (Windows sandbox): apply_batch rejected because codex-windows-sandbox-setup.exe is missing

Open skyfackr opened this issue 10 months ago • 6 comments

What version of the VS Code extension are you using?

0.4.62

What subscription do you have?

plus/api

Which IDE are you using?

VS Code

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What issue are you seeing?

When Windows sandbox mode is enabled in the Codex VS Code extension, file edit application via apply_batch fails. The VS Code UI shows the operation as "rejected" without an actionable reason.

Observed logs:

  • Extension log: windows sandbox: spawn setup refresh
  • ~/.sandbox/sandbox.log: error indicating setup refresh: failed to spawn codex-windows-sandbox-setup.exe: program not found .

Suspected root cause:

  • The VS Code extension appears to ship and invoke its own bundled codex binary by default.
  • That bundled copy does not include codex-windows-sandbox-setup.exe, so sandbox initialization fails.
  • A separately installed Codex CLI (e.g. via npm) includes the exe and works, which explains why the standalone CLI succeeds while the extension fails.

Impact / risk:

  • The UI only shows "rejected", and the model/tool response also lacks the underlying error cause. This can lead the model to misinterpret it as a permission/approval problem and either stop work or attempt workarounds (e.g., apply modification by shell code) that may bypass VS Code’s file-edit tracking / sandbox intent.

What steps can reproduce the bug?

  1. In VS Code on Windows, install the Codex extension.
  2. Open the Codex Chat tool and start a Codex agent session (either Full agent or the non-full mode).
  3. In the agent UI, open the top-right settings/menu and enable Windows Sandbox.
  4. Ask the agent to make a small file change that requires applying edits via the extension (i.e., an apply_patch / patch-apply edit).
    Example prompt: “Edit README.md and change the first heading text, then apply the patch.”
  5. Observe that the patch application fails (the UI shows the action as rejected / the edit is not applied).

What is the expected behavior?

  • When Windows sandbox mode is enabled, the extension should either:

    1. successfully initialize the sandbox and apply edits via apply_batch, or
    2. fail with a clear, actionable error explaining the exact cause (e.g., missing codex-windows-sandbox-setup.exe) instead of a generic “rejected”.
  • The tool response sent back to the model should include the underlying failure reason (e.g., ENOENT / missing helper binary), not only “rejected”.

  • Safety/behavior: if an editor-mediated file edit tool fails, the assistant should not default to suggesting command-line file writes that bypass the editor/sandbox flow unless the user explicitly asks for such a workaround.

  • The extension should document and support selecting the Codex CLI path (e.g., via chatgpt.cliExecutable, or by resolving codex from PATH) so users can use a working installed CLI when the bundled one is incomplete/outdated.

Additional information

Workaround / mitigation: In VS Code settings.json, point the extension to a separately installed Codex CLI that includes the Windows sandbox helper:

{
  "chatgpt.cliExecutable": "C:\\Path\\To\\Working\\codex.exe"
}

Do not use codex.cmd. It doesn't work.

skyfackr avatar Jan 23 '26 05:01 skyfackr

Hey I would like to work on this issue !

yuvichh avatar Jan 24 '26 14:01 yuvichh

I am seeing this behavior as well in VS Code on Windows 10 Pro. I have the Windows sandbox enabled through my config.toml file. When the agent tries to create a file, a Windows error box pops up outside of VS Code stating "Windows cannot find 'codex-windows-sandbox-setup.exe".

kevin-kore avatar Jan 26 '26 04:01 kevin-kore

@etraut-openai +1 this seems high-impact (Windows sandbox mode in the VS Code extension becomes unusable) and now has multiple confirmations.

Given the symptoms, this really looks like a packaging/regression in the extension-bundled Windows CLI: missing codex-windows-sandbox-setup.exe.

Two concrete improvements that would help immediately:

  • Make the failure actionable: if the helper exe is missing / ENOENT, surface that exact error in the UI/tool output instead of generic “rejected”, and disable (or prompt to disable) Windows sandbox mode.
    • Fix packaging/selection: ensure the bundled Windows CLI shipped with the extension includes the helper, or default to a PATH-installed CLI when sandbox is enabled. Also noting @Yuvraj-cyborg offered to work on this — could be worth assigning if you want community help.

swordfish444 avatar Jan 26 '26 06:01 swordfish444

I've submitted a consolidated fix for several Windows-specific issues in PR #10648, including a fix for the missing \codex-windows-sandbox-setup.exe\ error reported here.

I've updated the sandbox orchestrator to proactively verify the helper's existence and surface a clear, actionable error message instead of a generic 'rejected' status. Additionally, the PR addresses the common 'Apply_Patch' inconsistency on Windows by normalizing line endings (CRLF to LF) during the verification step, which should resolve the flakiness seen during sandbox edits.

For extension users, while pointing \chatgpt.cliExecutable\ to a full Codex CLI installation is a valid workaround, this fix aims to make the out-of-the-box experience reliable.

Ashutosh0x avatar Feb 04 '26 18:02 Ashutosh0x

This has been fixed:

❯ cd ~\.cursor\extensions\openai.chatgpt-0.4.69-universal\bin\windows-x86_64
❯ ls
╭───┬─────────────────────────────────┬──────┬──────────┬────────────╮
│ # │              name               │ type │   size   │  modified  │
├───┼─────────────────────────────────┼──────┼──────────┼────────────┤
│ 0 │ codex-command-runner.exe        │ file │ 597.4 kB │ 2 days ago │
│ 1 │ codex-windows-sandbox-setup.exe │ file │ 626.6 kB │ 2 days ago │
│ 2 │ codex.exe                       │ file │  76.0 MB │ 2 days ago │
│ 3 │ rg.exe                          │ file │   4.2 MB │ 2 days ago │
╰───┴─────────────────────────────────┴──────┴──────────┴────────────╯

ofek avatar Feb 05 '26 23:02 ofek

I believe this is fixed. I will close this issue for now.

skyfackr avatar Jun 05 '26 05:06 skyfackr