mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 13:44:03 +00:00
fix(agents): fail over and sanitize Codex server_error payloads (#42892)
Merged via squash.
Prepared head SHA: 6db9a5f02d
Co-authored-by: xaeon2026 <264572156+xaeon2026@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const ERROR_PAYLOAD_PREFIX_RE =
|
||||
/^(?:error|(?:[a-z][\w-]*\s+)?api\s*error|apierror|openai\s*error|anthropic\s*error|gateway\s*error)(?:\s+\d{3})?[:\s-]+/i;
|
||||
/^(?:error|(?:[a-z][\w-]*\s+)?api\s*error|apierror|openai\s*error|anthropic\s*error|gateway\s*error|codex\s*error)(?:\s+\d{3})?[:\s-]+/i;
|
||||
const HTTP_STATUS_PREFIX_RE = /^(?:http\s*)?(\d{3})\s+(.+)$/i;
|
||||
const HTTP_STATUS_CODE_PREFIX_RE = /^(?:http\s*)?(\d{3})(?:\s+([\s\S]+))?$/i;
|
||||
const HTML_ERROR_PREFIX_RE = /^\s*(?:<!doctype\s+html\b|<html\b)/i;
|
||||
@@ -180,8 +180,7 @@ export function formatRawAssistantErrorForUi(raw?: string): string {
|
||||
if (info?.message) {
|
||||
const prefix = info.httpCode ? `HTTP ${info.httpCode}` : "LLM error";
|
||||
const type = info.type ? ` ${info.type}` : "";
|
||||
const requestId = info.requestId ? ` (request_id: ${info.requestId})` : "";
|
||||
return `${prefix}${type}: ${info.message}${requestId}`;
|
||||
return `${prefix}${type}: ${info.message}`;
|
||||
}
|
||||
|
||||
return trimmed.length > 600 ? `${trimmed.slice(0, 600)}…` : trimmed;
|
||||
|
||||
Reference in New Issue
Block a user