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
This commit is contained in:
hsrvc
2026-01-24 19:06:37 +08:00
committed by Peter Steinberger
parent fa746b05de
commit ac45c8b404

View File

@@ -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 =