fix: account for additional openai retry case (#24063)
This commit is contained in:
@@ -1075,6 +1075,30 @@ describe("session.message-v2.fromError", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("serializes OpenAI response server_error stream chunks as retryable APIError", () => {
|
||||
const body = {
|
||||
type: "error",
|
||||
sequence_number: 2,
|
||||
error: {
|
||||
type: "server_error",
|
||||
code: "server_error",
|
||||
message:
|
||||
"An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID req_77eccd008d984bf6bf82d1b2c2b68715 in your message.",
|
||||
param: null,
|
||||
},
|
||||
}
|
||||
const result = MessageV2.fromError({ message: JSON.stringify(body) }, { providerID })
|
||||
|
||||
expect(result).toStrictEqual({
|
||||
name: "APIError",
|
||||
data: {
|
||||
message: body.error.message,
|
||||
isRetryable: true,
|
||||
responseBody: JSON.stringify(body),
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("detects context overflow from APICallError provider messages", () => {
|
||||
const cases = [
|
||||
"prompt is too long: 213462 tokens > 200000 maximum",
|
||||
|
||||
Reference in New Issue
Block a user