Summary
On a machine whose bb server was moved to bb Connect, every agent thread on that machine gets HTTP 401: Unauthorized from the bb CLI, for example from bb thread show, bb project list, and bb machine list. The host daemon gives each thread an authenticated loopback proxy in BB_SERVER_URL. The bb-app launcher replaces it with serverUrl from the machine's config.json (the public https://<handle>.getbb.app URL), and the CLI calls that URL without the machine credential. Restarting doesn't help, because the config file is unchanged.
Versions and environment
- Affected machine: bb
0.43.4-nightly.35739502552.1, installed through the desktop app and npm into ~/.bb, macOS on Apple silicon. It was originally the desktop-hosted server and is now a remote host of a bb Connect server (https://<handle>.getbb.app).
- Minimal repro below: bb
0.43.5-nightly.35773768107.1, macOS 15.2 (Intel), Node 24.18.1.
- Code cited at
main dea024ee6cdc8d482ca13713684e8495a112e142.
Steps to reproduce
Minimal, needs no Connect server; it shows only the precedence:
D=$(mktemp -d)
echo '{"serverUrl":"https://example.invalid"}' > "$D/config.json"
(unset BB_CLI; BB_DATA_DIR="$D" BB_SERVER_URL=http://127.0.0.1:59999 bb --help | grep 'BB_SERVER_URL:')
rm "$D/config.json"
(unset BB_CLI; BB_DATA_DIR="$D" BB_SERVER_URL=http://127.0.0.1:59999 bb --help | grep 'BB_SERVER_URL:')
rm -rf "$D"
On a real affected machine:
- Move a desktop-hosted bb server to bb Connect, so the old desktop becomes a remote host whose
~/.bb/config.json contains serverUrl: https://<handle>.getbb.app and serverHeaders with the machine credential.
- Start any agent thread on that machine and have it run
bb thread show <any-thread-id> --json.
Expected vs actual
Minimal repro, actual:
BB_SERVER_URL: https://example.invalid # config.json present: the explicit env var is ignored
BB_SERVER_URL: http://127.0.0.1:59999 # config.json absent: the env var is used
Expected: the explicitly set BB_SERVER_URL is used in both cases.
Affected machine, actual, from an agent thread whose env has BB_SERVER_URL=http://127.0.0.1:59089 (the daemon's machine-auth proxy):
$ bb thread show thr_… --json
Error: HTTP 401: Unauthorized
{"ok": false, "error": {"code": "http_401", "message": "HTTP 401: Unauthorized"}}
$ bb --help | grep BB_SERVER_URL
BB_SERVER_URL: https://<handle>.getbb.app
With NODE_DEBUG=net, the CLI connects directly to the Connect hostname on port 443, and never to the loopback proxy.
Expected: the CLI uses the daemon-provided proxy and the command succeeds. The proxy itself works: curl "$BB_SERVER_URL/api/v1/threads/thr_…" returns 200 application/json, and "$BB_CLI" thread show thr_… --json, which bypasses the launcher, succeeds.
Evidence
What you ruled out
- Not a stale or expired machine credential: the daemon's proxy, which uses the same
serverHeaders, authenticates fine.
- Not shell configuration: no
BB_SERVER_URL in shell profiles, and ~/.local/bin/bb only execs the installed launcher.
- Still present at
0.43.5-nightly.35773768107.1 (minimal repro) and in main at dea024ee6 (code above).
- No duplicate found in open or closed issues.
Suggested priority and effort
Every CLI call from every agent on an affected machine fails, so agents can't coordinate, report back, or open terminals. The workaround is to invoke "$BB_CLI" directly. Small fix: prefer an explicitly set BB_SERVER_URL over config.serverUrl in resolveServerUrl, or at least when the daemon provides it, plus a regression test. Terminals the user opens themselves don't set BB_SERVER_URL, so they keep resolving to config.serverUrl.
Checks
Found while coordinating agent workers on the affected machine, in bb thread thr_ixu6r7h84m.
AGENT GENERATED
Summary
On a machine whose bb server was moved to bb Connect, every agent thread on that machine gets
HTTP 401: Unauthorizedfrom thebbCLI, for example frombb thread show,bb project list, andbb machine list. The host daemon gives each thread an authenticated loopback proxy inBB_SERVER_URL. The bb-app launcher replaces it withserverUrlfrom the machine'sconfig.json(the publichttps://<handle>.getbb.appURL), and the CLI calls that URL without the machine credential. Restarting doesn't help, because the config file is unchanged.Versions and environment
0.43.4-nightly.35739502552.1, installed through the desktop app and npm into~/.bb, macOS on Apple silicon. It was originally the desktop-hosted server and is now a remote host of a bb Connect server (https://<handle>.getbb.app).0.43.5-nightly.35773768107.1, macOS 15.2 (Intel), Node 24.18.1.maindea024ee6cdc8d482ca13713684e8495a112e142.Steps to reproduce
Minimal, needs no Connect server; it shows only the precedence:
On a real affected machine:
~/.bb/config.jsoncontainsserverUrl: https://<handle>.getbb.appandserverHeaderswith the machine credential.bb thread show <any-thread-id> --json.Expected vs actual
Minimal repro, actual:
Expected: the explicitly set
BB_SERVER_URLis used in both cases.Affected machine, actual, from an agent thread whose env has
BB_SERVER_URL=http://127.0.0.1:59089(the daemon's machine-auth proxy):With
NODE_DEBUG=net, the CLI connects directly to the Connect hostname on port 443, and never to the loopback proxy.Expected: the CLI uses the daemon-provided proxy and the command succeeds. The proxy itself works:
curl "$BB_SERVER_URL/api/v1/threads/thr_…"returns200 application/json, and"$BB_CLI" thread show thr_… --json, which bypasses the launcher, succeeds.Evidence
config.serverUrlpriority overenv.BB_SERVER_URL:packages/bb-app/src/launcher.ts#L980-L987, applied to the CLI env at#L1389.serverHeadersintoBB_SERVER_HEADERS(#L996-L1014), but the CLI's direct requests to the Connect URL still return 401, so the credential doesn't reach them.BB_SERVER_URL(apps/host-daemon/src/start-host-daemon.ts#L135,apps/host-daemon/src/runtime-shell-env.ts#L413)./api/v1/threads/:id,/api/v1/projects, and/api/v1/hostsreturn 200, while/healthreturns 401 (the Connect sign-in page).serverUrlin the old desktop'sconfig.json.What you ruled out
serverHeaders, authenticates fine.BB_SERVER_URLin shell profiles, and~/.local/bin/bbonly execs the installed launcher.0.43.5-nightly.35773768107.1(minimal repro) and inmainatdea024ee6(code above).Suggested priority and effort
Every CLI call from every agent on an affected machine fails, so agents can't coordinate, report back, or open terminals. The workaround is to invoke
"$BB_CLI"directly. Small fix: prefer an explicitly setBB_SERVER_URLoverconfig.serverUrlinresolveServerUrl, or at least when the daemon provides it, plus a regression test. Terminals the user opens themselves don't setBB_SERVER_URL, so they keep resolving toconfig.serverUrl.Checks
main, or I say above that I could not.> AGENT GENERATEDand links the thread or report.Found while coordinating agent workers on the affected machine, in bb thread
thr_ixu6r7h84m.