Skip to content

local agent spawn/list resolve broker via raw cwd, not findProjectRoot — can't reach a broker that status reports running #1192

Description

@khaliqgant

Summary

agent-relay local agent spawn / list cannot find a broker that agent-relay up started and agent-relay status reports as running, when the current directory is a subdirectory that does not itself contain a project marker. The two code paths resolve the project root differently.

Repro

$ cd /Users/me/Sites/relay-tests/demos      # no .git/package.json here
$ agent-relay local up --background
Broker started.
Broker PID: 51840

$ agent-relay status
Workspace:    /Users/me                      # <-- resolved to HOME
Local broker: running (http://127.0.0.1:3889)

$ agent-relay local agent spawn claude --name Lead
No running broker found (/Users/me/Sites/relay-tests/demos/.agentworkforce/relay/connection.json does not exist).
Start one with 'agent-relay up' or use HarnessDriverClient.spawn().

$ agent-relay local agent list
No running broker found (/Users/me/Sites/relay-tests/demos/.agentworkforce/relay/connection.json does not exist).

status finds the broker; spawn/list do not — same broker, same shell.

Root cause

Two inconsistent project-root resolutions:

  • up / status / down resolve via getProjectPaths() → findProjectRoot()
    (packages/config/src/project-namespace.ts:33), which walks up the directory tree
    looking for a marker (.git, package.json, Cargo.toml, go.mod, pyproject.toml,
    .agentworkforce/relay). From a markerless subdir it climbs to the first ancestor with a
    marker — here $HOME — and registers connection.json at
    ~/.agentworkforce/relay/connection.json.

  • local agent spawn / list go through run() →
    deps.connect(deps.cwd()) → HarnessDriverClient.connect({ cwd })
    (packages/cli/src/cli/commands/local-agent.ts:96,131). This uses the raw cwd
    literally
    and does not walk up, so it only checks
    <cwd>/.agentworkforce/relay/connection.json.

When cwd is a subdirectory without its own marker, the broker is registered under the
walked-up root while spawn/list look only in cwd → mismatch → "No running broker found."

Expected

local agent subcommands should locate the broker the same way up/status do — i.e.
resolve via findProjectRoot() / getProjectPaths().projectRoot (walk-up), or at minimum
fall back to the walked-up root before erroring. The broker that status reports as
running should always be reachable by spawn/list from the same shell.

Notes / scope

  • Affects at least local agent spawn, local agent new, local agent list. The
    local agent message … subcommands take --broker-url/--state-dir/RELAY_BROKER_URL
    overrides and can be pointed manually; spawn/list expose no such override, so there is
    no in-CLI workaround.
  • Workaround today: ensure cwd contains a marker (e.g. git init, or
    mkdir -p .agentworkforce/relay) before agent-relay up, so the broker registers in
    cwd rather than resolving up to $HOME.
  • General footgun: a broker accidentally rooted at $HOME shadows every markerless subdir.

Version: agent-relay 9.0.1

Activity

  1. willwashburn commented on Oct 4, 2026

    @willwashburn
    Member

    Resolved. Without flags, node agent spawn/list/new now find the broker via findProjectRoot(cwd) (walk-up), the same root up/status use. #1876 (merged; ships in the next release after v13.1.0) also adds --state-dir/--broker-url/--api-key to those commands, so a broker can be targeted explicitly from any directory.


    Generated by Claude Code

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions