fix(acp,desktop): let a custom harness override session cwd for remote hosts - #3456
Open
surfingdev wants to merge 1 commit into
Open
fix(acp,desktop): let a custom harness override session cwd for remote hosts#3456surfingdev wants to merge 1 commit into
surfingdev wants to merge 1 commit into
Conversation
…e hosts A harness whose command executes on another machine (e.g. `ssh` to a Linux VM) can't complete its first turn today: buzz-acp always sends its own local working directory as session/new's cwd, which the remote adapter rejects since that path doesn't exist there. Add an optional `cwd` field to the custom harness JSON schema, threaded through the effective harness descriptor to a new BUZZ_ACP_SESSION_CWD env var that buzz-acp uses in place of its own current_dir() when set. Signed-off-by: Ivan Itzcovich <surfingdevs@gmail.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.
Problem
Bring-your-own-harness (BYOH) lets a managed agent's harness command be anything — including
sshto a remote machine, so the ACP agent process runs on a separate VM while Desktop stays the client. This is exactly the setup you'd want for an always-reachable-from-chat agent that doesn't have to live and die with the Desktop process.It fails on the very first turn today.
buzz-acpalways sends its own local working directory assession/new'scwd(std::env::current_dir()— the directory Desktop set when it spawned thebuzz-acpprocess, normally~/.buzz). When the harness runs elsewhere, that path is meaningless there and the remote adapter rejects it outright:There's no way to override it — nothing in the custom harness JSON schema or the effective spawn config lets you say "use this path instead." A user can work around it by manually creating the client's exact path on the remote machine (e.g.
sudo ln -sfn /home/user/buzz /Users/someuser/.buzz), but that's a fragile hack: a macOS path fabricated on Linux whose correctness depends on the two machines coincidentally agreeing on a string, and it breaks the moment Desktop starts sending per-agent subdirectories or a different client user account is used.What this changes
Adds an optional
cwdfield to the custom harness JSON schema (desktop/src-tauri/src/managed_agents/custom_harnesses.rs), alongside the existingcommand/args/env. When set, it's threaded throughresolve_effective_harness_descriptor(readiness.rs) to a newBUZZ_ACP_SESSION_CWDenv var set at spawn time (runtime.rs).buzz-acpreads that var and uses it verbatim assession/new'scwdin place of its owncurrent_dir()(crates/buzz-acp/src/config.rs,crates/buzz-acp/src/lib.rs).Deliberately not
command.current_dir(cwd)on the spawned process — that path only needs to exist on the harness's machine, which may not be this one, and callingcurrent_dir()with a nonexistent local path would just fail the spawn. The override only changes the string sent over the wire insession/new; thebuzz-acpprocess's own local working directory is untouched.Also added
descriptor.cwd.hash(&mut hasher)to the restart-drift hash (spawn_hash.rs) so editing a definition'scwdon a running agent trips the "Restart required" badge, same as editingcommand/argsalready does.Documented the field in
crates/buzz-acp/README.md's BYOH section, plus a new "Remote harnesses over SSH" subsection covering two more things a remote/SSH harness needs that aren't code fixes: forwardingBUZZ_*env vars viaSendEnv/AcceptEnv(SSH doesn't forward them by default — without this, the agent looks slow/unresponsive rather than misconfigured, since it can still receive turns but everybuzzCLI call it makes fails silently), and settingPATHinline in the harness command (non-interactive SSH sessions don't load the login shell profile).Out of scope
cwdoverride. Only the harness definition can set it for now, not an individual agent instance — matches the report's primary ask and keeps this change small. Multiple instances of the same SSH-based harness needing different remote paths would need this; not a reported need yet.cwdin the Settings custom-harness form. Tier-3 harnesses remain JSON-file-only for this field — consistent with how the field is meant to be used today (hand-edit the JSON, same workflow already used to configurecommand/args/envfor advanced setups).SendEnv/AcceptEnvpattern rather than automated, since "forward these vars" is meaningful only for an SSH-shaped harness command, not harness commands generically.Test plan
cargo test -p buzz-acp --lib— 634/634 pass (11 new:session_cwd_*×2,normalize_session_cwd_*×2,resolve_session_cwd_tests::*×2, plus existing suite)cargo clippy -p buzz-acp --all-targets -- -D warnings— cleancargo fmt -p buzz-acp -- --check— cleancargo build -p sprig(the only other workspace crate depending onbuzz-acp) — cleancargo clippy -p sprig --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleancustom_harnesses.rs,readiness.rs,runtime.rs,spawn_hash.rs,discovery.rs) could not be locally compiled or tested — this sandbox has no GTK/WebKitGTK/pkg-config installed and no passwordless sudo to add them (the Linux prerequisites CONTRIBUTING.md lists forjust desktop-tauri-*).cargo fmt --checkon the touched files passed (valid syntax), and I manually re-verified everyHarnessDefinition/EffectiveHarnessDescriptorstruct-literal construction site and the borrow/move ordering inresolve_effective_harness_descriptor, but this is not a substitute forcargo test --manifest-path desktop/src-tauri/Cargo.tomlandjust desktop-tauri-fmt/clippy — needed before merge."command": "ssh"and a"cwd"pointing at a real path on a remote host, confirm the first turn succeeds instead of failing with thecwd does not existerror.🤖 Written by Claude, running as an agent inside Buzz (buzz-acp) — not the Claude Code CLI.