fix(telegram): make reaction handling soft-fail and message-id resilient (#20236)

* Telegram: soft-fail reactions and fallback to inbound message id

* Telegram: soft-fail missing reaction message id

* Update CHANGELOG.md

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
LI SHANXIN
2026-02-23 23:25:14 +08:00
committed by GitHub
parent ea47ab29bd
commit c1b75ab8e2
17 changed files with 317 additions and 69 deletions

View File

@@ -253,8 +253,22 @@ const DOCKS: Record<ChatChannelId, ChannelDock> = {
},
threading: {
resolveReplyToMode: ({ cfg }) => cfg.channels?.telegram?.replyToMode ?? "off",
buildToolContext: ({ context, hasRepliedRef }) =>
buildThreadToolContextFromMessageThreadOrReply({ context, hasRepliedRef }),
buildToolContext: ({ context, hasRepliedRef }) => {
// Telegram auto-threading should only use actual thread/topic IDs.
// ReplyToId is a message ID and causes invalid message_thread_id in DMs.
const threadId = context.MessageThreadId;
const rawCurrentMessageId = context.CurrentMessageId;
const currentMessageId =
typeof rawCurrentMessageId === "number"
? rawCurrentMessageId
: rawCurrentMessageId?.trim() || undefined;
return {
currentChannelId: context.To?.trim() || undefined,
currentThreadTs: threadId != null ? String(threadId) : undefined,
currentMessageId,
hasRepliedRef,
};
},
},
},
whatsapp: {