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
2026-01-24 06:27:24 -05:00
committed by GitHub
parent 8002143d92
commit be1cdc9370
4 changed files with 311 additions and 1 deletions

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