


















@@ -1783,6 +1783,49 @@ describe("dispatchTelegramMessage draft streaming", () => {
17831783});
17841784});
178517851786+it("mirrors a legitimate repeat after a new user turn instead of skipping it", async () => {
1787+const repeatedText = "Final answer";
1788+const context = createContext();
1789+context.ctxPayload.SessionKey = "agent:default:telegram:direct:123";
1790+loadSessionStore.mockReturnValue({
1791+"agent:default:telegram:direct:123": { sessionId: "s1" },
1792+});
1793+readLatestAssistantTextFromSessionTranscript.mockResolvedValue({
1794+text: repeatedText,
1795+timestamp: 1,
1796+});
1797+deliverReplies.mockImplementation(
1798+async (params: {
1799+replies?: Array<{ text?: string }>;
1800+transcriptMirror?: (payload: { text?: string; mediaUrls?: string[] }) => Promise<void>;
1801+}) => {
1802+const text = params.replies
1803+?.map((reply) => reply.text)
1804+.filter(Boolean)
1805+.join("\n\n");
1806+await params.transcriptMirror?.({ text });
1807+return { delivered: true };
1808+},
1809+);
1810+dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ dispatcherOptions }) => {
1811+await dispatcherOptions.deliver({ text: repeatedText }, { kind: "final" });
1812+return { queuedFinal: true };
1813+});
1814+1815+await dispatchWithContext({ context });
1816+1817+expect(appendSessionTranscriptMessage).toHaveBeenCalledTimes(1);
1818+const transcriptCall = expectRecordFields(mockCallArg(appendSessionTranscriptMessage), {
1819+transcriptPath: "/tmp/session.jsonl",
1820+});
1821+expectRecordFields(transcriptCall.message, {
1822+role: "assistant",
1823+provider: "openclaw",
1824+model: "delivery-mirror",
1825+content: [{ type: "text", text: repeatedText }],
1826+});
1827+});
1828+17861829it("mirrors the longer streamed preview when final text is truncated", async () => {
17871830const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
17881831const fullAnswer =
@@ -1814,15 +1857,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
18141857content: fullAnswer,
18151858messageId: 2001,
18161859});
1817-const transcriptCall = expectRecordFields(mockCallArg(appendSessionTranscriptMessage), {
1818-transcriptPath: "/tmp/session.jsonl",
1819-});
1820-expectRecordFields(transcriptCall.message, {
1821-role: "assistant",
1822-provider: "openclaw",
1823-model: "delivery-mirror",
1824-content: [{ type: "text", text: fullAnswer }],
1825-});
1860+expect(appendSessionTranscriptMessage).not.toHaveBeenCalled();
18261861});
1827186218281863it("emits the redacted appended message in transcript updates", async () => {
@@ -2691,7 +2726,10 @@ describe("dispatchTelegramMessage draft streaming", () => {
26912726async ({ dispatcherOptions, replyOptions }) => {
26922727await replyOptions?.onToolStart?.({ name: "exec", phase: "start" });
26932728replyOptions?.onVerboseProgressVisibility?.(() => true);
2694-await dispatcherOptions.deliver({ text: "Tool output visible to Telegram" }, { kind: "tool" });
2729+await dispatcherOptions.deliver(
2730+{ text: "Tool output visible to Telegram" },
2731+{ kind: "tool" },
2732+);
26952733await dispatcherOptions.deliver({ text: "Final answer" }, { kind: "final" });
26962734return { queuedFinal: true };
26972735},
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。