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:
committed by
Xubin Ren
co-authored by
layla
parent
6973bfff24
commit
ddc9fc4fd2
@@ -86,12 +86,14 @@ class MessageTool(Tool):
|
|||||||
) -> str:
|
) -> str:
|
||||||
channel = channel or self._default_channel
|
channel = channel or self._default_channel
|
||||||
chat_id = chat_id or self._default_chat_id
|
chat_id = chat_id or self._default_chat_id
|
||||||
# Only use default message_id if chat_id matches the default context.
|
# Only inherit default message_id when targeting the same channel+chat.
|
||||||
# If targeting a different chat, don't reply to the original message.
|
# Cross-chat sends must not carry the original message_id, because
|
||||||
if chat_id == self._default_chat_id:
|
# 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
|
message_id = message_id or self._default_message_id
|
||||||
else:
|
else:
|
||||||
# Targeting a different chat - don't use default message_id
|
|
||||||
message_id = None
|
message_id = None
|
||||||
|
|
||||||
if not channel or not chat_id:
|
if not channel or not chat_id:
|
||||||
|
|||||||
Reference in New Issue
Block a user