|
|
@@ -1,4 +1,5 @@
|
|
|
import { describe, expect, test } from "bun:test"
|
|
|
+import { APICallError } from "ai"
|
|
|
import { SessionRetry } from "../../src/session/retry"
|
|
|
import { MessageV2 } from "../../src/session/message-v2"
|
|
|
|
|
|
@@ -128,4 +129,18 @@ describe("session.message-v2.fromError", () => {
|
|
|
expect(retryable).toBeDefined()
|
|
|
expect(retryable).toBe("Connection reset by server")
|
|
|
})
|
|
|
+
|
|
|
+ test("marks OpenAI 404 status codes as retryable", () => {
|
|
|
+ const error = new APICallError({
|
|
|
+ message: "boom",
|
|
|
+ url: "https://api.openai.com/v1/chat/completions",
|
|
|
+ requestBodyValues: {},
|
|
|
+ statusCode: 404,
|
|
|
+ responseHeaders: { "content-type": "application/json" },
|
|
|
+ responseBody: "{\"error\":\"boom\"}",
|
|
|
+ isRetryable: false,
|
|
|
+ })
|
|
|
+ const result = MessageV2.fromError(error, { providerID: "openai" }) as MessageV2.APIError
|
|
|
+ expect(result.data.isRetryable).toBe(true)
|
|
|
+ })
|
|
|
})
|