47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
|
|
import { describe, expect, test } from "bun:test"
|
||
|
|
|
||
|
|
import { extractAutoRetrySignal, isRetryableError } from "./error-classifier"
|
||
|
|
|
||
|
|
describe("runtime-fallback error classifier", () => {
|
||
|
|
test("detects cooling-down auto-retry status signals", () => {
|
||
|
|
//#given
|
||
|
|
const info = {
|
||
|
|
status:
|
||
|
|
"All credentials for model claude-opus-4-6-thinking are cooling down [retrying in ~5 days attempt #1]",
|
||
|
|
}
|
||
|
|
|
||
|
|
//#when
|
||
|
|
const signal = extractAutoRetrySignal(info)
|
||
|
|
|
||
|
|
//#then
|
||
|
|
expect(signal).toBeDefined()
|
||
|
|
})
|
||
|
|
|
||
|
|
test("treats cooling-down retry messages as retryable", () => {
|
||
|
|
//#given
|
||
|
|
const error = {
|
||
|
|
message:
|
||
|
|
"All credentials for model claude-opus-4-6-thinking are cooling down [retrying in ~5 days attempt #1]",
|
||
|
|
}
|
||
|
|
|
||
|
|
//#when
|
||
|
|
const retryable = isRetryableError(error, [400, 403, 408, 429, 500, 502, 503, 504, 529])
|
||
|
|
|
||
|
|
//#then
|
||
|
|
expect(retryable).toBe(true)
|
||
|
|
})
|
||
|
|
|
||
|
|
test("ignores non-retry assistant status text", () => {
|
||
|
|
//#given
|
||
|
|
const info = {
|
||
|
|
status: "Thinking...",
|
||
|
|
}
|
||
|
|
|
||
|
|
//#when
|
||
|
|
const signal = extractAutoRetrySignal(info)
|
||
|
|
|
||
|
|
//#then
|
||
|
|
expect(signal).toBeUndefined()
|
||
|
|
})
|
||
|
|
})
|