Launch ACP agents directly on Windows - #175
Open
MLuc24 wants to merge 1 commit into
Open
Conversation
Every ACP session was spawned through /usr/bin/env -C <cwd> <binary>, which does not exist on native Windows, so process creation failed with "the system cannot find the path specified" before the agent started. env -C is there to give the child the session working directory, because AcpAgentConfig carries only a command, arguments and environment, and the SDK never calls current_dir when it spawns. Windows has no equivalent that keeps argument boundaries intact without going through a shell. It does not need one: the session cwd already travels in the ACP session request, which NewSessionRequest, ResumeSessionRequest and LoadSessionRequest all carry. On Windows the resolved binary is launched directly and the agent is told where to work over the protocol. Closes egoist#149
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.
Closes #149.
Problem
Every ACP session is spawned through
/usr/bin/env -C <cwd> <binary>. That path does not exist on native Windows, so process creation fails withos error 3— "the system cannot find the path specified" — before the agent is ever started. @qiankun229 reported it against Grok Build and traced it tosdk_agentincrates/waku-core/src/driver/acp.rs; since that function builds the launch for every ACP provider, none of them can start on Windows.Why
env -Cis there, and why Windows can do without itenv -Cis not incidental — it is how the child gets the session working directory.AcpAgentConfigcarries only a command, arguments and environment:and
spawn_processbuildsstd::process::Command::new(&self.config.command)without ever callingcurrent_dir, so there is no field to route a cwd through. Windows has noenvequivalent that sets a working directory while keeping argument boundaries intact —cmd /C cd /d … &&would mean going through a shell, which is exactly what the comment above that code says the current approach avoids.It turns out nothing needs to be routed. The session cwd already travels in the ACP session request, and this file sends it on all three paths:
So on Windows the resolved binary is launched directly, and the agent learns where to work over the protocol. Unix keeps
env -Cunchanged, including the process-group lifecycle behaviour the SDK relies on there.The platform split is a runtime
cfg!(windows)rather than#[cfg]blocks so both branches stay type-checked on every target.Checks
cargo test -p waku-core --lib— 340 passed, 0 failedcargo check— cleancargo fmt --package waku --package waku-protocol --package waku-client --package waku-core --package waku-daemon -- --check— reports pre-existing diffs in about 40 places (src/app.rs,src/input.rs,src/md/highlight.rs,crates/waku-core/src/driver/codex.rsand others) on an unmodified checkout ofmain; nothing indriver/acp.rs, the only file this touchesbunprotocol and client checks were not run: no Rust wire type changes here, sopackages/waku-client/src/generatedis untouchedThe new test asserts the launch configuration per platform. It fails on
mainwhen run on Windows, which is the point of keeping it:Known limitations
cwd— which is the contract — is unaffected, but one that quietly relies on its process cwd instead would see a different directory. If that turns out to matter for a specific provider, the fix belongs upstream inagent-client-protocolas acwdonAcpAgentConfig, and I'd be glad to open that./usr/bin/env, that the same configuration on Unix is byte-for-byte what it was, and that the wholewaku-coresuite still passes. The claim thatAcpAgentConfighas no working-directory field was read out of the vendoredagent-client-protocol-2.0.0source rather than assumed. The reporter's own validation — routing/usr/bin/envto Git for Windows'env.exeand watching the same command succeed — is the evidence that removing that hop is what unblocks the spawn.