


























@@ -260,6 +260,15 @@ function requireRunReplyAgentCall(index = 0) {
260260return call;
261261}
262262263+function requireLastRunReplyAgentCall() {
264+const calls = vi.mocked(runReplyAgent).mock.calls;
265+const call = calls[calls.length - 1]?.[0];
266+if (!call) {
267+throw new Error("last runReplyAgent call missing");
268+}
269+return call;
270+}
271+263272describe("runPreparedReply media-only handling", () => {
264273beforeAll(async () => {
265274({ runPreparedReply } = await import("./get-reply-run.js"));
@@ -308,7 +317,7 @@ describe("runPreparedReply media-only handling", () => {
308317it("propagates non-visible assistant silence for group runs", async () => {
309318await runPreparedReply(baseParams());
310319311-let call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
320+let call = requireLastRunReplyAgentCall();
312321expect(call?.followupRun.run.allowEmptyAssistantReplyAsSilent).toBe(true);
313322314323await runPreparedReply(
@@ -317,7 +326,7 @@ describe("runPreparedReply media-only handling", () => {
317326}),
318327);
319328320-call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
329+call = requireLastRunReplyAgentCall();
321330expect(call?.followupRun.run.allowEmptyAssistantReplyAsSilent).toBe(true);
322331});
323332@@ -346,7 +355,7 @@ describe("runPreparedReply media-only handling", () => {
346355}),
347356);
348357349-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
358+const call = requireLastRunReplyAgentCall();
350359expect(call?.followupRun.run.allowEmptyAssistantReplyAsSilent).toBe(false);
351360});
352361@@ -445,7 +454,7 @@ describe("runPreparedReply media-only handling", () => {
445454}),
446455);
447456448-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
457+const call = requireLastRunReplyAgentCall();
449458expect(call?.followupRun.run.allowEmptyAssistantReplyAsSilent).toBe(true);
450459},
451460);
@@ -482,7 +491,7 @@ describe("runPreparedReply media-only handling", () => {
482491}),
483492);
484493485-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
494+const call = requireLastRunReplyAgentCall();
486495expect(call?.followupRun.run.allowEmptyAssistantReplyAsSilent).toBe(false);
487496});
488497@@ -1044,7 +1053,7 @@ describe("runPreparedReply media-only handling", () => {
10441053previousRun.complete();
1045105410461055await expect(runPromise).resolves.toEqual({ text: "ok" });
1047-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1056+const call = requireLastRunReplyAgentCall();
10481057expect(call?.followupRun.run.authProfileId).toBe("profile-after-wait");
10491058expect(vi.mocked(resolveSessionAuthProfileOverride)).toHaveBeenCalledTimes(1);
10501059});
@@ -1105,7 +1114,7 @@ describe("runPreparedReply media-only handling", () => {
11051114rotatedRun.complete();
1106111511071116await expect(runPromise).resolves.toEqual({ text: "ok" });
1108-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1117+const call = requireLastRunReplyAgentCall();
11091118expect(call?.followupRun.run.sessionId).toBe("session-after-rotation");
11101119});
11111120it("continues when the original owner clears before an unrelated run appears", async () => {
@@ -1166,7 +1175,7 @@ describe("runPreparedReply media-only handling", () => {
11661175previousRun.complete();
1167117611681177await expect(runPromise).resolves.toEqual({ text: "ok" });
1169-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1178+const call = requireLastRunReplyAgentCall();
11701179expect(call?.commandBody).toContain("System: [t] Initial event.");
11711180expect(call?.commandBody).not.toContain("System: [t] Post-compaction context.");
11721181expect(call?.transcriptCommandBody).not.toContain("System: [t] Initial event.");
@@ -1204,7 +1213,7 @@ describe("runPreparedReply media-only handling", () => {
12041213}),
12051214);
120612151207-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1216+const call = requireLastRunReplyAgentCall();
12081217expect(call?.commandBody).toContain("what does this mean?");
12091218expect(call?.commandBody).not.toContain("Reply target of current user message");
12101219expect(call?.transcriptCommandBody).toBe("what does this mean?");
@@ -1244,7 +1253,7 @@ describe("runPreparedReply media-only handling", () => {
12441253}),
12451254);
124612551247-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1256+const call = requireLastRunReplyAgentCall();
12481257expect(call?.commandBody).toContain(heartbeatPrompt);
12491258expect(call?.followupRun.prompt).toContain(heartbeatPrompt);
12501259expect(call?.transcriptCommandBody).toBe("[OpenClaw heartbeat poll]");
@@ -1293,7 +1302,7 @@ describe("runPreparedReply media-only handling", () => {
12931302}),
12941303);
129513041296-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1305+const call = requireLastRunReplyAgentCall();
12971306expect(buildGroupChatContext).toHaveBeenCalledTimes(1);
12981307const groupContextParams = requireMockCallArg(
12991308vi.mocked(buildGroupChatContext),
@@ -1360,7 +1369,7 @@ describe("runPreparedReply media-only handling", () => {
13601369}),
13611370);
136213711363-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1372+const call = requireLastRunReplyAgentCall();
13641373expect(call?.commandBody).toContain("A new session was started via /new or /reset.");
13651374expect(call?.commandBody).toContain("Conversation info (untrusted metadata):");
13661375expect(call?.commandBody).toContain("Sender (untrusted metadata):");
@@ -1406,7 +1415,7 @@ describe("runPreparedReply media-only handling", () => {
14061415}),
14071416);
140814171409-const call = vi.mocked(runReplyAgent).mock.calls.at(-1)?.[0];
1418+const call = requireLastRunReplyAgentCall();
14101419expect(call?.commandBody).toContain("A new session was started via /new or /reset.");
14111420expect(call?.commandBody).toContain("summarize my workspace");
14121421expect(call?.transcriptCommandBody).toBe("summarize my workspace");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。