fix: no retry on quota limit errors (#1072)

This commit is contained in:
Charles Packer
2026-02-20 16:30:20 -08:00
committed by GitHub
parent 2e8b00f8cc
commit 150ff0d998
4 changed files with 116 additions and 15 deletions

View File

@@ -182,6 +182,60 @@ describe("formatErrorDetails", () => {
expect(message).toContain("/model");
});
test("uses premium-specific guidance for premium-usage-exceeded", () => {
const error = new APIError(
429,
{
error: "Rate limited",
reasons: ["premium-usage-exceeded"],
},
undefined,
new Headers(),
);
const message = formatErrorDetails(error);
expect(message).toContain("Premium model usage limit");
expect(message).toContain("Standard or Basic hosted models");
expect(message).toContain("/model");
expect(message).not.toContain("hosted model usage limit");
});
test("uses standard-specific guidance for standard-usage-exceeded", () => {
const error = new APIError(
429,
{
error: "Rate limited",
reasons: ["standard-usage-exceeded"],
},
undefined,
new Headers(),
);
const message = formatErrorDetails(error);
expect(message).toContain("Standard model usage limit");
expect(message).toContain("Basic hosted models");
expect(message).toContain("/model");
});
test("uses basic-specific guidance for basic-usage-exceeded", () => {
const error = new APIError(
429,
{
error: "Rate limited",
reasons: ["basic-usage-exceeded"],
},
undefined,
new Headers(),
);
const message = formatErrorDetails(error);
expect(message).toContain("Basic model usage limit");
expect(message).toContain("/model");
});
test("formats Z.ai error from APIError with embedded error code", () => {
const error = new APIError(
429,