Exact error
Match the message before using the fix
windows sandbox: runner error: CreateProcessAsUserW failed: 1312CreateProcessAsUserW failed: 1312 (The specified logon session does not exist. It may already have been terminated.)Quick answer
Start here
Error 1312 is not the same branch as `CreateProcessAsUserW failed: 5`. If it began after opening another VS Code window, close the extra Codex/VS Code windows and start a fresh session in one window. If it occurs in a single window, preserve the sandbox log and version details: the upstream issue shows setup can succeed while process creation still fails, and no permanent fix is confirmed.
Diagnosis
Why it happens
- One report shows sandbox setup completing successfully before the runner fails to create the command process.
- A second report reproduces error 1312 after another VS Code window ends Full access in the first window and invalidates its sandbox logon session.
- The error code identifies a missing or terminated logon session; it does not by itself prove a filesystem ACL or executable-path problem.
Safest first
Fixes, in order
Test the multi-window trigger
Applies when: The error started after opening another VS Code or Codex window
The upstream multi-window report gives a repeatable trigger and a narrow recovery boundary.
- Save work in every open VS Code window.
- Close the extra windows and their Codex sessions.
- Start one fresh VS Code window, open the project, and begin a new Codex session.
- Run a harmless command such as `Get-Location` before restoring the previous permission mode.
Expected: A fresh single-window session can create the sandboxed process without error 1312.
Separate setup success from runner failure
Applies when: Error 1312 also occurs with only one Codex window
The first upstream report recorded successful ACL/setup work followed by failure at the process-creation boundary.
- Find the matching `.codex/.sandbox` log for the failed command.
- Record whether setup refresh completed and whether the failure appears only at `SpawnChild` or runner invocation.
- Record Codex app, extension, CLI, Windows build, and active sandbox mode.
- Redact usernames, project paths, commands, and tokens before sharing the log excerpt.
Expected: The report distinguishes setup failure from a stale or missing sandbox logon session.
Update Codex and create a clean session
Applies when: The current session still fails after removing the multi-window trigger
There is no confirmed configuration edit for this open issue, so the safe recovery is a current build and a newly created session rather than broad permission changes.
- Update Codex through the official app or extension channel.
- Fully close the affected client and verify no old extension-owned Codex window remains active.
- Start a new session and rerun a read-only command.
Expected: The new client session owns a valid sandbox logon session, or the same failure is captured on a current version.
Verification
Prove the fix worked
- Run `Get-Location` and one read-only project command inside the normal sandbox.
- Open a second VS Code window only as a controlled test, then confirm the first window retains its permission state.
- Verify the sandbox log no longer ends at `CreateProcessAsUserW failed: 1312`.
Escalation
If it still fails
- Do not reset broad Windows ACLs or weaken system security settings; the evidence points to a logon-session lifecycle failure.
- Do not reuse the error-5 fix unless the exact code is 5 rather than 1312.
- Attach a redacted sandbox log and note whether multiple app-server processes were running when reporting upstream.
Scope
Environment and version notes
- The original report used Codex app/runtime 26.616.81150 on Windows 11 with the unelevated sandbox.
- The multi-window report used VS Code 1.128.0, extension 26.707.41301, and bundled CLI 0.144.0-alpha.4 with elevated sandboxing.
- Both upstream issues remained open when rechecked September 23, 2026.
Evidence
Sources
Source labels describe the evidence available on the checked date. A closed issue is not automatically a shipped fix.