From 71cc545cb2899e102e1838f217807b0de8b6338e Mon Sep 17 00:00:00 2001 From: bitburner Date: Wed, 22 Jul 2026 00:19:00 +0200 Subject: [PATCH] fix(#2629): exclude agent's own messages from unread sweep Gate the unread sweep on sender: skip rooms where the latest unread message was sent by the agent itself. This prevents self-authored messages from triggering an unread notification and causing a self-wake loop. Fixes: #2629 --- hive-matrix-mcp/src/handlers.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hive-matrix-mcp/src/handlers.rs b/hive-matrix-mcp/src/handlers.rs index b4c1810d..344d7fef 100644 --- a/hive-matrix-mcp/src/handlers.rs +++ b/hive-matrix-mcp/src/handlers.rs @@ -890,6 +890,7 @@ pub async fn collect_unread_with_ids( ) -> Vec<(matrix_sdk::ruma::OwnedRoomId, crate::protocol::RoomUnread)> { use crate::protocol::RoomUnread; let mut result = Vec::new(); + let own_user_id = client.user_id(); for room in client.joined_rooms() { let count = u32::try_from(room.unread_notification_counts().notification_count).unwrap_or(u32::MAX); @@ -902,6 +903,13 @@ pub async fn collect_unread_with_ids( } else { (None, None) }; + // Skip rooms where the newest unread event was sent by the agent itself. + // Self-authored messages should not trigger an unread notification. + if let (Some(ref sender), Some(own_id)) = (&last_sender, own_user_id) { + if sender == own_id.as_str() { + continue; + } + } result.push(( room.room_id().to_owned(), RoomUnread {