Skip to content

Commit 33eafa3

Browse files
committed
fix: suppress telegram fallback after message-tool-only turns
1 parent 69c8097 commit 33eafa3

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

extensions/telegram/src/bot-message-dispatch.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,44 @@ describe("dispatchTelegramMessage draft streaming", () => {
27762776
expect(sendMessageTelegram).not.toHaveBeenCalled();
27772777
});
27782778

2779+
it("does not add empty-response fallback after message-tool-only delivery skips final text", async () => {
2780+
setupDraftStreams({ answerMessageId: 2001, reasoningMessageId: 3001 });
2781+
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ dispatcherOptions }) => {
2782+
dispatcherOptions.onSkip?.({ text: "NO_REPLY" }, { kind: "final", reason: "silent" });
2783+
dispatcherOptions.onSkip?.(
2784+
{ text: "automatic final suppressed" },
2785+
{ kind: "final", reason: "cancelled" },
2786+
);
2787+
return {
2788+
queuedFinal: false,
2789+
counts: { block: 0, final: 0, tool: 0 },
2790+
sourceReplyDeliveryMode: "message_tool_only",
2791+
};
2792+
});
2793+
2794+
await dispatchWithContext({
2795+
context: createContext({
2796+
ctxPayload: {
2797+
SessionKey: "agent:main:telegram:group:-100123",
2798+
ChatType: "group",
2799+
} as unknown as TelegramMessageContext["ctxPayload"],
2800+
primaryCtx: {
2801+
message: { chat: { id: -100123, type: "supergroup" } },
2802+
} as TelegramMessageContext["primaryCtx"],
2803+
msg: {
2804+
chat: { id: -100123, type: "supergroup" },
2805+
message_id: 456,
2806+
} as TelegramMessageContext["msg"],
2807+
chatId: -100123,
2808+
isGroup: true,
2809+
}),
2810+
});
2811+
2812+
expect(deliverReplies).not.toHaveBeenCalled();
2813+
expect(editMessageTelegram).not.toHaveBeenCalled();
2814+
expect(sendMessageTelegram).not.toHaveBeenCalled();
2815+
});
2816+
27792817
it("runs ambient room events as tool-only invisible turns", async () => {
27802818
const historyKey = "telegram:group:-100123";
27812819
const groupHistories = new Map([

extensions/telegram/src/bot-message-dispatch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,7 @@ export const dispatchTelegramMessage = async ({
22092209
!isRoomEvent &&
22102210
(dispatchError ||
22112211
(!deliverySummary.delivered &&
2212+
!suppressSilentReplyFallback &&
22122213
(deliverySummary.skippedNonSilent > 0 || deliverySummary.failedNonSilent > 0)));
22132214
if (shouldSendFailureFallback) {
22142215
const fallbackText = dispatchError

0 commit comments

Comments
 (0)