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>
This commit is contained in:
WormW 2026-04-01 12:32:15 +08:00 committed by Xubin Ren
parent 6973bfff24
commit ddc9fc4fd2

View File

@ -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: