





















@@ -965,6 +965,55 @@ describe("dispatchTelegramMessage draft streaming", () => {
965965});
966966});
967967968+it("does not mirror non-final tool progress into the session transcript", async () => {
969+const context = createContext();
970+context.ctxPayload.SessionKey = "agent:default:telegram:direct:123";
971+loadSessionStore.mockReturnValue({
972+"agent:default:telegram:direct:123": { sessionId: "s1" },
973+});
974+deliverReplies.mockImplementation(
975+async (params: {
976+replies?: Array<{ text?: string }>;
977+transcriptMirror?: (payload: { text?: string; mediaUrls?: string[] }) => Promise<void>;
978+}) => {
979+const text = params.replies
980+?.map((reply) => reply.text)
981+.filter(Boolean)
982+.join("\n\n");
983+await params.transcriptMirror?.({ text });
984+return { delivered: true };
985+},
986+);
987+dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ dispatcherOptions }) => {
988+await dispatcherOptions.deliver({ text: "🛠️ tool progress" }, { kind: "tool" });
989+await dispatcherOptions.deliver({ text: "Final answer" }, { kind: "final" });
990+return { queuedFinal: true };
991+});
992+993+await dispatchWithContext({
994+ context,
995+streamMode: "partial",
996+cfg: { agents: { defaults: { blockStreamingDefault: "on" } } },
997+telegramCfg: { streaming: { mode: "partial", preview: { toolProgress: true } } },
998+});
999+1000+expect(deliverReplies).toHaveBeenCalledTimes(2);
1001+expectRecordFields(mockCallArg(deliverReplies, 0), {
1002+transcriptMirror: undefined,
1003+});
1004+expect(typeof mockCallArg(deliverReplies, 1).transcriptMirror).toBe("function");
1005+expect(appendSessionTranscriptMessage).toHaveBeenCalledTimes(1);
1006+const transcriptCall = expectRecordFields(mockCallArg(appendSessionTranscriptMessage), {
1007+transcriptPath: "/tmp/session.jsonl",
1008+});
1009+expectRecordFields(transcriptCall.message, {
1010+role: "assistant",
1011+provider: "openclaw",
1012+model: "delivery-mirror",
1013+content: [{ type: "text", text: "Final answer" }],
1014+});
1015+});
1016+9681017it("mirrors the longer streamed preview when final text is truncated", async () => {
9691018const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
9701019const fullAnswer =
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。