From d264c761cb6d52cbbaa2af4bc0ec10860b776a7a Mon Sep 17 00:00:00 2001 From: moltbot886 Date: Mon, 23 Mar 2026 07:44:16 +0800 Subject: [PATCH] fix(telegram): add allow_sending_without_reply to prevent lost messages When a Telegram message that OpenClaw is replying to gets deleted before delivery, the Telegram API rejects the entire sendMessage call with "message to be replied not found". This causes the bot's response to be silently lost and stuck in the failed delivery queue permanently. Setting allow_sending_without_reply: true tells Telegram to deliver the message as a standalone message if the reply target no longer exists, instead of failing the entire request. Applied to all 6 locations across 4 source files where reply_to_message_id is set: - send.ts: buildTelegramReplyParams (both reply_parameters and plain reply) - bot/delivery.send.ts: buildTelegramSendParams - draft-stream.ts: draft stream reply params - bot-handlers.runtime.ts: error reply messages (file too large, media download failed) Co-Authored-By: Claude Opus 4.6 (1M context) --- extensions/telegram/src/bot-handlers.runtime.ts | 2 ++ extensions/telegram/src/bot/delivery.send.ts | 1 + extensions/telegram/src/draft-stream.ts | 2 +- extensions/telegram/src/send.ts | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/telegram/src/bot-handlers.runtime.ts b/extensions/telegram/src/bot-handlers.runtime.ts index 6f088b3e437..d3d90d382e8 100644 --- a/extensions/telegram/src/bot-handlers.runtime.ts +++ b/extensions/telegram/src/bot-handlers.runtime.ts @@ -1017,6 +1017,7 @@ export const registerTelegramHandlers = ({ fn: () => bot.api.sendMessage(chatId, `⚠️ File too large. Maximum size is ${limitMb}MB.`, { reply_to_message_id: msg.message_id, + allow_sending_without_reply: true, }), }).catch(() => {}); } @@ -1030,6 +1031,7 @@ export const registerTelegramHandlers = ({ fn: () => bot.api.sendMessage(chatId, "⚠️ Failed to download media. Please try again.", { reply_to_message_id: msg.message_id, + allow_sending_without_reply: true, }), }).catch(() => {}); return; diff --git a/extensions/telegram/src/bot/delivery.send.ts b/extensions/telegram/src/bot/delivery.send.ts index 9c0c6a77e10..c3768cf1b5d 100644 --- a/extensions/telegram/src/bot/delivery.send.ts +++ b/extensions/telegram/src/bot/delivery.send.ts @@ -82,6 +82,7 @@ export function buildTelegramSendParams(opts?: { const params: Record = {}; if (opts?.replyToMessageId) { params.reply_to_message_id = opts.replyToMessageId; + params.allow_sending_without_reply = true; } if (threadParams) { params.message_thread_id = threadParams.message_thread_id; diff --git a/extensions/telegram/src/draft-stream.ts b/extensions/telegram/src/draft-stream.ts index 3cb2d4074f2..f79cc50c58e 100644 --- a/extensions/telegram/src/draft-stream.ts +++ b/extensions/telegram/src/draft-stream.ts @@ -125,7 +125,7 @@ export function createTelegramDraftStream(params: { const threadParams = buildTelegramThreadParams(params.thread); const replyParams = params.replyToMessageId != null - ? { ...threadParams, reply_to_message_id: params.replyToMessageId } + ? { ...threadParams, reply_to_message_id: params.replyToMessageId, allow_sending_without_reply: true } : threadParams; const resolvedDraftApi = prefersDraftTransport ? resolveSendMessageDraftApi(params.api) diff --git a/extensions/telegram/src/send.ts b/extensions/telegram/src/send.ts index 55f1d689359..74e5699a477 100644 --- a/extensions/telegram/src/send.ts +++ b/extensions/telegram/src/send.ts @@ -394,9 +394,11 @@ function buildTelegramThreadReplyParams(params: { threadParams.reply_parameters = { message_id: replyToMessageId, quote: params.quoteText.trim(), + allow_sending_without_reply: true, }; } else { threadParams.reply_to_message_id = replyToMessageId; + threadParams.allow_sending_without_reply = true; } } return threadParams;