Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions server/drivers/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,29 @@ describe("classifyError", () => {
});
});

it.each([
[429, "rate_limited"],
[500, "server_error"],
[502, "server_error"],
[503, "server_error"],
[504, "server_error"],
])("retries unexpected status %s from both streamed errors and CLI exits", (status, reason) => {
const text = `unexpected status ${status}`;
expect(classifyError(new Error(text))).toEqual({ transient: true, reason });
expect(classifyError({ text })).toEqual({ transient: true, reason });
expect(classifyError({ exitCode: 1, stderr: text })).toEqual({ transient: true, reason });
});

it.each([
[400, "invalid_request"],
[401, "auth"],
[403, "auth"],
[404, "not_found"],
[422, "invalid_request"],
])("keeps unexpected status %s terminal", (status, reason) => {
expect(classifyError({ text: `unexpected status ${status}` })).toEqual({ transient: false, reason });
});

it("calls Codex's failed workspace routing discovery transient, but not a refused sign-in", () => {
expect(classifyError({ text: "stream error: workspace routing discovery failed: error sending request" })).toEqual({ transient: true, reason: "server_error" });
expect(classifyError(new Error("workspace routing discovery timed out"))).toEqual({ transient: true, reason: "server_error" });
Expand Down
2 changes: 1 addition & 1 deletion server/drivers/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const TERMINAL_PATTERNS: Array<{ pattern: RegExp; reason: TerminalReason }> = [
{ pattern: USAGE_LIMIT, reason: "quota" },
{ pattern: /\b402\b|\bquota\b|\bbilling\b|\bsubscription\b/i, reason: "quota" },
{ pattern: /\bmodel not found\b|\bunknown model\b|\bdoes not exist for model\b|\bunsupported model\b/i, reason: "unknown_model" },
{ pattern: /\b400\b|\b422\b|\binvalid request\b|\bmalformed\b|\bunexpected status\b/i, reason: "invalid_request" },
{ pattern: /\b400\b|\b422\b|\binvalid request\b|\bmalformed\b/i, reason: "invalid_request" },
{ pattern: /\b404\b|\bno such thread\b|\bthread gone\b/i, reason: "not_found" },
// A turn the user stopped must never come back as an auto-retry.
{ pattern: /\b(?:interrupted|cancelled by user)\b/i, reason: "interrupted" },
Expand Down
Loading