Skip to content

Commit 06adb12

Browse files
committed
test(agents): cover scoped completion dispatch
1 parent 164cc67 commit 06adb12

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎src/agents/subagents/announce/subagent-announce-delivery.runtime.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
GatewayRequestContext,
66
GatewayRequestHandlers,
77
} from "../../../gateway/server-methods/types.js";
8+
import { withPluginRuntimeGatewayContextResolver } from "../../../plugins/runtime/gateway-request-scope.js";
89
import { dispatchSubagentAnnounceAgent } from "./subagent-announce-delivery.runtime.js";
910

1011
function createContext(handlers: GatewayRequestHandlers): GatewayRequestContext {
@@ -59,4 +60,37 @@ describe("subagent announce Gateway instance dispatch", () => {
5960
),
6061
).resolves.toEqual({ runId: "announce-run", status: "ok", summary: "delivered" });
6162
});
63+
64+
it("delivers through a lifecycle-fenced instance resolver scope", async () => {
65+
const context = createContext({
66+
agent: ({ respond }) => respond(true, { raw: true }),
67+
});
68+
const idempotencyKey = "scoped-subagent-announce";
69+
context.dedupe.set(`agent:${idempotencyKey}`, {
70+
ts: Date.now(),
71+
ok: true,
72+
payload: { runId: "scoped-announce-run", status: "ok", summary: "delivered" },
73+
});
74+
75+
await expect(
76+
withPluginRuntimeGatewayContextResolver(
77+
() => context,
78+
() =>
79+
dispatchSubagentAnnounceAgent(
80+
{
81+
message: "Process one completed child result.",
82+
idempotencyKey,
83+
},
84+
{
85+
expectFinal: true,
86+
forceSyntheticClient: true,
87+
},
88+
),
89+
),
90+
).resolves.toEqual({
91+
runId: "scoped-announce-run",
92+
status: "ok",
93+
summary: "delivered",
94+
});
95+
});
6296
});

0 commit comments

Comments
 (0)