-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug] Gateway reply-queue state not flushed on restart — stale queued replies drain to wrong Matrix room after restart #91613
Copy link
Copy link
Closed
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.
Type
Fields
Priority
None yet
Summary
Gateway reply-queue state is not flushed on restart. Queued outbound Matrix replies targeting a specific room persist across a gateway process restart and drain to their destination after the gateway comes back up — even when the originating session was
isolatedand completed long before the restart.Version
2026.4.25— reproduced on two separate Mac mini fleet agents (Charlie and Johnny), both running LaunchAgent-managed gateways.Observed behavior
2026-06-08, ~07:00–07:56 CDT
Charlie (Mac mini, LaunchAgent):
07:00:02— Morning Briefing cron session starts (sessionf8986989, targeting Glenn's DM room)07:14:46— long-running session warning, age=131s07:15:06—UND_ERR_SOCKETfetch failure mid-model-call (Anthropic provider)07:16— gateway self-restarts (process exits and launchd relaunches)07:34:01— liveness warning: active + queued sessions both keyed to@johnnyDM room (wrong room — Charlie's session was targeting Glenn's DM)07:34:47–07:34:58—ReplyRunAlreadyActiveErrorloop; queued reply drains into Johnny's DM with Charlie's Morning Briefing tool narration as payload (memory searches, Linear issue lookups, CFO briefing reasoning)Johnny (Mac mini, LaunchAgent):
⏰ Cron,🧩 Linear Get Issue,📊 Session Status,🛠️ exec,📖 Read,📝 Edit) leaked into a different agent's DM room through multiple restart cycles between 07:40–07:55 CDT.launchctl kickstart) at 07:56 CDT finally stabilized after the queued boot session drained.Key diagnostic finding
After both restarts,
sessions.jsonshowed 0 pending sessions. The reply-queue state is stored separately from the sessions index — meaning the standard sessions-store check does not reveal pending outbound message queue entries. The reply queue appears to persist in a separate store that survives process restart.Why
sessionTarget: isolateddoes NOT mitigate thisAll fleet cron jobs use
sessionTarget: isolated. Both affected cron sessions were isolated. The reply-queue corruption still occurred becauseisolatedgoverns per-run context (not outbound message queue state). These are orthogonal.Impact / severity
Proposed fixes (for upstream evaluation)
sessionScope: per-roompartially addresses this at config level but should be enforced at the transport layer.Current workaround
sessionScope: per-roomon the matrix channel config prevents wrong-room drain even if the queue survives restart (config-level mitigation, not a transport-layer fix).Steps to reproduce
UND_ERR_SOCKETor similar) that causes the gateway to self-restartsessions.jsonshows 0 pending sessionsReplyRunAlreadyActiveErrorloop confirms the stale reply is retrying