






















@@ -18,6 +18,30 @@ import {
18181919const runCronIsolatedAgentTurn = await loadRunCronIsolatedAgentTurn();
202021+function requireEmbeddedAgentCall(index: number): { prompt?: string } {
22+const call = runEmbeddedPiAgentMock.mock.calls[index]?.[0] as { prompt?: string } | undefined;
23+if (!call) {
24+throw new Error(`Expected embedded PI agent call ${index}`);
25+}
26+return call;
27+}
28+29+function requireDeliveryRequest(): {
30+skipHeartbeatDelivery?: boolean;
31+deliveryPayloads?: unknown;
32+} {
33+const request = dispatchCronDeliveryMock.mock.calls[0]?.[0] as
34+| {
35+skipHeartbeatDelivery?: boolean;
36+deliveryPayloads?: unknown;
37+}
38+| undefined;
39+if (!request) {
40+throw new Error("Expected cron delivery request");
41+}
42+return request;
43+}
44+2145describe("runCronIsolatedAgentTurn — interim ack retry", () => {
2246setupRunCronIsolatedAgentTurnSuite();
2347@@ -61,7 +85,7 @@ describe("runCronIsolatedAgentTurn — interim ack retry", () => {
61856286mockRunCronFallbackPassthrough();
6387await runTurnAndExpectOk(2, 2);
64-expect(runEmbeddedPiAgentMock.mock.calls[1]?.[0]?.prompt).toContain(
88+expect(requireEmbeddedAgentCall(1).prompt).toContain(
6589"previous response was only an acknowledgement",
6690);
6791});
@@ -132,9 +156,9 @@ describe("runCronIsolatedAgentTurn — interim ack retry", () => {
132156133157expect(result.status).toBe("error");
134158expect(result.error).toBe("SYSTEM_RUN_DENIED: approval required");
135-const deliveryRequest = dispatchCronDeliveryMock.mock.calls[0]?.[0];
136-expect(deliveryRequest?.skipHeartbeatDelivery).toBe(false);
137-expect(deliveryRequest?.deliveryPayloads).toEqual([
159+const deliveryRequest = requireDeliveryRequest();
160+expect(deliveryRequest.skipHeartbeatDelivery).toBe(false);
161+expect(deliveryRequest.deliveryPayloads).toEqual([
138162{ text: "SYSTEM_RUN_DENIED: approval required", isError: true },
139163]);
140164});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。