CI-monitor events fire from archived sessions and fan out to unrelated active sessions (stale session→PR binding)
Environment
- Claude Code 2.1.160 (desktop app, macOS 26.5.1)
- Multi-session workflow: many concurrent/archived sessions in one repo, each in its own git worktree, sessions associated with GitHub PRs (the
prNumbervisible inlist_sessions)
Summary
CI-check-failure monitor events (<ci-monitor-event> user-turn injections instructing the agent to fix a PR's failing checks) are delivered to the wrong sessions, three stacked defects:
- Archived sessions keep live CI monitors. A session that was archived still received CI failure notifications for its PR. Archiving should deregister any PR/CI watch the session held.
- Events fan out to sessions that don't own the PR. A session working on an unrelated ticket (zero cron jobs per
CronList, bound to a different PR) received fourci-monitor-eventmessages for someone else's PR in one day, each instructing it to "fix the failing checks." - Session→PR bindings go stale. A session shows
prNumber= a PR whose branch was merely checked out in its worktree at some point; after switching to its real work (different branch, different PRs),list_sessionsstill reports the old PR binding.
Impact (real incident)
Two agent sessions both received the same "fix PR #A checks" event. Both acted. They raced uncommitted edits in the same worktree for ~20 minutes (the second session followed the event to the PR's checkout location). The resulting amend was assembled from an index two writers were mutating: it shipped with a missing newly-added file (broken builds) and swept in the other session's unrelated edits. Cleanup consumed a full morning. A separate near-miss: the wrongly-notified session context-switched mid-task while holding unpushed prod-deploy commits.
Expected
- Archiving a session tears down its CI/PR monitors.
- A CI event for PR #A is delivered only to the single non-archived session whose binding is PR #A (or to none, surfaced as a global notification — never as an actionable "fix it" instruction to unrelated sessions).
- The session→PR binding updates when the checked-out branch / submitted PR changes, or at minimum is cleared when the branch moves away.
Repro sketch
- Create session S1 in worktree W1, open PR #A from its branch; archive S1.
- Create sessions S2/S3 on unrelated branches/PRs.
- Make PR #A's CI fail.
- Observe the ci-monitor event appear in the archived S1 and/or in S2/S3 as an instruction to fix PR #A.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗