fix(agents): treat provider request-aborted as timeout for fallback (#1576)

* fix(agents): treat request-aborted as timeout for fallback

* test(e2e): add provider timeout fallback
This commit is contained in:
Luke authored and GitHub committed 2026-01-24 11:27:24 +00:00
1 parent 8002143d92
commit be1cdc9370
4 files changed
+311 -1

No files matched your search

+22
View File
@@ -346,6 +346,28 @@ describe("runWithModelFallback", () => {
expect(run.mock.calls[1]?.[1]).toBe("claude-haiku-3-5");
});
it("falls back on provider abort errors with request-aborted messages", async () => {
const cfg = makeCfg();
const run = vi
.fn()
.mockRejectedValueOnce(
Object.assign(new Error("Request was aborted"), { name: "AbortError" }),
)
.mockResolvedValueOnce("ok");
const result = await runWithModelFallback({
cfg,
provider: "openai",
model: "gpt-4.1-mini",
run,
});
expect(result.result).toBe("ok");
expect(run).toHaveBeenCalledTimes(2);
expect(run.mock.calls[1]?.[0]).toBe("anthropic");
expect(run.mock.calls[1]?.[1]).toBe("claude-haiku-3-5");
});
it("does not fall back on user aborts", async () => {
const cfg = makeCfg();
const run = vi