

























@@ -1215,6 +1215,56 @@ describe("deliverSubagentAnnouncement completion delivery", () => {
12151215);
12161216});
121712171218+it("directly delivers direct-message subagent text when the announce agent omits the result", async () => {
1219+const callGateway = createGatewayMock({
1220+result: {
1221+payloads: [{ text: "TG88042_NO_REOUTPUT" }],
1222+},
1223+});
1224+const sendMessage = createSendMessageMock();
1225+1226+const result = await deliverDiscordDirectMessageCompletion({
1227+ callGateway,
1228+ sendMessage,
1229+internalEvents: [
1230+{
1231+type: "task_completion",
1232+source: "subagent",
1233+childSessionKey: "agent:worker:subagent:child",
1234+childSessionId: "child-session-id",
1235+announceType: "subagent task",
1236+taskLabel: "direct completion smoke",
1237+status: "ok",
1238+statusLabel: "completed successfully",
1239+result: "TG88042_CHILD",
1240+replyInstruction: "Summarize the result.",
1241+},
1242+],
1243+});
1244+1245+expectRecordFields(result, {
1246+delivered: true,
1247+path: "direct",
1248+});
1249+expect(sendMessage).toHaveBeenCalledWith(
1250+expect.objectContaining({
1251+channel: "discord",
1252+accountId: "acct-1",
1253+to: "dm:U123",
1254+content: "TG88042_CHILD",
1255+idempotencyKey: "announce-dm-fallback-empty:text-direct",
1256+}),
1257+);
1258+expectGatewayAgentParams(callGateway, {
1259+deliver: false,
1260+channel: "discord",
1261+accountId: "acct-1",
1262+to: "dm:U123",
1263+threadId: undefined,
1264+sourceReplyDeliveryMode: "message_tool_only",
1265+});
1266+});
1267+12181268it("does not directly deliver failed subagent placeholder output", async () => {
12191269const callGateway = createGatewayMock({
12201270result: {
@@ -4176,14 +4226,18 @@ describe("deliverSubagentAnnouncement completion delivery", () => {
41764226});
41774227});
417842284179-it("keeps automatic final delivery for direct subagent completions", async () => {
4229+it("requires message-tool delivery for direct subagent completions", async () => {
41804230const callGateway = createGatewayMock({
41814231result: {
4182-payloads: [{ text: "The subagent is done." }],
4232+payloads: [{ text: "The subagent is done: child completion output" }],
4233+didSendViaMessagingTool: true,
4234+messagingToolSentTexts: ["The subagent is done: child completion output"],
41834235},
41844236});
4237+const sendMessage = createSendMessageMock();
41854238const result = await deliverDiscordDirectMessageCompletion({
41864239 callGateway,
4240+ sendMessage,
41874241sourceTool: "subagent_announce",
41884242internalEvents: [
41894243{
@@ -4206,12 +4260,14 @@ describe("deliverSubagentAnnouncement completion delivery", () => {
42064260path: "direct",
42074261});
42084262expectGatewayAgentParams(callGateway, {
4209-deliver: true,
4263+deliver: false,
42104264channel: "discord",
42114265accountId: "acct-1",
42124266to: "dm:U123",
42134267threadId: undefined,
4268+sourceReplyDeliveryMode: "message_tool_only",
42144269});
4270+expect(sendMessage).not.toHaveBeenCalled();
42154271});
4216427242174273it("falls back to the external requester route when completion origin is internal", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。