mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-30 14:56:01 +00:00
fix(agent): message tool incorrectly replies to original chat when targeting different chat_id
When the message tool is used to send a message to a different chat_id than the current conversation, it was incorrectly including the default message_id from the original context. This caused channels like Feishu to send the message as a reply to the original chat instead of creating a new message in the target chat. Changes: - Only use default message_id when chat_id matches the default context - When targeting a different chat, set message_id to None to avoid unintended reply behavior
This commit is contained in:
parent
7e719f41cc
commit
6973bfff24
@ -86,7 +86,13 @@ 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
|
||||||
message_id = message_id or self._default_message_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:
|
||||||
|
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:
|
if not channel or not chat_id:
|
||||||
return "Error: No target channel/chat specified"
|
return "Error: No target channel/chat specified"
|
||||||
@ -101,7 +107,7 @@ class MessageTool(Tool):
|
|||||||
media=media or [],
|
media=media or [],
|
||||||
metadata={
|
metadata={
|
||||||
"message_id": message_id,
|
"message_id": message_id,
|
||||||
},
|
} if message_id else {},
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user