claude-code - 💡(How to fix) Fix claude agents: bg-spare workers exit 1 before init non-deterministically on claim

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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).

Error Message

Reported error in the FleetView UI and in ~/.claude/jobs/<id>/state.json: 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.

Root Cause

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).

Fix Action

Fix / Workaround

Workaround attempted

Code Example

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)

---

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
RAW_BUFFERClick to expand / collapse

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

  1. cd /tmp && claude agents
  2. Start a background agent task
  3. 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 /tmp with 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 claude works 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix claude agents: bg-spare workers exit 1 before init non-deterministically on claim