fix(runtime): resolve codex .cmd shim path so Windows spawns don't fail#105
Merged
Conversation
On Windows, npm installs the codex CLI only as a .cmd shim, and create_subprocess_exec (CreateProcess) does no PATHEXT resolution — _run_codex_cli_with_stdin spawned the bare "codex" name and failed with FileNotFoundError ([WinError 2]) on every codex harness call. Each schema attempt then surfaced as "Schema retry N provider error: [WinError 2]" and reasoners fell back to their advisor-failure defaults in ~500ms. Route cmd[0] through the AgentField SDK's resolve_cli_command, which resolves the shim's real path via shutil.which and is a no-op on POSIX. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Windows, every codex harness call fails instantly with
[WinError 2] The system cannot find the file specified._run_codex_cli_with_stdininswe_af/runtime/codex_harness_patch.pyspawns the bare"codex"name viaasyncio.create_subprocess_exec, butCreateProcessdoes no PATHEXT resolution and npm installs the codex CLI only as a.cmdshim — so the spawn never finds it, even though the shell does.The AgentField SDK already ships the fix for exactly this (
agentfield.harness._cli.resolve_cli_command, which resolves the shim's real path viashutil.whichand is a no-op on POSIX), but this monkeypatch bypasses the SDK's spawn path and never picked it up. Mac/Linux never hit the bug, which is how it went unnoticed.Symptoms
Schema validation retry N/2: The output file was NOT created.followed bySchema retry N provider error: [WinError 2] The system cannot find the file specified.Changes Made
cmd[0]through the SDK'sresolve_cli_commandbeforecreate_subprocess_exec(no-op on POSIX and for paths that already carry a separator).Test Plan
make checkgreen (1130 passed, 1 skipped) on Python 3.12run_retry_advisorinvoked withai_provider=codex/model=gpt-5.6-lunareturns real structured advice through the codex CLI (previously the instant WinError 2 fallback)🤖 Generated with Claude Code