fix(acp): emit [Workspace] section for Windows drive-letter cwd - #3130
Open
kcao-gss wants to merge 1 commit into
Open
fix(acp): emit [Workspace] section for Windows drive-letter cwd#3130kcao-gss wants to merge 1 commit into
kcao-gss wants to merge 1 commit into
Conversation
workspace_section() used cwd.starts_with('/') to detect absolute paths,
which is always false for Windows drive-letter paths (C:\Users\...).
Since cwd comes from std::env::current_dir() in the same process, this
meant Windows agents never received the [Workspace] grounding section.
Replace the string-prefix check with std::path::Path::is_absolute() +
parent().is_some(), which generalizes the original guard (reject
relative paths, reject the "/" current_dir() failure sentinel) to also
reject Windows roots (C:\, \\?\C:\) uniformly across platforms.
Gate the two POSIX-path assertions in the affected tests behind
#[cfg(unix)], since Path::is_absolute() correctly returns false for a
POSIX-style path on Windows, and extend the workspace_section doc
comment to record why the platform-dependent predicate is correct here
rather than a bug.
Fixes block#3124
Signed-off-by: Kyler Cao <kcao@gssmail.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
workspace_section()gated the[Workspace]system-prompt block oncwd.starts_with('/'), so it was silently dropped for every Windows agent —cwdcomes fromstd::env::current_dir()(lib.rs:1547-1550), which on Windows is always drive-letter form (C:\Users\<user>\.buzz).Replaces the string-prefix test with
Path::is_absolute() && Path::parent().is_some(), which preserves both invariants the original guard existed for — reject relative paths, reject the/sentinelcurrent_dir()falls back to on failure — and generalizes the second to rejectC:\,\\?\C:\, and UNC share roots uniformly.Fixes #3124
Scope, stated honestly
This is not "Windows agents don't know about their workspace."
base_prompt.md:84-100already ships the Workspace Layout table (REPOS/,OUTBOX/) and the "never runfindover$HOME" instruction unconditionally on every platform, and the agent's OS cwd is the workspace (the child inherits it). What Windows was missing is the absolute-path anchor — one reinforcing sentence. Filed and fixed as a correctness bug, not a user-facing breakage.Why the platform-dependent predicate is deliberate
Path::is_absoluteis platform-dependent, and that is correct here rather than a hazard:cwdonly ever originates fromcurrent_dir()in the same process on the same host, so the compile-time platform always matches the path's dialect. Audited —PromptContext(pool.rs:482) has no derives (so no deserialization path), its only production constructor islib.rs:1530, no crate outsidebuzz-acpreferences it, and there is no CLI flag or env override for cwd. The reasoning is now recorded in the function's doc comment so a future maintainer doesn't "fix" it back to a string prefix test.Deliberately not done: normalizing the cwd string upstream. The same string is the ACP
session/newcwd (pool.rs:831), so rewriting it would change protocol behavior for every harness.Tests
#[cfg(windows)]: drive-letter cwd →Some;C:\→None.#[cfg(unix)]:/Users/me/.buzz→Some./→None,relative/path→None,""→None.Two POSIX-path assertions needed
#[cfg(unix)]gating as a direct consequence of this change — including the pre-existingtest_framed_system_prompt_absolute_cwd_prepends_workspace_before_base, which was green on Windows before, becausePath::new("/Users/me/.buzz").is_absolute()isfalseon Windows (root, no drive prefix). Called out explicitly since it's the one non-obvious side effect of the fix.Reviewer note: the
#[cfg(windows)]tests do not currently execute in CI..github/workflows/ci.yml:945-947runscargo clippyandcargo check --workspace --all-targetsonwindows-latest(so they compile), but the only Windowscargo testinvocations are-p buzz-dev-mcp(:953) and the Tauri crate (:988). Adding-p buzz-acpto that step would make them enforcing — happy to include it here if you want it, or leave it separate.Test plan
cargo test -p buzz-acp workspace_section— 3 passedcargo test -p buzz-acp framed_system_prompt— 7 passedcargo fmt --check -p buzz-acp— cleancargo clippy -p buzz-acp— cleancargo test -p buzz-acpon a Windows target (no Windows host available to me — this is the one gap, and it's exactly what the two#[cfg(windows)]tests are for)Out of scope, noted for follow-up
Now that Windows agents receive this text:
$HOME" — POSIX phrasing that reads oddly on Windows (base_prompt.md:100has the same issue).{cwd}/REPOS/rendersC:\Users\me\.buzz/REPOS/— mixed separators, functional but untidy.Related
#3126 — the same
[Workspace]section never reaches protocol-v1 harnesses (Claude Code, Codex) on any platform, because the legacy prompt-framing path never callsworkspace_sectionat all. Independent of this predicate bug: a Windows Claude Code agent is affected by both, a macOS one only by #3126. This PR does not address it, and should not close it.🤖 Generated with Claude Code
https://claude.ai/code/session_01FnfD8YHcZF5KbBTcLxc1P1