
















@@ -61,6 +61,14 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
6161expect(warnMessages().join("\n")).not.toContain(text);
6262}
636364+function runAttemptCall(index: number): { prompt?: string } {
65+const call = mockedRunEmbeddedAttempt.mock.calls[index];
66+if (!call) {
67+throw new Error(`Expected run embedded attempt call ${index}`);
68+}
69+return call[0] as { prompt?: string };
70+}
71+6472it("emits the before_agent_run hook block message as the agent payload", async () => {
6573mockedRunEmbeddedAttempt.mockResolvedValueOnce(
6674makeAttemptResult({
@@ -437,7 +445,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
437445});
438446439447expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
440-const secondCall = mockedRunEmbeddedAttempt.mock.calls.at(1)?.[0] as { prompt?: string };
448+const secondCall = runAttemptCall(1);
441449expect(secondCall.prompt).toContain(REASONING_ONLY_RETRY_INSTRUCTION);
442450expectWarnMessageWith("reasoning-only assistant turn detected");
443451});
@@ -472,7 +480,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
472480});
473481474482expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(1);
475-const onlyCall = mockedRunEmbeddedAttempt.mock.calls.at(0)?.[0] as { prompt?: string };
483+const onlyCall = runAttemptCall(0);
476484expect(onlyCall.prompt).not.toContain(REASONING_ONLY_RETRY_INSTRUCTION);
477485expect(onlyCall.prompt).not.toContain(EMPTY_RESPONSE_RETRY_INSTRUCTION);
478486expectNoWarnMessageWith("reasoning-only assistant turn detected");
@@ -641,7 +649,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
641649});
642650643651expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
644-const secondCall = mockedRunEmbeddedAttempt.mock.calls.at(1)?.[0] as { prompt?: string };
652+const secondCall = runAttemptCall(1);
645653expect(secondCall.prompt).toContain(REASONING_ONLY_RETRY_INSTRUCTION);
646654expectWarnMessageWith("reasoning-only assistant turn detected");
647655});
@@ -681,7 +689,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
681689});
682690683691expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
684-const secondCall = mockedRunEmbeddedAttempt.mock.calls.at(1)?.[0] as { prompt?: string };
692+const secondCall = runAttemptCall(1);
685693expect(secondCall.prompt).toContain(EMPTY_RESPONSE_RETRY_INSTRUCTION);
686694expectWarnMessageWith("empty response detected");
687695});
@@ -735,7 +743,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
735743});
736744737745expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
738-const secondCall = mockedRunEmbeddedAttempt.mock.calls.at(1)?.[0] as { prompt?: string };
746+const secondCall = runAttemptCall(1);
739747expect(secondCall.prompt).toContain(EMPTY_RESPONSE_RETRY_INSTRUCTION);
740748expectWarnMessageWith("empty response detected");
741749});
@@ -804,7 +812,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
804812});
805813806814expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(2);
807-const secondCall = mockedRunEmbeddedAttempt.mock.calls.at(1)?.[0] as { prompt?: string };
815+const secondCall = runAttemptCall(1);
808816expect(secondCall.prompt).toContain(EMPTY_RESPONSE_RETRY_INSTRUCTION);
809817expectWarnMessageWith("empty response detected");
810818});
@@ -1923,7 +1931,7 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
19231931});
1924193219251933expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(1);
1926-const onlyCall = mockedRunEmbeddedAttempt.mock.calls.at(0)?.[0] as { prompt?: string };
1934+const onlyCall = runAttemptCall(0);
19271935expect(onlyCall.prompt).not.toContain(REASONING_ONLY_RETRY_INSTRUCTION);
19281936expect(onlyCall.prompt).not.toContain(EMPTY_RESPONSE_RETRY_INSTRUCTION);
19291937expect(result.payloads).toEqual([{ text: "NO_REPLY" }]);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。