Sandboxed PowerShell commands intermittently fail on Windows with `windows sandbox: spawn setup refresh`
What version of the IDE extension are you using?
openai.chatgpt@26.527.31454
What subscription do you have?
ChatGPT Plus
Which IDE are you using?
VS Code 1.122.1
What platform is your computer?
Microsoft Windows NT 10.0.26200.0 x64
What issue are you seeing?
Sandboxed shell commands frequently fail immediately on Windows before the command itself runs.
The repeated error is:
execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })
This happened with simple read-only PowerShell commands in a workspace on E:\..., including:
Get-ChildItem -Force
It also happened with search commands such as:
rg -n "score|评分|fallback|兜底|short|truncate|limit|85|90|75|rank|排序" -S .
In one session, both commands failed when run through the sandbox. Retrying Get-ChildItem -Force outside the sandbox with escalation succeeded immediately.
The same sandbox startup error also occurred when trying to query local tool versions:
code --version
code --list-extensions --show-versions
Both failed inside the sandbox with windows sandbox: spawn setup refresh, then succeeded when rerun outside the sandbox with approval.
This makes normal repo inspection unreliable because even basic read-only commands fail during sandbox setup.
What steps can reproduce the bug?
- Use the Codex/OpenAI IDE extension in VS Code on Windows.
- Open a workspace on a Windows drive, for example an
E:\...repo. - Start a Codex session with filesystem sandboxing enabled, e.g.
workspace-write. - Ask Codex to inspect the repo or run a simple read-only command.
- Codex attempts a sandboxed PowerShell command such as:
Get-ChildItem -Force
- The command fails immediately with:
execution error: Io(Custom { kind: Other, error: "windows sandbox: spawn setup refresh" })
- Rerun the same command outside the sandbox with escalation/approval.
- The command succeeds.
Expected behavior:
Sandboxed read-only PowerShell commands should run normally, or sandbox startup failures should provide a more actionable diagnostic.
Actual behavior:
The sandbox fails during startup/setup with windows sandbox: spawn setup refresh, blocking even basic read-only commands.
What is the expected behavior?
_No response_
Additional information
_No response_
5 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
https://github.com/openai/codex/issues/24391
Sharing a concrete occurrence of the "setup refresh" command actually failing (not just erroring on sandboxed commands), with timestamps, in case it helps narrow down the trigger.
Environment: Windows 11, Codex Store app
OpenAI.Codex_26.715.10079.0.What happened (from
.codex\.sandbox\sandbox.<date>.log):User-visible symptom: during the ~60s hang, an actual (non-hidden)
powershell.execonsole window stayed on screen, overlapping the Codex chat UI — this is presumably the normal behind-the-scenes "setup refresh" powershell invocation becoming visible/foregrounded because it didn't complete quickly like it normally does (every other invocation in the same log, both before and after, completes in well under 1 second). The active chat session's backend (kernel.js) then had to restart twice within a few minutes.Package status (
Get-AppxPackage ... | select Status) wasOkthroughout this particular incident — so this looks like a different/lighter failure mode than theModified, NeedsRemediationpackage-level corruption I reported over in #17901, but it's the same "setup refresh" mechanism visibly misbehaving. Happy to share the full log excerpt if useful.Follow-up with a controlled reproduction, since a single occurrence isn't strong evidence on its own — this was tested twice with clean before/after measurements.
Setup: Windows 11, Codex Store app
OpenAI.Codex_26.715.10079.0. Measured the backend process CPU time directly viaGet-Process <app-server PID>.CPU(the process iscodex.exe -c features.code_mode_host=true app-server --analytics-default-enabled).Trial 1 (fresh app restart, then opened a specific existing task):
ChatGPT.exe+ thecodex.exe app-serverprocess) was killed and restartedTrial 2 (independent repeat, fresh restart, then reopened the same task):
The task in question: it was mid-flow, waiting on an external OAuth consent screen (Cloudflare) that had gone stale — by the time it was reopened, the consent link itself returned "authorization failed" in the browser (the backend that originally issued it had been restarted several times since). I can't confirm this staleness is mechanistically why it spins — I looked for corroborating detail in the sandbox log (
.codex\.sandbox\sandbox.<date>.log) during both runaway windows and found no relevant entries at all for either occurrence, so whatever loop is running isn't going through the logged "setup refresh" path discussed above.Summary of what's now confirmed:
app-serverprocess within ~90 seconds.Happy to share the task content or further diagnostics if useful.
One more update — I think I've narrowed down the actual trigger, with a clean A/B test.
Hypothesis after the last comment: it's not OAuth/the sandbox refresh mechanism in general, but specifically reopening a task that's holding a stale/expired pending browser-consent flow.
Test A (reproduces the runaway, 2/2): reopened a task that was left mid-flow waiting on a browser OAuth consent screen (Cloudflare, via
wrangler login) that had gone stale — the original local callback listener was long gone (the consent link itself no-longer resolved / the redirect came backERR_CONNECTION_REFUSEDwhen tested). Both times, CPU in theapp-serverprocess climbed to ~95-100% of one core within ~90 seconds and did not settle on its own.Test B (does not reproduce, clean): started a brand-new task, ran
wrangler loginfresh, and completed the browser consent promptly (within the tool's own callback-listener timeout window, ~2 min). CPU stayed flat (~0.1%) throughout, before, during, and after. Verified the OAuth actually completed successfully (Cloudflare's own "authorization granted" confirmation page, and the CLI reporting a valid logged-in account).Also worth noting: when I added an instruction telling the agent not to retry
wrangler loginin a loop if it doesn't complete within ~2 minutes, it followed that correctly (ran it once, waited, then stopped and reported back) — so at least in this environment, the agent's own retry behavior isn't what's spinning the CPU. The runaway seems to live in theapp-server/sandbox layer itself, specifically tied to resuming a task that has a dangling/expired OAuth wait state, not to normalwrangler loginusage in general.Not a fix, just hopefully a tighter repro condition than before.