[Bug]: Windows: Codex resolver prefers `codex.cmd` from anywhere on PATH over `codex.exe`, but supervise cannot launch `.cmd` — session exits silently in ~1.5 s with no child process
Summary
Two defects that only fail in combination, making every Codex session on an affected Windows machine exit silently ~1.5 s after spawn, with nothing run:
- Resolution: AO's Codex binary resolution searches the whole PATH for
codex.cmdbeforecodex.exe. Anycodex.cmdanywhere on the daemon's PATH wins — even when a directory containing the nativecodex.execomes first in PATH order. (A VS Code extension shim at%USERPROFILE%\.local\bin\codex.cmdis enough to trigger it.) - Launch: AO's supervised launch chain (
ao pty-host → ao agent-process supervise → <agent>) cannot start a.cmdchild at all. A 100 ms process monitor during a real spawn showspty-hostandsupervisestarting and the ConPTY being created (conhost --headless), then no child process of any kind — nocmd.exe, nocodex.exe. Supervise reports process-exited ~200 ms later; that exit is the session's only signal, so the session showsexitedwith nothing executed.
Notably, the daemon's own preflight (codex login status) runs the same .cmd fine — the defect is specific to the supervised agent launch.
Steps to reproduce
- Windows, AO 0.11.2, a daemon PATH where some directory contains
codex.cmd(e.g. a VS Code extension shim or npm shim), and the nativecodex.exedirectory listed earlier in PATH. - Spawn a Codex worker session.
- Session exits ~1.5 s after spawn;
first_signal_atequals the exited timestamp; no hooks fire, no file changes.
Proof by inversion: start the daemon with a PATH containing the native codex.exe directory and no codex.cmd anywhere → the same spawn goes working (hooks firing), completes its task, and ao session kill returns cleanly.
Ruled out by direct test: codex.exe stays alive ≥20 s under ao pty-host alone, under pty-host + supervise, with AO's full argv (hooks + trust_level + ~7 KB developer_instructions), in a git-worktree cwd, with and without a live daemon. Codex requires a TTY and AO's ConPTY provides one — a ConPTY-dimensions hypothesis was refuted.
Expected behavior
On Windows, prefer the native codex.exe over any .cmd shim (or at minimum honor PATH directory order); a resolved agent binary that supervise cannot launch should surface a launch error, not a silent instant exit.
Actual behavior
Session state exited ~1.5 s after spawn, no child process ever created, no error surfaced to the user.
AO version
0.11.2 (desktop app; bundled daemon resources\daemon\ao.exe)
Environment
Windows 10 Pro (10.0.19045) x64; ConPTY runtime; native codex.exe install plus a VS Code-extension codex.cmd shim elsewhere on PATH
Logs / extra context
- Related: #2582 fixed
.exe-vs-.cmdshadowing in the auth probe resolution; this report is the inverse preference (.cmdfirst) in the session launch path, plus the supervise layer's inability to start.cmdchildren at all. - A caution against fixing this by wrapping
.cmdlaunches incmd.exe /c: with the npm claude.cmdshim, Go'sos/execruns it throughcmd.exe /c, andcmd.exetruncates AO's multi-line--append-system-promptargument at the first newline — the agent then fails withError: Input must be provided either through stdin or as a prompt argument when using --print. With the nativeclaude.exethe same argv survives intact (verified on the live process command line). So.cmdshims are a bad launch target on Windows in general; preferring native.exefixes both. - Duplicate search: #2582, #3396, #3326, #2832 — none cover the launch-path
.cmdpreference or the supervise.cmdlaunch failure.
I've started investigating this. From the issue description, it looks like there are two separate behaviors involved:
The Windows resolver prefers a codex.cmd found anywhere on PATH over a native codex.exe. The supervised launch path cannot execute the resolved .cmd target, causing the session to exit immediately.
I'll trace the resolver and launch path to confirm where the .cmd preference is introduced before proposing a fix
I've traced the Windows resolver to backend/internal/adapters/agent/codex/codex.go and added a regression test locally that models the reported PATH ordering (codex.exe in an earlier PATH directory, codex.cmd in a later one).
From the current resolver logic, it appears PATH precedence is violated because exec.LookPath is called separately for codex.cmd and codex.exe, allowing a later .cmd shim to win before an earlier native executable is considered.
I'm validating the behavior before proposing a fix.
I opened a PR implementing a directory-first Windows PATH scan while preserving the existing native executable resolution logic. I'd appreciate any feedback on whether this matches the intended fix for #3409.
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @illegalcall
- @pulkit7070
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @pulkit7070 here.
For faster context or live questions, you can also join the AO Discord.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
Closing as a duplicate of #5323. Windows Codex resolution and shim launch remain tracked there.
i checked this on windows and found that ao can pick codex.cmd ahead of codex.exe even when the exe comes first in path. my codex session did not exit as described, so i can confirm the path ordering part from my side, but not the launch failure.