claude-code - 💡(How to fix) Fix [BUG] Background agents: every daemon-spawned worker crashes "exit 1 before init" (macOS arm64)

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…

Every background-agent worker spawned by the on-demand daemon crashes immediately with exit 1 before init. The Agents view and claude --bg are completely unusable — no background session can start, and existing ones can't be resumed. Interactive claude is unaffected.

Error Message

error message and earlier stack frames are cut off, so a user has no way to see

Error Messages/Logs

Root Cause

Every background-agent worker spawned by the on-demand daemon crashes immediately with exit 1 before init. The Agents view and claude --bg are completely unusable — no background session can start, and existing ones can't be resumed. Interactive claude is unaffected.

Code Example

### daemon.log excerpt

  
  [2026-05-16T06:00:32.913Z] [supervisor] ─── daemon start ─── version=2.1.143 pid=92076 origin=transient
  [2026-05-16T06:00:33.050Z] [bg] bg spare spawned host pid=92103
  [2026-05-16T06:00:33.161Z] [bg] bg claimed-spare 66c5da22 (spare)
  [2026-05-16T06:00:33.615Z] [bg] bg settled 66c5da22 (crashed)
  [2026-05-16T06:00:54.844Z] [bg] bg claimed-spare a433d7e5 (fleet)
  [2026-05-16T06:00:54.851Z] [bg] bg spare spawned host pid=92410
  [2026-05-16T06:00:54.915Z] [bg] bg settled a433d7e5 (crashed)

---

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

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Summary

Every background-agent worker spawned by the on-demand daemon crashes immediately with exit 1 before init. The Agents view and claude --bg are completely unusable — no background session can start, and existing ones can't be resumed. Interactive claude is unaffected.

Ruled out

  • Not auth. The daemon separately hit auth_required (expired OAuth, headless daemon can't refresh). Re-login + daemon restart fixed auth — the fresh daemon authenticates cleanly — but workers still crash identically.
  • Not a version regression. First seen on 2.1.142; persists on 2.1.143 (reported latest by claude update).
  • Not system Bun. Updating system Bun to latest had no effect — consistent with the crash being in the Bun runtime embedded in the compiled binary.
  • Not project config. All settings.json files valid; claude -p from the same cwd runs fine (full startup, exit 0); interactive claude is unaffected.

Secondary issue

The crash detail stored in state.json is truncated (leading ) — the actual error message and earlier stack frames are cut off, so a user has no way to see what actually threw. The daemon should persist the full worker stderr.

What Should Happen?

Expected vs actual

Expected: the worker starts and runs the session. Actual: the worker exits 1 before init; the daemon logs bg settled <id> (crashed) ~60–500ms after bg spare spawned host.

Error Messages/Logs

### daemon.log excerpt

  
  [2026-05-16T06:00:32.913Z] [supervisor] ─── daemon start ─── version=2.1.143 pid=92076 origin=transient
  [2026-05-16T06:00:33.050Z] [bg] bg spare spawned host pid=92103
  [2026-05-16T06:00:33.161Z] [bg] bg claimed-spare 66c5da22 (spare)
  [2026-05-16T06:00:33.615Z] [bg] bg settled 66c5da22 (crashed)
  [2026-05-16T06:00:54.844Z] [bg] bg claimed-spare a433d7e5 (fleet)
  [2026-05-16T06:00:54.851Z] [bg] bg spare spawned host pid=92410
  [2026-05-16T06:00:54.915Z] [bg] bg settled a433d7e5 (crashed)

Steps to Reproduce

Reproduction

  1. Run claude --bg "reply with the single word OK" (any prompt).
  2. The job is created, then fails within ~100ms.
  3. claude logs <id>job not found — it may have already exited.
  4. ~/.claude/jobs/<id>/state.json shows:
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)

100% reproducible. Also affects pre-warmed "spare" workers (no session/job attached) and resuming existing Agents-view chats.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.143 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

No response

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 [BUG] Background agents: every daemon-spawned worker crashes "exit 1 before init" (macOS arm64)