Repository navigation
Description
Summary
When the login-shell PATH probe's interactive attempt ($SHELL -ilc) times out, for example under heavy load right after a reboot, bb falls back to $SHELL -lc and keeps that PATH. That PATH comes from .zprofile only and is missing everything .zshrc adds. If the provider CLI itself is on the -lc PATH but something it runs is only on the .zshrc PATH, bb finds the CLI, the CLI exits with code 1, and bb never re-reads the shell. In my case every pi thread failed to start until I restarted bb. Expected: bb notices that the fallback PATH is incomplete and probes again with the interactive shell once it can.
Versions and environment
- bb 0.48.0 (desktop app, launched as a login item at boot), macOS on Apple Silicon
- provider-pi,
pi1.4.0 (behind a wrapper script that runs a helper CLI at startup) - zsh login shell:
.zprofileputspion PATH for non-interactive shells,.zshrcadds the helper's directory.zsh -ilc truetakes about 1.7 s on an idle machine. - Code checked against
mainat 2096c06
Steps to reproduce
Real host (observed):
- Use a login shell whose
.zprofileputs the provider CLI on PATH and whose.zshrcadds a directory with a helper the CLI runs..zshrctakes more than 3 s under load. - Reboot, with bb starting at login. Load average was about 12 during the first minutes.
- Start a pi thread.
Minimal repro against HostToolchain on main (packages/process-utils/src/host-toolchain.ts). It uses a throwaway ZDOTDIR: .zprofile adds profilebin (holds agent), .zshrc adds rcbin (holds helper, which agent needs) and sleeps 4 s while a slow flag file exists.
R=$(mktemp -d); mkdir -p $R/home/profilebin $R/home/rcbin
printf '#!/bin/sh\ncommand -v helper >/dev/null || { echo "agent: helper not found on PATH" >&2; exit 1; }\necho ok\n' > $R/home/profilebin/agent
printf '#!/bin/sh\nexit 0\n' > $R/home/rcbin/helper
chmod +x $R/home/profilebin/agent $R/home/rcbin/helper
echo "export PATH=\"$R/home/profilebin:\$PATH\"" > $R/home/.zprofile
printf '[ -f "%s/slow" ] && sleep 4\nexport PATH="%s/home/rcbin:$PATH"\n' $R $R > $R/home/.zshrcSave as repro.mts at the root of a checkout with dependencies installed, then run R=$R pnpm exec tsx repro.mts:
import { spawnSync } from "node:child_process";
import { writeFileSync, rmSync } from "node:fs";
import { HostToolchain } from "./packages/process-utils/src/host-toolchain.ts";
const R = process.env.R!;
const base = { HOME: R + "/home", ZDOTDIR: R + "/home", SHELL: "/bin/zsh", USER: process.env.USER, PATH: "/usr/bin:/bin:/usr/sbin:/sbin" };
const run = (tc: HostToolchain, label: string) => {
const c = tc.command("agent");
const r = spawnSync(c.command, c.args, { env: c.env, encoding: "utf8" });
console.log(label, "| resolved:", c.command, "| exit:", r.status, "|", (r.stdout + r.stderr).trim());
};
writeFileSync(R + "/slow", ""); // interactive rc file is slow (boot load)
const tc = new HostToolchain(base, process.execPath);
let t = Date.now(); await tc.refresh(); console.log("startup probe took", Date.now() - t, "ms");
run(tc, "1. after startup probe");
await tc.refresh(); run(tc, "2. refresh while still slow");
rmSync(R + "/slow"); // load settles
tc.invalidateFailure(1); await new Promise(r => setTimeout(r, 2500));
run(tc, "3. load settled, only invalidateFailure(exit 1)");
await tc.refresh(); run(tc, "4. after explicit refresh()");Did not reproduce: with no slow flag (the -ilc probe finishes in time), agent exits 0 from the first run. Restarting bb on the real host also fixed it.
Expected vs actual
Actual, repro on main:
startup probe took 3027 ms
1. after startup probe | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
2. refresh while still slow | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
3. load settled, only invalidateFailure(exit 1) | resolved: $R/home/profilebin/agent | exit: 1 | agent: helper not found on PATH
4. after explicit refresh() | resolved: $R/home/profilebin/agent | exit: 0 | ok
Actual, real host (~/.bb/logs/host-daemon.3.log, boot at 17:04:09, bb restarted by hand at 17:12:48):
17:05:56 provider.list_models: Could not determine the pi version: `pi --version` exited with 1.
17:06:14 turn.submit: pi exited (code 1, signal null): Error: <wrapper's helper failed: helper not on PATH>
17:07:11 turn.submit: same
17:09:13 turn.submit: same
Expected: when the -ilc probe times out, the -lc PATH is used only until a later interactive probe succeeds. A provider that exits right away after spawning (or a turn that fails to start) triggers that probe, and the next turn gets the full PATH without restarting bb.
Evidence
- The probe timeout is 3 s:
const PROBE_TIMEOUT_MS = 3000; - In the first probe, a timed-out
-ilcfalls through to-lc, and whatever PATH that returns is kept:bb/packages/process-utils/src/host-toolchain.ts
Lines 195 to 219 in 2096c06
const shellArgs = ["sh", "dash"].includes(basename(shell)) ? ["-lc"] : ["-ilc", "-lc"]; for (const arg of shellArgs) { const result = await runProbe(shell, [arg, command], env); if (result.status !== 0) { if (retainPrevious) return null; continue; } const start = result.stdout.indexOf(`${SHELL_START}\n`); const end = result.stdout.indexOf(`\n${SHELL_END}`, start); if (start < 0 || end < 0) { if (retainPrevious) return null; continue; } const values: NodeJS.ProcessEnv = {}; for (const line of result.stdout .slice(start + SHELL_START.length + 1, end) .split("\n")) { const separator = line.indexOf("="); const key = line.slice(0, separator); if (key === "PATH" || NETWORK_KEYS.includes(key)) values[key] = line.slice(separator + 1); } if (values.PATH) return values; - Later refreshes run with
retainPrevious, so a-ilcthat times out again keeps the incomplete-lcPATH:andbb/packages/process-utils/src/host-toolchain.ts
Lines 244 to 246 in 2096c06
const retainPrevious = this.shellEnv.PATH !== undefined; this.refreshing = readShellEnvironment(this.baseEnv, retainPrevious) .then((env) => { bb/packages/process-utils/src/host-toolchain.ts
Lines 199 to 202 in 2096c06
const result = await runProbe(shell, [arg, command], env); if (result.status !== 0) { if (retainPrevious) return null; continue; invalidateFailurerefreshes only onENOENTor exit 127. A CLI that is found and exits with 1 never triggers a refresh:bb/packages/process-utils/src/host-toolchain.ts
Lines 255 to 263 in 2096c06
invalidateFailure(errorOrCode: unknown): void { const code = typeof errorOrCode === "object" && errorOrCode !== null && "code" in errorOrCode ? errorOrCode.code : errorOrCode; if (code === "ENOENT" || code === 127) void this.refresh(); } - After the reboot I rebuilt the
zsh -lcPATH by hand and ranpi --versionwith it. That printed the same error. Adding the helper's directory made it print1.4.0. - bb thread: thr_348ecrgmk2
What you ruled out
- Not Host daemon falls back to bare launchd PATH when login-shell probe fails, breaking provider CLI detection (codex/claude) until daemon restart #5292: that one is the bare launchd PATH (the CLI is not found, ENOENT). Here the probe partly succeeds through
-lc, so the CLI is found and fails later, which none of the ENOENT-based recovery covers. Same trigger (load at boot), different path. - Not Desktop app hangs at launch: the login-shell PATH probe is never killed (interactive zsh ignores SIGTERM) #3484: the probe was killed on time; it did not hang.
- Unverified: whether the daemon's per-turn refresh (
RUNTIME_SHELL_ENV_REFRESH_TTL_MS) ran during those 7 minutes and kept timing out, or whether its result never reached the provider bridge worker. In the repro, an explicitrefresh()recovers once the shell is fast again (step 4). - Workaround: also putting the helper's directory on PATH in
.zprofilemakes the-lcfallback complete.
Suggested priority and effort
Medium. It hits anyone whose .zshrc is slow at boot and adds PATH entries their provider needs, and every thread fails until bb restarts. There's a workaround (dotfiles or a restart), and no data is lost. Effort is probably low to medium: re-probe -ilc after a fallback or timeout, or raise the timeout at startup.
Checks
- I reproduced this on
mainat 2096c06 (code-level repro above) and on the real host with bb 0.48.0. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report.
AGENT GENERATED
Activity
bb-slop-cop commentedon Oct 29, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilothost,providers, andprovider-pi; no existing classifications were replaced.confirmed-repro. Both authored regression cases fail on trustedorigin/mainin two separate clean-base checkouts.Probe the interactive shell again when the host PATH came from the lo…