From ddc9fc4fd286025aebaab5fb3f2f032a18ed2478 Mon Sep 17 00:00:00 2001 From: WormW Date: Wed, 1 Apr 2026 12:32:15 +0800 Subject: [PATCH] fix: also check channel match before inheriting default message_id Different channels could theoretically share the same chat_id. Check both channel and chat_id to avoid cross-channel reply issues. Co-authored-by: layla <111667698+04cb@users.noreply.github.com> --- nanobot/agent/tools/message.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nanobot/agent/tools/message.py b/nanobot/agent/tools/message.py index efbadca10..3ac813248 100644 --- a/nanobot/agent/tools/message.py +++ b/nanobot/agent/tools/message.py @@ -86,12 +86,14 @@ class MessageTool(Tool): ) -> str: channel = channel or self._default_channel chat_id = chat_id or self._default_chat_id - # Only use default message_id if chat_id matches the default context. - # If targeting a different chat, don't reply to the original message. - if chat_id == self._default_chat_id: + # Only inherit default message_id when targeting the same channel+chat. + # Cross-chat sends must not carry the original message_id, because + # some channels (e.g. Feishu) use it to determine the target + # conversation via their Reply API, which would route the message + # to the wrong chat entirely. + if channel == self._default_channel and chat_id == self._default_chat_id: message_id = message_id or self._default_message_id else: - # Targeting a different chat - don't use default message_id message_id = None if not channel or not chat_id: