




















@@ -365,6 +365,13 @@ describe("dispatchTelegramMessage draft streaming", () => {
365365};
366366}
367367368+function createDirectSessionPayload(): TelegramMessageContext["ctxPayload"] {
369+return {
370+SessionKey: "agent:test:telegram:direct:123",
371+ChatType: "direct",
372+} as TelegramMessageContext["ctxPayload"];
373+}
374+368375function observeDeliveredReply(text: string): Promise<void> {
369376return new Promise((resolve) => {
370377deliverReplies.mockImplementation(async (params: { replies?: Array<{ text?: string }> }) => {
@@ -1644,4 +1651,41 @@ describe("dispatchTelegramMessage draft streaming", () => {
16441651expect(generateTopicLabel).not.toHaveBeenCalled();
16451652expect(bot.api.editForumTopic).not.toHaveBeenCalled();
16461653});
1654+1655+it("does not emit a silent-reply fallback when the dispatcher reports a queued final reply", async () => {
1656+dispatchReplyWithBufferedBlockDispatcher.mockResolvedValue({
1657+queuedFinal: true,
1658+counts: { block: 0, final: 1, tool: 0 },
1659+});
1660+1661+await dispatchWithContext({
1662+context: createContext({
1663+ctxPayload: createDirectSessionPayload(),
1664+}),
1665+streamMode: "off",
1666+});
1667+1668+expect(deliverReplies).not.toHaveBeenCalled();
1669+});
1670+1671+it("emits a silent-reply fallback when no final reply was queued and nothing was delivered", async () => {
1672+dispatchReplyWithBufferedBlockDispatcher.mockResolvedValue({
1673+queuedFinal: false,
1674+counts: { block: 0, final: 0, tool: 0 },
1675+});
1676+1677+await dispatchWithContext({
1678+context: createContext({
1679+ctxPayload: createDirectSessionPayload(),
1680+}),
1681+streamMode: "off",
1682+});
1683+1684+expect(deliverReplies).toHaveBeenCalledTimes(1);
1685+const replies = deliverReplies.mock.calls[0]?.[0]?.replies as
1686+| Array<{ text?: string }>
1687+| undefined;
1688+expect(replies?.[0]?.text?.trim()).toBeTruthy();
1689+expect(replies?.[0]?.text).not.toBe("NO_REPLY");
1690+});
16471691});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。