fix(model-core): retry OpenAI usage_limit_reached fallbacks
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { shouldRetryError } from "./model-error-classifier"
|
||||
|
||||
describe("model-error-classifier OpenAI usage_limit_reached", () => {
|
||||
test("treats OpenAI usage_limit_reached response bodies as retryable provider exhaustion", () => {
|
||||
//#given
|
||||
const error = {
|
||||
name: "AI_APICallError",
|
||||
message: '{"error":{"type":"usage_limit_reached","message":"The usage limit has been reached"}}',
|
||||
}
|
||||
|
||||
//#when
|
||||
const result = shouldRetryError(error)
|
||||
|
||||
//#then
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -172,7 +172,7 @@ describe("model-error-classifier", () => {
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
test("treats usage limit reached message as non-retryable STOP error (no error name)", () => {
|
||||
test("treats provider usage limit reached message as retryable fallback signal", () => {
|
||||
//#given
|
||||
const error = { message: "usage limit has been reached for your account" }
|
||||
|
||||
@@ -180,7 +180,7 @@ describe("model-error-classifier", () => {
|
||||
const result = shouldRetryError(error)
|
||||
|
||||
//#then
|
||||
expect(result).toBe(false)
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("treats insufficient credits message as non-retryable STOP error (no error name)", () => {
|
||||
|
||||
@@ -40,6 +40,8 @@ const NON_RETRYABLE_ERROR_NAMES = new Set([
|
||||
const RETRYABLE_MESSAGE_PATTERNS = [
|
||||
"rate_limit",
|
||||
"rate limit",
|
||||
"usage_limit_reached",
|
||||
"usage limit has been reached",
|
||||
"quota",
|
||||
"all credentials for model",
|
||||
"cooling down",
|
||||
@@ -92,7 +94,6 @@ const RETRYABLE_MESSAGE_PATTERNS = [
|
||||
const STOP_MESSAGE_PATTERNS = [
|
||||
"quota will reset after",
|
||||
"quota exceeded",
|
||||
"usage limit has been reached",
|
||||
"free usage limit",
|
||||
"billing limit",
|
||||
"billing hard limit",
|
||||
|
||||
Reference in New Issue
Block a user