






















@@ -976,6 +976,103 @@ describe("runEmbeddedPiAgent incomplete-turn safety", () => {
976976expect(retryInstruction).toBe(REASONING_ONLY_RETRY_INSTRUCTION);
977977});
978978979+it("does not apply planning-only or ack fast paths to Ollama runs", () => {
980+const retryInstruction = resolvePlanningOnlyRetryInstruction({
981+provider: "ollama",
982+modelId: "gemma4:31b",
983+prompt: "Please inspect the code, make the change, and run the checks.",
984+aborted: false,
985+timedOut: false,
986+attempt: makeAttemptResult({
987+assistantTexts: ["I'll inspect the code, make the change, and run the checks."],
988+}),
989+});
990+const ackInstruction = resolveAckExecutionFastPathInstruction({
991+provider: "ollama",
992+modelId: "gemma4:31b",
993+prompt: "go ahead",
994+});
995+996+expect(retryInstruction).toBeNull();
997+expect(ackInstruction).toBeNull();
998+});
999+1000+it("retries signed reasoning-only Ollama turns with a visible-answer continuation instruction", () => {
1001+const retryInstruction = resolveReasoningOnlyRetryInstruction({
1002+provider: "ollama",
1003+modelId: "gemma4:31b",
1004+aborted: false,
1005+timedOut: false,
1006+attempt: makeAttemptResult({
1007+assistantTexts: [],
1008+lastAssistant: {
1009+role: "assistant",
1010+stopReason: "end_turn",
1011+provider: "ollama",
1012+model: "gemma4:31b",
1013+content: [
1014+{
1015+type: "thinking",
1016+thinking: "internal reasoning",
1017+thinkingSignature: JSON.stringify({ id: "ollama_rs_helper", type: "reasoning" }),
1018+},
1019+],
1020+} as unknown as EmbeddedRunAttemptResult["lastAssistant"],
1021+}),
1022+});
1023+1024+expect(retryInstruction).toBe(REASONING_ONLY_RETRY_INSTRUCTION);
1025+});
1026+1027+it("retries unsigned-thinking Ollama turns via the empty-response path", () => {
1028+const retryInstruction = resolveEmptyResponseRetryInstruction({
1029+provider: "ollama",
1030+modelId: "gemma4:31b",
1031+payloadCount: 0,
1032+aborted: false,
1033+timedOut: false,
1034+attempt: makeAttemptResult({
1035+assistantTexts: [],
1036+lastAssistant: {
1037+role: "assistant",
1038+stopReason: "end_turn",
1039+provider: "ollama",
1040+model: "gemma4:31b",
1041+content: [
1042+{
1043+type: "thinking",
1044+thinking: "internal reasoning",
1045+},
1046+],
1047+} as unknown as EmbeddedRunAttemptResult["lastAssistant"],
1048+}),
1049+});
1050+1051+expect(retryInstruction).toBe(EMPTY_RESPONSE_RETRY_INSTRUCTION);
1052+});
1053+1054+it("retries generic empty Ollama turns without visible text", () => {
1055+const retryInstruction = resolveEmptyResponseRetryInstruction({
1056+provider: "ollama",
1057+modelId: "gemma4:31b",
1058+payloadCount: 0,
1059+aborted: false,
1060+timedOut: false,
1061+attempt: makeAttemptResult({
1062+assistantTexts: [],
1063+lastAssistant: {
1064+role: "assistant",
1065+stopReason: "end_turn",
1066+provider: "ollama",
1067+model: "gemma4:31b",
1068+content: [{ type: "text", text: "" }],
1069+} as unknown as EmbeddedRunAttemptResult["lastAssistant"],
1070+}),
1071+});
1072+1073+expect(retryInstruction).toBe(EMPTY_RESPONSE_RETRY_INSTRUCTION);
1074+});
1075+9791076it("treats exact NO_REPLY as a deliberate silent assistant reply", () => {
9801077const incompleteTurnText = resolveIncompleteTurnPayloadText({
9811078payloadCount: 0,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。