























@@ -3,8 +3,14 @@ import type { EmbeddedPiQueueMessageOutcome } from "./pi-embedded-runner/runs.js
33import { createSubagentAnnounceDeliveryRuntimeMock } from "./subagent-announce.test-support.js";
4455type AgentCallRequest = { method?: string; params?: Record<string, unknown> };
6+type AgentCallResponse = { runId?: string; status: string; error?: string };
677-const agentSpy = vi.fn(async (_req: AgentCallRequest) => ({ runId: "run-main", status: "ok" }));
8+const agentSpy = vi.fn(
9+async (_req: AgentCallRequest): Promise<AgentCallResponse> => ({
10+runId: "run-main",
11+status: "ok",
12+}),
13+);
814const sessionsDeleteSpy = vi.fn((_req: AgentCallRequest) => undefined);
915const callGatewayMock = vi.fn(async (_request: unknown) => ({}));
1016const loadSessionStoreMock = vi.fn((_storePath: string) => ({}));
@@ -120,7 +126,7 @@ vi.mock("./subagent-announce-delivery.js", () => ({
120126const effectiveOrigin =
121127params.completionDirectOrigin ?? params.requesterOrigin ?? params.directOrigin;
122128123-await callGatewayMock({
129+const response = (await callGatewayMock({
124130method: "agent",
125131params: {
126132sessionKey: params.targetRequesterSessionKey,
@@ -139,7 +145,11 @@ vi.mock("./subagent-announce-delivery.js", () => ({
139145threadId: effectiveOrigin?.threadId,
140146}),
141147},
142-});
148+})) as { status?: string; error?: string };
149+150+if (response.status === "error") {
151+return { delivered: false, path: "direct", error: response.error ?? "agent delivery failed" };
152+}
143153144154return { delivered: true, path: "direct" };
145155},
@@ -180,6 +190,7 @@ vi.mock("./subagent-announce-delivery.js", () => ({
180190}));
181191182192vi.mock("./subagent-announce.registry.runtime.js", () => subagentRegistryRuntimeMock);
193+import { defaultRuntime } from "../runtime.js";
183194import { applySubagentWaitOutcome } from "./subagent-announce-output.js";
184195import { runSubagentAnnounceFlow } from "./subagent-announce.js";
185196@@ -502,4 +513,35 @@ describe("subagent announce seam flow", () => {
502513expect(agentCall.params?.accountId).toBe("bot-123");
503514expect(agentCall.params?.to).toBe("-1001234567890");
504515});
516+517+it("logs direct completion announce delivery failures through the gateway log path", async () => {
518+const logSpy = vi.spyOn(defaultRuntime, "log").mockImplementation(() => {});
519+agentSpy.mockResolvedValueOnce({ status: "error", error: "Outbound not configured for slack" });
520+521+const didAnnounce = await runSubagentAnnounceFlow({
522+childSessionKey: "agent:main:subagent:slack",
523+childRunId: "run-direct-failure-log",
524+requesterSessionKey: "agent:main:main",
525+requesterDisplayKey: "main",
526+requesterOrigin: {
527+channel: "slack",
528+to: "C123",
529+},
530+task: "deliver completion",
531+timeoutMs: 10,
532+cleanup: "keep",
533+waitForCompletion: false,
534+startedAt: 10,
535+endedAt: 20,
536+outcome: { status: "ok" },
537+roundOneReply: "done",
538+expectsCompletionMessage: true,
539+});
540+541+expect(didAnnounce).toBe(false);
542+expect(logSpy).toHaveBeenCalledWith(
543+"[warn] Subagent completion direct announce failed for run run-direct-failure-log: Outbound not configured for slack",
544+);
545+logSpy.mockRestore();
546+});
505547});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。