From ac45c8b4045fdb0cc99c8a7213f8092e6d3625d4 Mon Sep 17 00:00:00 2001 From: hsrvc <129702169+hsrvc@users.noreply.github.com> Date: Sat, 24 Jan 2026 19:06:37 +0800 Subject: [PATCH] fix: preserve Telegram topic (message_thread_id) in sub-agent announcements When native slash commands are executed in Telegram topics/forums, the originating topic context was not being preserved. This caused sub-agent announcements to be delivered to the wrong topic. Root cause: Native slash command context did not set OriginatingChannel and OriginatingTo, causing session delivery context to fallback to the user's personal ID instead of the group ID + topic. Fix: Added OriginatingChannel and OriginatingTo to native slash command context, ensuring topic information is preserved for sub-agent announcements. Related session fields: - lastThreadId: preserved via MessageThreadId - lastTo: now correctly set to group ID via OriginatingTo - deliveryContext: includes threadId for proper routing --- src/telegram/bot-native-commands.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/telegram/bot-native-commands.ts b/src/telegram/bot-native-commands.ts index 9f5dd5782..17952ac83 100644 --- a/src/telegram/bot-native-commands.ts +++ b/src/telegram/bot-native-commands.ts @@ -311,6 +311,9 @@ export const registerTelegramNativeCommands = ({ CommandTargetSessionKey: route.sessionKey, MessageThreadId: resolvedThreadId, IsForum: isForum, + // Originating context for sub-agent announce routing + OriginatingChannel: "telegram" as const, + OriginatingTo: `telegram:${chatId}`, }); const disableBlockStreaming =