

























@@ -25,6 +25,7 @@ import {
2525createTestRegistry,
2626} from "../../test-utils/channel-plugins.js";
2727import { createInternalHookEventPayload } from "../../test-utils/internal-hook-event-payload.js";
28+import { getReplyPayloadMetadata } from "../reply-payload.js";
2829import type { MsgContext } from "../templating.js";
2930import { setReplyPayloadMetadata, type GetReplyOptions, type ReplyPayload } from "../types.js";
3031import { PROVIDER_CONVERSATION_STATE_ERROR_USER_MESSAGE } from "./provider-request-error-classifier.js";
@@ -6367,6 +6368,53 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
63676368});
63686369});
636963706371+it("keeps internal source reply metadata on TTS-cloned final payloads", async () => {
6372+setNoAbort();
6373+ttsMocks.state.synthesizeFinalAudio = true;
6374+sessionStoreMocks.currentEntry = {
6375+sessionId: "s1",
6376+updatedAt: 0,
6377+sendPolicy: "allow",
6378+};
6379+const dispatcher = createDispatcher();
6380+const sourceReply = setReplyPayloadMetadata(
6381+{ text: "message tool reply" },
6382+{
6383+deliverDespiteSourceReplySuppression: true,
6384+sourceReplyTranscriptMirror: {
6385+sessionKey: "agent:main",
6386+agentId: "main",
6387+text: "message tool reply",
6388+idempotencyKey: "run-tts:internal-source-reply:0",
6389+},
6390+},
6391+);
6392+const replyResolver = vi.fn(async () => sourceReply satisfies ReplyPayload);
6393+6394+const result = await dispatchReplyFromConfig({
6395+ctx: buildTestCtx({ Provider: "webchat", Surface: "webchat", SessionKey: "agent:main" }),
6396+cfg: emptyConfig,
6397+ dispatcher,
6398+ replyResolver,
6399+replyOptions: {
6400+sourceReplyDeliveryMode: "message_tool_only",
6401+},
6402+});
6403+6404+expect(result.queuedFinal).toBe(true);
6405+const queuedPayload = (dispatcher.sendFinalReply as ReturnType<typeof vi.fn>).mock
6406+.calls[0]?.[0];
6407+expect(queuedPayload).toMatchObject({
6408+text: "message tool reply",
6409+mediaUrl: "https://example.com/tts-synth.opus",
6410+audioAsVoice: true,
6411+});
6412+expect(getReplyPayloadMetadata(queuedPayload)?.sourceReplyTranscriptMirror).toMatchObject({
6413+sessionKey: "agent:main",
6414+idempotencyKey: "run-tts:internal-source-reply:0",
6415+});
6416+});
6417+63706418it("does not deliver marked runtime failure notices when sendPolicy denies delivery", async () => {
63716419setNoAbort();
63726420sessionStoreMocks.currentEntry = {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。