Background shell watcher orphaned by session restart/compaction — CI-gated autonomous flow silently stalls, resume context self-contradicts (running vs stopped)
What happened
An autonomous release flow was parked on a background Bash watcher:
sleep 300 && for i in $(seq 1 30); do
line=$(gh pr checks <N> | grep -E '^test\s')
# echo PASS/FAIL sentinel and exit; sleep 45 between polls
done
The intent: when the PR's test check goes green, the watcher's completion re-invokes the agent, which then merges and promotes (pre-authorized by the user).
The session hit auto-compaction and the Claude Code process restarted. On resume, a <task-notification> reported the background tasks "didn't finish before the previous session ended … They have been marked stopped" with no completion record. The PR's test check had gone green (7m25s run), but nothing re-invoked the agent on that condition — and the model's first post-resume turn printed only a status recap without re-checking the watched condition. The pipeline sat stalled until the user came back and intervened manually.
An extra inconsistency: in the same resumed context, the background-shell system reminders described the three tasks as "still running" (with instructions not to restart them), while the task-notification in the same message said they had been marked stopped. The two states are mutually exclusive and the agent has no way to tell which is true without side-effects.
Expected
Any one of:
- Background shell tasks survive session continuation/compaction (the child processes are detached; only the bookkeeping died), or
- The resume path treats an orphaned watcher as actionable — re-invoke the agent with "these tasks were watching conditions; re-check them now", instead of a passive notification, or
- At minimum, the "still running" reminder and the "marked stopped" notification should agree.
Repro
- Start a background Bash task (
run_in_background) that polls an external condition and echoes a sentinel (e.g.gh pr checksuntil pass). - Let the session grow until auto-compaction restarts the process (or exit and resume).
- Observe: tasks marked stopped via an
__orphan_summary__scan, no re-invocation when the watched condition completes, contradictory "still running" reminders, and an idle resume turn.
Impact
A fully pre-authorized merge+promote sat idle after CI went green until the user noticed and intervened. Verbatim user reaction: 「我操你妈的什么时候 promote 废物」.
Environment
- Claude Code CLI on macOS (darwin 27.0.0), model claude-fable-5
- Session
12d9f264-61fe-4e32-bb83-732813ce891f; task idsb7salku3w(CI watcher),bc8f5ql8j,bmdacq2yg
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗