handle more API errors

Signed-off-by: Eason Goodale <easong@openai.com>
This commit is contained in:
Eason Goodale
2025-04-18 03:50:27 -07:00
parent 0d6a98f9af
commit ec70bbb4b9
2 changed files with 119 additions and 0 deletions
+8
View File
@@ -955,6 +955,14 @@ export class AgentLoop {
return true;
}
// Explicit check for OpenAI "server_error" types which are surfaced
// when the backend encounters an unexpected exception. The SDK often
// omits the HTTP status in this case (leaving it undefined) so we
// must inspect the structured error fields instead.
if (e.type === "server_error" || e.code === "server_error") {
return true;
}
if (typeof e.status === "number" && e.status >= 500) {
return true;
}