claude agents: bg-spare workers exit 1 before init non-deterministically on claim
Summary
claude agents background agent workers crash non-deterministically with exit 1 before init immediately after the daemon claims a spare worker. Sometimes a claim succeeds and the session runs fine; sometimes it crashes within ~45ms of being claimed. Reproduces against fresh daemons, fresh spare workers, and against any cwd (including /tmp with no project config).
Environment
- macOS 26.3.0 (Darwin arm64)
- Claude Code 2.1.143 (also observed on 2.1.141)
- Bun v1.3.14 (bundled)
- Shell: zsh
Reproduction
cd /tmp && claude agents- Start a background agent task
- Sometimes works, sometimes crashes immediately. Hit it repeatedly and at least one will crash.
Failure surface
Reported error in the FleetView UI and in ~/.claude/jobs/<id>/state.json:
exit 1 before init — …at uSK (/$bunfs/root/src/entrypoints/cli.js:9092:233)
at async SKO (/$bunfs/root/src/entrypoints/cli.js:19558:68)
at async h4O (/$bunfs/root/src/entrypoints/cli.js:19595:313)
Bun v1.3.14 (macOS arm64)
The job's state.json shows state: "failed", intent: "" or a user prompt, respawnFlags: ["--agent", "claude"], and no resumeSessionId (so it's not a stale-session resume issue).
Daemon log evidence (non-deterministic pattern, same daemon)
14:22:15.813Z [supervisor] ─── daemon start ─── version=2.1.143 pid=75996
14:22:15.873Z [bg] bg spare spawned host pid=76003
14:22:16.040Z [bg] bg claimed-spare 2d82e5ef (spare)
14:22:16.086Z [bg] bg settled 2d82e5ef (crashed) ← crashed 46ms after claim
14:22:25.771Z [bg] bg claimed-spare 14642ab9 (spare)
14:22:25.815Z [bg] bg settled 14642ab9 (crashed) ← crashed 44ms after claim
14:26:34.809Z [bg] bg claimed-spare c820735e (spare)
14:26:48.625Z [bg] bg claimed-spare 136b9e62 (spare)
14:27:03.275Z [bg] bg settled c820735e (killed) ← ran fine; user cancelled
14:27:06.082Z [bg] bg settled 136b9e62 (killed) ← ran fine; user cancelled
14:27:11.084Z [supervisor] idle 5s with no clients — exiting
14:28:06.616Z [supervisor] ─── daemon start ─── version=2.1.143 pid=78921
14:28:06.673Z [bg] bg spare spawned host pid=78929
14:28:06.844Z [bg] bg claimed-spare c83a827f (spare)
14:28:06.888Z [bg] bg settled c83a827f (crashed) ← crashed 44ms after claim
What we ruled out
- Stale-session resume — failures happen on fresh sessions with no
resumeSessionId - Project hooks/MCP/CLAUDE.md — reproduces from
/tmpwith no project context - Version regression — same crash on 2.1.141 and 2.1.143
- Stale spare workers — fresh spares spawned <100ms before being claimed still crash
- Auth/token expiry — daemon's proactive refresh succeeds; non-agents
claudeworks fine throughout - Cwd — reproduces against both project dir and
/tmp
Workaround attempted
- Killing the daemon + clearing
~/.claude/jobs/+ relinking binary version → next first claim sometimes succeeds, but the crash recurs on subsequent claims
What would help
A way to make the daemon log the worker process's actual stderr (not just the summarised exit 1 before init line) would surface the real exception inside uSK/SKO/h4O and almost certainly identify the cause.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗