Compare commits

...

2 Commits

Author SHA1 Message Date
Peter Steinberger
e9dc73a7dc fix: preserve telegram topic routing for native slash commands (#1587) (thanks @hsrvc) 2026-01-24 12:25:42 +00:00
hsrvc
6c61c848a5 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
2026-01-24 12:20:58 +00:00
4 changed files with 11 additions and 1 deletions

View File

@ -49,6 +49,7 @@ Docs: https://docs.clawd.bot
- Discord: retry rate-limited allowlist resolution + command deploy to avoid gateway crashes. (commit f70ac0c7c)
- Mentions: ignore mentionPattern matches when another explicit mention is present in group chats (Slack/Discord/Telegram/WhatsApp). (commit d905ca0e0)
- Telegram: render markdown in media captions. (#1478)
- Telegram: preserve topic routing for native slash command sub-agent announcements. (#1587) Thanks @hsrvc.
- MS Teams: remove `.default` suffix from Graph scopes and Bot Framework probe scopes. (#1507, #1574) Thanks @Evizero.
- Browser: keep extension relay tabs controllable when the extension reuses a session id after switching tabs. (#1160)
- Voice wake: auto-save wake words on blur/submit across iOS/Android and align limits with macOS. (commit 69f645c66)

View File

@ -1,3 +1,4 @@
import { inspect } from "node:util";
import { Client } from "@buape/carbon";
import { GatewayIntents, GatewayPlugin } from "@buape/carbon/gateway";
import { Routes } from "discord-api-types/v10";
@ -95,7 +96,7 @@ function formatDiscordDeployErrorDetails(err: unknown): string {
try {
bodyText = JSON.stringify(rawBody);
} catch {
bodyText = String(rawBody);
bodyText = inspect(rawBody, { depth: 4, breakLength: 120 });
}
if (bodyText) {
const maxLen = 800;

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 =

View File

@ -2187,6 +2187,11 @@ describe("createTelegramBot", () => {
match: "",
});
expect(replySpy).toHaveBeenCalledTimes(1);
const payload = replySpy.mock.calls[0][0];
expect(payload.OriginatingChannel).toBe("telegram");
expect(payload.OriginatingTo).toBe("telegram:-1001234567890");
expect(payload.MessageThreadId).toBe(99);
expect(sendMessageSpy).toHaveBeenCalledWith(
"-1001234567890",
expect.any(String),