Skip to content

msb: "has no ssh-agent --vsock route" warning fires when msb inspect fails, even though the route exists #516

Closed

Description

@basiliskus

Problem

acq run can warn that an existing sandbox has no ssh-agent route when the route is present and forwarding works:

acq(msb): warning: host SSH_AUTH_SOCK is set, but existing sandbox 'gsa-agentic-coding' has no ssh-agent --vsock route. The route is create-time only, so SSH_AUTH_SOCK will not be set in the guest and git signing will fail.

_acq_msb_has_ssh_agent_vsock_route (acq.backends/msb.sh:4082) answers only yes or no. A failed msb inspect (|| return 1) and an empty result ([ -n "$json" ] || return 1) both return the same "no" as a genuinely missing route, and the caller (:4058) reports every "no" as a missing route. So a momentary inspect failure produces a confident, wrong warning that tells the user to recreate a working sandbox.

Reproduction

acq main@187aa57, msb 0.7.3, macOS, SSH_AUTH_SOCK set to the launchd agent. Sandbox created through acq with the route recorded.

  • 1 of 3 consecutive acq run <sandbox> printed the warning; the other two were clean.
  • Right after the warning, the route was present: msb inspect <sandbox> --format json shows "vsock":{"routes":[{"host_socket":"/private/var/run/com.apple.launchd.…/Listeners","port":3552,"socket_type":"stream"}]}, and replaying the function's flatten + grep logic by hand passes both checks.
  • Forwarding worked in the guest: acq exec <sandbox> -- ssh-add -l listed the host's keys via /home/agent/.acq/ssh-agent.sock.

The inspect error is discarded (2>/dev/null), so I couldn't capture why it failed on the bad run. That the failed inspect is the cause is inferred from the code path, not observed directly.

Suggested fix

Separate "couldn't check" from "missing":

  • Return 2 when msb inspect fails or returns nothing; 0 and 1 keep their meaning.
  • On 2, retry the inspect once or twice. If it still fails, warn that acq couldn't verify the route (and include inspect's stderr), rather than stating the route is missing.
  • Keep the existing warning for a genuine 1: it's accurate there.

Related: #501 (re-deriving the route on restore), which touches the same route handling.

Activity

  1. added theissue type on Oct 1, 2026
  2. removed
    bugSomething isn't working
    on Oct 5, 2026
  3. basiliskus commented on Oct 21, 2026

    @basiliskus
    ContributorAuthor

    Likely root cause, partly reproduced: acq runs under set -euo pipefail, and _acq_msb_has_ssh_agent_vsock_route tests the flattened inspect JSON with printf '%s\n' "$_flat" | grep -Eq …. grep -q exits on the first match; when the document is larger than the pipe buffer, printf can still be writing and dies with SIGPIPE (141), and pipefail turns the successful match into a failure. On msb 0.7.8 a sandbox's msb inspect --format json is ~175 KB (~71 KB flattened, vsock: about halfway through), so it's timing-dependent, matching the 1-in-3 rate above. Replaying the check with pipefail on that real document passed 6/6; on a 3× document it failed 3/3 with rc=141. Feeding grep from a here-string (grep -Eq … <<<"$_flat") or using a case match avoids the pipe. The return-2 split suggested above is still worth having for real inspect failures.

  4. basiliskus commented on Oct 21, 2026

    @basiliskus
    ContributorAuthor

    The false "no route" has a bigger effect than the warning. On acq start/restart, _acq_msb_ensure_ssh_agent_forward returns before setting _ACQ_MSB_SSH_AGENT_FORWARDING=1, so acq runs that start's agent-user kit commands without SSH_AUTH_SOCK (the -e SSH_AUTH_SOCK=… at msb.sh ~2180 is gated on that flag). A kit daemon started then keeps the empty env: the paseo kit's daemon came up without SSH_AUTH_SOCK, so every agent and terminal it spawns has no ssh-agent, and with commit.gpgsign on, their commits fail ([git-ssh-sign] no SSH agent - cannot sign commits, fatal: failed to write commit object). The bridge itself is fine, and later acq exec sessions get the agent because their own route check passes. On msb 0.7.8 the warning printed on 3 of 3 acq start/restart runs I saw, versus 1 of 3 acq runs in the report above, so after a restart it's effectively always hit. The fix suggested above covers it. The Team Data kit sets SSH_AUTH_SOCK=/home/agent/.acq/ssh-agent.sock in its kit env as a stopgap until then.

  5. added a commit that references this issue on Oct 21, 2026
    24c8493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions