From 92c953d0749143eb2a3f31f3cd6ad0e8eabf48c3 Mon Sep 17 00:00:00 2001 From: "clawd@msch" Date: Mon, 5 Jan 2026 17:10:34 +0000 Subject: [PATCH] Telegram: send tool summaries during replies --- src/telegram/bot.ts | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/telegram/bot.ts b/src/telegram/bot.ts index cfe76d0bc61..2b8425a4f27 100644 --- a/src/telegram/bot.ts +++ b/src/telegram/bot.ts @@ -228,7 +228,33 @@ export function createTelegramBot(opts: TelegramBotOptions) { ); } - let blockSendChain: Promise = Promise.resolve(); + let replySendChain: Promise = Promise.resolve(); + const sendToolResult = (payload: ReplyPayload) => { + if ( + !payload?.text && + !payload?.mediaUrl && + !(payload?.mediaUrls?.length ?? 0) + ) { + return; + } + replySendChain = replySendChain + .then(async () => { + await deliverReplies({ + replies: [payload], + chatId: String(chatId), + token: opts.token, + runtime, + bot, + replyToMode, + textLimit, + }); + }) + .catch((err) => { + runtime.error?.( + danger(`telegram tool update failed: ${String(err)}`), + ); + }); + }; const sendBlockReply = (payload: ReplyPayload) => { if ( !payload?.text && @@ -237,7 +263,7 @@ export function createTelegramBot(opts: TelegramBotOptions) { ) { return; } - blockSendChain = blockSendChain + replySendChain = replySendChain .then(async () => { await deliverReplies({ replies: [payload], @@ -258,7 +284,11 @@ export function createTelegramBot(opts: TelegramBotOptions) { const replyResult = await getReplyFromConfig( ctxPayload, - { onReplyStart: sendTyping, onBlockReply: sendBlockReply }, + { + onReplyStart: sendTyping, + onToolResult: sendToolResult, + onBlockReply: sendBlockReply, + }, cfg, ); const replies = replyResult @@ -266,7 +296,7 @@ export function createTelegramBot(opts: TelegramBotOptions) { ? replyResult : [replyResult] : []; - await blockSendChain; + await replySendChain; if (replies.length === 0) return; await deliverReplies({