Background agent sessions (claude --bg/claude agents): fast session termination, worker crash-loop on attach, and lost background-task completion records
Summary
Using Claude Code CLI in a workflow that dispatches multiple long-running sessions as background agents (claude --bg / /bg) and periodically reattaches via claude agents, we've observed three distinct problems, each on separate occasions (not simultaneously). Reporting them together since they all touch the background-session/agent lifecycle and may share a root cause — but this is an observation report, not a diagnosis. Happy to have maintainers deduplicate against existing issues.
Environment
- Claude Code version: 2.1.201 (native CLI install)
- OS: macOS, Apple Silicon (arm64)
- Usage pattern: multiple background agent sessions dispatched concurrently via
claude --bg//bg, some running tens of minutes to hours, periodically listed/reattached viaclaude agents
Observation 1 — Session terminates unexpectedly, often within ~10 minutes of last activity
A background session that was actively in use stops producing further output / is reported as no longer running noticeably sooner than expected — frequently within about 10 minutes of the last user interaction — with no indication the task had completed or that termination was requested. Observed across multiple distinct sessions.
Observation 2 — Worker crash-loop on attach
Attempting to reattach to a background agent session produced:
Attaching...
Sess<session-id> is currently running as a background agent (bg). Use `claude agents` to find and attach to it, or add --fork-session to branch off a copy.
[worker crashed (exit 1 — exit_with_message) — respawning...]
The crash/respawn repeated and the session never became usable.
Observation 3 — Lost/orphaned background-task completion record on resume
On a separate occasion, resuming a session produced this message twice in the same resume:
No completion record was found for this background shell command from the previous session. It may have been stopped (via the UI, Monitor timeout, or agent teardown — these leave no transcript marker), or it may have been running when the previous Claude Code process exited. Check the output file for partial results before assuming it completed.
No output/partial-result path was available to confirm the true final state of the affected tasks.
Pattern notes
- All three occur intermittently, not on every session.
- No single reliable local trigger identified (not obviously tied to sleep, network changes, or a specific command).
- Never observed all three in the same session at once.
Possibly related existing issues
Found via search, flagged for maintainer triage/dedup rather than asserted as the same bug:
- #72221 — background daemon supervisor "signal war" causing worker respawns
- #73332 — background agent workers reaped mid-work, never respawn through documented path
- #65216 — worker crash-loop on reopen from agents view
- #72171 — near-identical "no completion record" message, closed as duplicate of apparently-unrelated
/clear/plan-mode issues
Impact
Background agent sessions are core to this workflow (running multiple long-lived agents concurrently). These issues require frequent manual monitoring/recovery, and completion state for background tasks can't always be trusted after a crash/respawn or resume.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗