fix: zai error handling (#1047)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { APIError } from "@letta-ai/letta-client/core/error";
|
||||
import { getErrorContext } from "./errorContext";
|
||||
import { checkZaiError } from "./zaiErrors";
|
||||
|
||||
const LETTA_USAGE_URL = "https://app.letta.com/settings/organization/usage";
|
||||
const LETTA_AGENTS_URL =
|
||||
@@ -293,6 +294,20 @@ export function formatErrorDetails(
|
||||
const encryptedContentMsg = checkEncryptedContentError(e);
|
||||
if (encryptedContentMsg) return encryptedContentMsg;
|
||||
|
||||
// Check for Z.ai provider errors (wrapped in generic "OpenAI" messages)
|
||||
const errorText =
|
||||
e instanceof APIError
|
||||
? e.message
|
||||
: e instanceof Error
|
||||
? e.message
|
||||
: typeof e === "string"
|
||||
? e
|
||||
: undefined;
|
||||
if (errorText) {
|
||||
const zaiMsg = checkZaiError(errorText);
|
||||
if (zaiMsg) return zaiMsg;
|
||||
}
|
||||
|
||||
// Handle APIError from streaming (event: error)
|
||||
if (e instanceof APIError) {
|
||||
const reasons = getErrorReasons(e);
|
||||
@@ -446,6 +461,8 @@ export function getRetryStatusMessage(
|
||||
): string {
|
||||
if (!errorDetail) return DEFAULT_RETRY_MESSAGE;
|
||||
|
||||
if (checkZaiError(errorDetail)) return "Z.ai API error, retrying...";
|
||||
|
||||
if (errorDetail.includes("Anthropic API is overloaded"))
|
||||
return "Anthropic API is overloaded, retrying...";
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user