Skip to content

Commit c917fd5

Browse files
committed
codex: avoid mirroring telegram progress into active transcripts
1 parent 651ec20 commit c917fd5

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,55 @@ describe("dispatchTelegramMessage draft streaming", () => {
965965
});
966966
});
967967

968+
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+
9681017
it("mirrors the longer streamed preview when final text is truncated", async () => {
9691018
const { answerDraftStream } = setupDraftStreams({ answerMessageId: 2001 });
9701019
const fullAnswer =

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ export const dispatchTelegramMessage = async ({
10921092
}
10931093
const result = await (telegramDeps.deliverReplies ?? deliverReplies)({
10941094
...deliveryBaseOptions,
1095+
transcriptMirror: options?.durable ? deliveryBaseOptions.transcriptMirror : undefined,
10951096
replies: [deliverablePayload],
10961097
onVoiceRecording: sendRecordVoice,
10971098
silent,

0 commit comments

Comments
 (0)