Skip to content

agents on Windows: start, probe and show the .exe a spawn actually finds - #90

Merged
blockmandev merged 2 commits into
mainfrom
fix/agent-start-what-was-found
Nov 13, 2026
Merged

blockmandev merged 2 commits into
mainfrom
fix/agent-start-what-was-found

Conversation

@blockmandev

Copy link
Copy Markdown
Member

Found while verifying #19. On Windows, incode's discovery took where's first line, which for npm's codex is a shell script or codex.cmd, but the spawn (Command::new("codex")) starts only a .exe. Measured: the shell's codex was npm's 0.167.0 and --admin showed npm's path, yet every run started the Codex desktop app's codex.exe 0.145.0, further down PATH (each run's version read from codex's own session files).

Now discovery resolves the .exe a spawn finds, in PATH order, and uses that absolute path for the run, the version probe and the display. It's one program throughout. A .cmd shim isn't started in its place, because Rust refuses some batch-file arguments (newlines) and prompts have newlines. Off Windows, or when no .exe is on PATH, discovery works as before.

Test: the measured layout resolves to the desktop app's exe, a .cmd-only agent resolves to nothing, and a name with an extension is taken as written. Agent tests: 432 pass. clippy is clean.

Measured on Windows 11: the shell's `codex` was npm's (0.167.0, a
`codex.cmd` shim first on PATH), `incode --admin` showed npm's path, and
every run incode started was the Codex desktop app's codex.exe, 0.145.0,
further down PATH (each run's version read from codex's own session
file). Discovery took `where`'s first line, which lists every PATHEXT
extension; the spawn was `Command::new("codex")`, which starts only a
`.exe`. So incode named one program and ran another.

Now discovery resolves the `.exe` a spawn of the bare name finds, in PATH
order (exe_on_path), and names it by its absolute path as the command the
run starts (task_run::drive, cli::prepare, acp_agent), the program probed
for its version and the path shown: one program throughout. A `.cmd` shim
is not started in its place: Rust refuses some arguments to a batch file,
newlines among them, and a prompt has newlines. Off Windows, and when no
`.exe` is on PATH, discovery is as before.

Test: the measured layout (npm's codex and codex.cmd first, the desktop
app's codex.exe later) resolves to the desktop app's exe; a .cmd-only agent
resolves to nothing; a name with its extension is taken as written.
Agent tests: 432 pass; clippy clean.
…ows paths)

It failed on Linux and macOS CI: there, C:\npm is not a folder path, so
join() builds a different path than the test expects. exe_on_path is only
called by a Windows build.
@blockmandev
blockmandev merged commit 732483d into main Nov 13, 2026
12 checks passed
@blockmandev
blockmandev deleted the fix/agent-start-what-was-found branch November 15, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant