fix(coding-agent): retry connection lost errors

closes #3317
This commit is contained in:
Mario Zechner
2026-04-17 16:43:37 +02:00
parent 346c82425e
commit c15e4d4913
3 changed files with 36 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
import { fauxAssistantMessage } from "@mariozechner/pi-ai";
import { afterEach, describe, expect, it } from "vitest";
import { createHarness, getAssistantTexts, type Harness } from "../harness.js";
describe("issue #3317 network connection lost retry", () => {
const harnesses: Harness[] = [];
afterEach(() => {
while (harnesses.length > 0) {
harnesses.pop()?.cleanup();
}
});
it('retries transient "Network connection lost." failures', async () => {
const harness = await createHarness({
settings: { retry: { enabled: true, maxRetries: 3, baseDelayMs: 1 } },
});
harnesses.push(harness);
harness.setResponses([
fauxAssistantMessage("", { stopReason: "error", errorMessage: "Network connection lost." }),
fauxAssistantMessage("recovered after reconnect"),
]);
await harness.session.prompt("test");
expect(harness.faux.state.callCount).toBe(2);
expect(harness.eventsOfType("auto_retry_start").map((event) => event.errorMessage)).toEqual([
"Network connection lost.",
]);
expect(harness.eventsOfType("auto_retry_end").map((event) => event.success)).toEqual([true]);
expect(getAssistantTexts(harness)).toContain("recovered after reconnect");
});
});