UNPKG

@mastra/core

Version:
1 lines • 36.4 kB
{"version":3,"file":"error-CBEbujW6.cjs","names":["readField"],"sources":["../src/loop/shared/provider-error-details.ts","../src/error/provider-error.ts","../src/loop/shared/record-terminal-error-message.ts"],"sourcesContent":["/**\n * Diagnostic fields of a provider HTTP failure (AI SDK `APICallError`).\n *\n * When a provider's error body doesn't match the shape the AI SDK expects, the\n * error `message` falls back to the HTTP status text (\"Bad Request\"), and the\n * real explanation is only in `responseBody`. These helpers pull out the fields\n * worth keeping without trusting the error object: getters may throw, fields\n * may be any type, and bodies may be huge.\n */\n\nexport const MAX_PERSISTED_RESPONSE_BODY_LENGTH = 2000;\n\nexport function capPersistedText(text: string): string {\n return text.length > MAX_PERSISTED_RESPONSE_BODY_LENGTH\n ? `${text.slice(0, MAX_PERSISTED_RESPONSE_BODY_LENGTH)}…`\n : text;\n}\n\nconst REQUEST_ID_HEADERS = ['request-id', 'x-request-id'];\n\nexport type ProviderErrorDetails = {\n statusCode?: number;\n responseBody?: string;\n requestId?: string;\n modelId?: string;\n};\n\nfunction readField(error: object, field: string): unknown {\n try {\n return (error as Record<string, unknown>)[field];\n } catch {\n return undefined;\n }\n}\n\nexport function readRequestId(headers: unknown): string | undefined {\n if (!headers || typeof headers !== 'object') return undefined;\n for (const header of REQUEST_ID_HEADERS) {\n const value = readField(headers, header);\n if (typeof value === 'string' && value.trim()) return value.trim();\n }\n return undefined;\n}\n\nexport function readRequestedModel(requestBody: unknown): string | undefined {\n if (!requestBody || typeof requestBody !== 'object') return undefined;\n const model = readField(requestBody, 'model');\n return typeof model === 'string' && model.trim() ? model.trim() : undefined;\n}\n\nexport function readProviderErrorDetails(error: unknown): ProviderErrorDetails {\n if (error === null || (typeof error !== 'object' && typeof error !== 'function')) return {};\n\n const details: ProviderErrorDetails = {};\n\n const statusCode = readField(error, 'statusCode');\n if (typeof statusCode === 'number' && Number.isInteger(statusCode)) details.statusCode = statusCode;\n\n const responseBody = readField(error, 'responseBody');\n if (typeof responseBody === 'string' && responseBody.trim()) {\n details.responseBody = capPersistedText(responseBody);\n }\n\n const requestId = readRequestId(readField(error, 'responseHeaders'));\n if (requestId) details.requestId = requestId;\n\n const modelId = readRequestedModel(readField(error, 'requestBodyValues'));\n if (modelId) details.modelId = modelId;\n\n return details;\n}\n\n/**\n * The provider's own explanation from a response body: `error.message` (Anthropic,\n * OpenAI), a top-level `message` or string `detail` (FastAPI backends such as the\n * ChatGPT Codex endpoint), or the raw text when the body isn't JSON.\n */\nfunction providerExplanation(responseBody: string): string {\n try {\n const parsed = JSON.parse(responseBody) as {\n error?: { message?: unknown } | string;\n message?: unknown;\n detail?: unknown;\n };\n if (parsed && typeof parsed === 'object') {\n const nested = typeof parsed.error === 'object' ? parsed.error?.message : parsed.error;\n if (typeof nested === 'string' && nested.trim()) return nested.trim();\n if (typeof parsed.message === 'string' && parsed.message.trim()) return parsed.message.trim();\n if (typeof parsed.detail === 'string' && parsed.detail.trim()) return parsed.detail.trim();\n }\n } catch {\n // Not JSON; show the raw text.\n }\n return responseBody.trim();\n}\n\n/**\n * Human-readable one-liner for a provider HTTP failure, at most `maxLength`\n * characters, or undefined when the error carries no HTTP details. Example:\n * `Bad Request (HTTP 400): prompt is too long (request id req_123)`.\n *\n * The explanation is parsed from the full body (a truncated JSON body would not\n * parse), and the request id is always kept when the text has to be shortened.\n */\nexport function describeProviderError(message: string, error: unknown, maxLength: number): string | undefined {\n const details = readProviderErrorDetails(error);\n if (details.statusCode === undefined && details.responseBody === undefined) return undefined;\n\n let text = message;\n if (details.statusCode !== undefined) text += ` (HTTP ${details.statusCode})`;\n\n if (details.responseBody !== undefined) {\n const explanation = providerExplanation(readField(error as object, 'responseBody') as string);\n if (explanation && explanation !== message) text += `: ${explanation}`;\n } else if (details.statusCode !== undefined) {\n text += ': empty response body';\n }\n\n const suffix = details.requestId ? ` (request id ${details.requestId})` : '';\n const room = Math.max(0, maxLength - suffix.length);\n if (text.length > room) text = `${text.slice(0, Math.max(0, room - 1))}…`;\n return text + suffix;\n}\n","import { capPersistedText, readRequestedModel, readRequestId } from '../loop/shared/provider-error-details';\n\nexport type ProviderFailureKind =\n | 'auth'\n | 'quota'\n | 'rate_limited'\n | 'context_overflow'\n | 'model_rejected'\n | 'tool_history_rejected'\n | 'timeout'\n | 'unavailable'\n | 'invalid_request'\n | 'unknown';\n\nexport interface ProviderErrorFacts {\n statusCode?: number;\n codes?: string[];\n /** The innermost sentence behind HTTP phrases, envelopes, stringified layers and a wrapped provider response, when it differs from the message. */\n reason?: string;\n}\n\nconst MAX_OBJECT_DEPTH = 4;\nconst ENVELOPE_TYPES = new Set(['error', 'response.failed']);\nconst SYMBOLIC_STATUS = /^[A-Z][A-Z0-9_]+$/;\n\nconst BILLING_EXHAUSTED =\n /insufficient[_ ]quota|insufficient (?:balance|credits?)|credits? exhausted|credit balance|payment required/i;\nconst USAGE_CAPPED =\n /usage (?:limit|cap)|quota (?:exceeded|exhausted|reached)|exceeded (?:your )?current quota|weekly limit|monthly limit/i;\n// A cap that refills within the hour is a rate limit, whatever the provider calls it.\nconst RENEWS_WITHIN_THE_HOUR = /per[_ -]?(?:second|minute|hour|min|sec)\\b|\\b[rt]pm\\b/i;\nconst ACCESS_DENIED_WORDING =\n /invalid[_ ]api[_ ]key|incorrect api key|api key not valid|authentication[_ ]error|permission_?(?:denied|error)|access[_ ]?denied/i;\n// Bare \"unauthorized\" or \"forbidden\" in free text can come from any service a run touches, not only the model provider.\nconst ACCESS_DENIED_CODE = new RegExp(`${ACCESS_DENIED_WORDING.source}|unauthorized|authentication|forbidden`, 'i');\nconst CONTEXT_OVERFLOW = [\n /context[_ ]length[_ ]exceeded/i,\n /maximum context length/i,\n /maximum prompt length/i,\n /prompt is too long/i,\n /input is too long/i,\n /exceed(?:s|ed|ing)?\\b[^.]{0,40}\\bcontext (?:window|length|limit|size)/i,\n /input token count[^.]{0,40}exceeds the maximum/i,\n /reduce the length of the (?:messages|prompt|input)/i,\n];\nconst MODEL_REJECTED =\n /model_not_found|model not found|no[_ ]?such[_ ]?model|not_found_error|invalid[_ ]model|unsupported[_ ]model|\\bmodel\\b[^.]{0,40}\\bis not supported\\b|unsupported[_ ]parameter|unsupported[_ ]value/i;\nconst TOOL_HISTORY_REJECTED =\n /no tool output found for (?:function|tool) call|tool_call_ids[^.]{0,40}(?:response|respond)|tool_use[^.]{0,40}tool_result/i;\nconst INVALID_REQUEST_CODE = /invalid_request_error|invalid_prompt/i;\n// The envelope type every OpenAI and Anthropic 400 carries; a code beside it is the provider naming the rejection.\nconst INVALID_REQUEST_ENVELOPE = /^invalid_request_error$/i;\nconst TIMED_OUT = /timed ?out|timeout|deadline[_ ]exceeded/i;\nconst RATE_LIMITED = /rate[_ ]limit|too many requests|resource_exhausted|throttl/i;\nconst UNAVAILABLE =\n /internal server error|server_error|internal_error|service[_ ]?unavailable|temporarily[_ ]?unavailable|bad gateway|overloaded/i;\nconst HTTP_REASON_PHRASE =\n /^(?:bad request|unauthorized|payment required|forbidden|not found|method not allowed|not acceptable|proxy authentication required|request timeout|conflict|gone|length required|precondition failed|(?:payload|content|request entity) too large|(?:request-)?uri too long|unsupported media type|(?:requested )?range not satisfiable|expectation failed|i'm a teapot|misdirected request|unprocessable (?:entity|content)|locked|failed dependency|too early|upgrade required|precondition required|too many requests|request header fields too large|unavailable for legal reasons|internal server error|not implemented|bad gateway|service unavailable|gateway timeout|http version not supported|variant also negotiates|insufficient storage|loop detected|not extended|network authentication required)\\.?$/i;\n\n// A provider call saved before its status was kept says only the HTTP phrase; elsewhere a bare phrase names nobody.\nexport const PROVIDER_CALL_ERROR_NAME = /^(?:AI_)?APICallError$/;\nconst ACCESS_DENIED_PHRASE = /^(?:unauthorized|forbidden)\\.?$/i;\nconst MARKUP_OR_JSON = /^\\s*[[{<]/;\n\ninterface CollectedFacts {\n statusCode?: number;\n codes: string[];\n texts: string[];\n seen: WeakSet<object>;\n}\n\nfunction readField(record: object, key: string): unknown {\n try {\n return (record as Record<string, unknown>)[key];\n } catch {\n return undefined;\n }\n}\n\nfunction parseJsonObject(text: string): unknown {\n const trimmed = text.trim();\n if (!trimmed.startsWith('{')) return undefined;\n try {\n return JSON.parse(trimmed);\n } catch {\n return undefined;\n }\n}\n\nfunction collect(value: unknown, facts: CollectedFacts, depth: number): void {\n if (depth > MAX_OBJECT_DEPTH || value === null || value === undefined) return;\n if (typeof value === 'string') {\n facts.texts.push(value);\n collect(parseJsonObject(value), facts, depth);\n return;\n }\n if (typeof value !== 'object' || facts.seen.has(value)) return;\n facts.seen.add(value);\n\n const statusCode = readField(value, 'statusCode');\n if (typeof statusCode === 'number' && Number.isInteger(statusCode)) facts.statusCode ??= statusCode;\n // Providers report `statusCode`, or Google's numeric `error.code`; a numeric `status` is GitHub's, a fetch response's or a storage client's.\n const code = readField(value, 'code');\n if (typeof code === 'number' && Number.isInteger(code) && code >= 400 && code < 600) facts.statusCode ??= code;\n // Google's symbolic `error.status` names the failure; a lifecycle `status: 'failed'` names nothing.\n const status = readField(value, 'status');\n if (typeof status === 'string' && SYMBOLIC_STATUS.test(status.trim())) facts.codes.push(status.trim());\n const saved = readField(value, 'codes');\n const savedCodes = Array.isArray(saved) ? saved : [];\n for (const candidate of [code, readField(value, 'type'), ...savedCodes]) {\n if (typeof candidate === 'string' && candidate.trim() && !ENVELOPE_TYPES.has(candidate))\n facts.codes.push(candidate);\n }\n const name = readField(value, 'name');\n if (typeof name === 'string') facts.texts.push(name);\n for (const key of ['message', 'reason', 'detail', 'responseBody']) collect(readField(value, key), facts, depth);\n for (const key of ['error', 'data', 'response', 'cause']) collect(readField(value, key), facts, depth + 1);\n}\n\nfunction collectFacts(error: unknown): CollectedFacts {\n const facts: CollectedFacts = { codes: [], texts: [], seen: new WeakSet() };\n collect(error, facts, 0);\n return facts;\n}\n\nexport function classifyProviderError(error: unknown): ProviderFailureKind {\n const facts = collectFacts(error);\n const evidence = [...facts.codes, ...facts.texts].join('\\n');\n const verdict = providerVerdict(facts.statusCode, facts.codes.join('\\n'), evidence);\n if (verdict === 'invalid_request') return narrowInvalidRequest(evidence, facts.statusCode, facts.codes);\n // A gateway can relay an upstream context overflow as a 5xx; retrying the same prompt can't succeed.\n if (verdict === 'unavailable' && isContextOverflow(evidence)) return 'context_overflow';\n if (verdict) return verdict;\n return (\n usageKind(evidence) ??\n terminalKindFromWording(evidence) ??\n transientKindFromWording(evidence) ??\n providerCallPhraseKind(error, facts.texts) ??\n 'unknown'\n );\n}\n\nfunction providerCallPhraseKind(error: unknown, texts: string[]): ProviderFailureKind | undefined {\n if (typeof error !== 'object' || error === null) return undefined;\n const name = readField(error, 'name');\n if (typeof name !== 'string' || !PROVIDER_CALL_ERROR_NAME.test(name)) return undefined;\n const message = readField(error, 'message');\n if (typeof message === 'string' && ACCESS_DENIED_PHRASE.test(message.trim())) return 'auth';\n return texts.some(text => HTTP_REASON_PHRASE.test(text.trim())) ? 'invalid_request' : undefined;\n}\n\nfunction providerVerdict(status: number | undefined, codes: string, evidence: string): ProviderFailureKind | undefined {\n if (status === 401 || status === 403 || ACCESS_DENIED_CODE.test(codes)) return 'auth';\n if (status === 402 || BILLING_EXHAUSTED.test(codes)) return 'quota';\n // Token-per-minute limits are 429s whose message asks to shorten the request; waiting is the fix.\n if (status === 429 || RATE_LIMITED.test(codes)) return usageKind(evidence) ?? 'rate_limited';\n if (status === 408 || status === 504 || TIMED_OUT.test(codes)) return 'timeout';\n if ((status !== undefined && status >= 500) || UNAVAILABLE.test(codes)) return 'unavailable';\n if (status === 400 || status === 404 || status === 422 || INVALID_REQUEST_CODE.test(codes)) return 'invalid_request';\n return undefined;\n}\n\n// A request the provider named invalid is final; its wording may only say which final kind.\nfunction narrowInvalidRequest(evidence: string, status: number | undefined, codes: string[]): ProviderFailureKind {\n // Anthropic reports an exhausted credit balance as a 400 invalid request.\n if (BILLING_EXHAUSTED.test(evidence)) return 'quota';\n // An uncoded 400 can be a usage cap (Claude Max) or a rate limit; a coded rejection, a 404 or a 422 names something else.\n const uncodedRejection = status === 400 && codes.every(code => INVALID_REQUEST_ENVELOPE.test(code));\n if (uncodedRejection && usageKind(evidence) === 'quota') return 'quota';\n if (uncodedRejection && RATE_LIMITED.test(evidence)) return 'rate_limited';\n return terminalKindFromWording(evidence) ?? 'invalid_request';\n}\n\nfunction usageKind(evidence: string): 'quota' | 'rate_limited' | undefined {\n if (BILLING_EXHAUSTED.test(evidence)) return 'quota';\n if (USAGE_CAPPED.test(evidence)) return RENEWS_WITHIN_THE_HOUR.test(evidence) ? 'rate_limited' : 'quota';\n return undefined;\n}\n\nfunction terminalKindFromWording(evidence: string): ProviderFailureKind | undefined {\n if (ACCESS_DENIED_WORDING.test(evidence)) return 'auth';\n if (isContextOverflow(evidence)) return 'context_overflow';\n if (MODEL_REJECTED.test(evidence)) return 'model_rejected';\n if (TOOL_HISTORY_REJECTED.test(evidence)) return 'tool_history_rejected';\n if (INVALID_REQUEST_CODE.test(evidence)) return 'invalid_request';\n return undefined;\n}\n\nfunction isContextOverflow(evidence: string): boolean {\n return CONTEXT_OVERFLOW.some(pattern => pattern.test(evidence));\n}\n\nfunction transientKindFromWording(evidence: string): ProviderFailureKind | undefined {\n if (TIMED_OUT.test(evidence)) return 'timeout';\n if (RATE_LIMITED.test(evidence)) return 'rate_limited';\n if (UNAVAILABLE.test(evidence)) return 'unavailable';\n return undefined;\n}\n\n/** The JSON-safe facts worth carrying next to a failure's name and message, on the wire and in history. */\nexport function providerErrorFacts(error: unknown): ProviderErrorFacts {\n const facts = collectFacts(error);\n const result: ProviderErrorFacts = {};\n if (facts.statusCode !== undefined) result.statusCode = facts.statusCode;\n const codes = [...new Set(facts.codes)];\n if (codes.length > 0) result.codes = codes;\n const reason = reasonToPersist(error);\n if (reason !== undefined) result.reason = capPersistedText(reason);\n return result;\n}\n\nfunction reasonToPersist(error: unknown): string | undefined {\n if (typeof error !== 'object' || error === null) return undefined;\n const reason = producedByProvider(error)\n ? innermostReason(error, 0)\n : reasonBehindCause(readField(error, 'cause'), 1);\n const alreadySaved = ['message', 'responseBody'].some(field => {\n const saved = readField(error, field);\n return typeof saved === 'string' && saved.trim() === reason;\n });\n return alreadySaved ? undefined : reason;\n}\n\n/** The innermost sentence a provider wrote for a person, unwrapped from envelopes, stringified layers and a wrapped provider response. */\nexport function providerErrorReason(error: unknown): string | undefined {\n const reason = innermostReason(error, 0);\n return reason === undefined ? undefined : capPersistedText(reason);\n}\n\nexport function providerRequestId(error: unknown): string | undefined {\n return firstAlongCauses(error, requestIdOf, 0);\n}\n\nexport function providerModelId(error: unknown): string | undefined {\n return firstAlongCauses(error, modelIdOf, 0);\n}\n\nfunction firstAlongCauses(\n error: unknown,\n read: (error: object) => string | undefined,\n depth: number,\n): string | undefined {\n if (depth > MAX_OBJECT_DEPTH || typeof error !== 'object' || error === null) return undefined;\n return read(error) ?? firstAlongCauses(readField(error, 'cause'), read, depth + 1);\n}\n\nfunction requestIdOf(error: object): string | undefined {\n return nonBlank(readField(error, 'requestId')) ?? readRequestId(readField(error, 'responseHeaders'));\n}\n\nfunction modelIdOf(error: object): string | undefined {\n return nonBlank(readField(error, 'modelId')) ?? readRequestedModel(readField(error, 'requestBodyValues'));\n}\n\nfunction nonBlank(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n}\n\nfunction innermostReason(error: unknown, depth: number): string | undefined {\n if (depth > MAX_OBJECT_DEPTH || error === null || error === undefined) return undefined;\n if (typeof error === 'string') {\n const trimmed = error.trim();\n const parsed = parseJsonObject(trimmed);\n if (parsed !== undefined) return innermostReason(parsed, depth);\n return !trimmed || HTTP_REASON_PHRASE.test(trimmed) ? undefined : trimmed;\n }\n if (typeof error !== 'object') return undefined;\n for (const key of ['reason', 'detail']) {\n const own = readField(error, key);\n const ownReason = typeof own === 'string' ? innermostReason(own, depth) : undefined;\n if (ownReason) return ownReason;\n }\n for (const key of ['error', 'response', 'data']) {\n const nested = innermostReason(readField(error, key), depth + 1);\n if (nested) return nested;\n }\n const body = readField(error, 'responseBody');\n const bodyReason = typeof body === 'string' ? bodyExplanation(body, depth) : undefined;\n if (bodyReason) return bodyReason;\n const causeReason = reasonBehindCause(readField(error, 'cause'), depth + 1);\n if (causeReason) return causeReason;\n const message = readField(error, 'message');\n return typeof message === 'string' ? innermostReason(message, depth) : undefined;\n}\n\nfunction bodyExplanation(body: string, depth: number): string | undefined {\n const parsed = parseJsonObject(body);\n if (parsed !== undefined) return innermostReason(parsed, depth);\n return MARKUP_OR_JSON.test(body) ? undefined : innermostReason(body, depth);\n}\n\n// Walks wrapping causes to the first the provider produced, an HTTP response or a stream error frame; any other cause stays out of history.\nfunction reasonBehindCause(cause: unknown, depth: number): string | undefined {\n if (depth > MAX_OBJECT_DEPTH || typeof cause !== 'object' || cause === null) return undefined;\n if (producedByProvider(cause)) return innermostReason(cause, depth);\n return reasonBehindCause(readField(cause, 'cause'), depth + 1);\n}\n\nfunction producedByProvider(value: object): boolean {\n const type = readField(value, 'type');\n return (\n typeof readField(value, 'statusCode') === 'number' ||\n typeof readField(value, 'responseBody') === 'string' ||\n (typeof type === 'string' && ENVELOPE_TYPES.has(type))\n );\n}\n","/**\n * Terminal-error recording for the agentic loops.\n *\n * Error chunks are deferred until every recovery avenue (model retries, error\n * processors, fallback models) is exhausted, and `buildMessagesFromChunks`\n * turns an error chunk into no parts at all. A turn that produced no normal\n * output therefore created no assistant message, so the failed turn vanished\n * from thread history: only the orphan-guard-blocked user message remained.\n *\n * This helper runs only at the loops' established terminal-error decision\n * point and appends a first-class `error` part — analogous to the stored\n * `step-start` part — to the assistant record of the failed attempt, creating\n * a normal error-only assistant message when the attempt produced nothing.\n * Because that message is a real assistant record, the failed turn forms a\n * persistable pair with its user message through the ordinary memory path.\n *\n * Only `{ name, message }` is persisted, plus `statusCode`, a bounded\n * `responseBody`, the provider `requestId`, the `modelId` the request named,\n * every provider code and the innermost `reason` for provider failures —\n * without those, an `APICallError` whose message is just \"Bad Request\" cannot\n * be diagnosed or classified after the fact. The rest of the request body,\n * stack traces, causes, other custom fields and\n * custom `toJSON` output stay on the runtime error surfaces (stream chunk,\n * `onError`, `result.error`); thread history has to be deterministic and\n * JSON-safe.\n */\n\nimport type { MastraDBMessage, MastraErrorPart, MessageList } from '../../agent/message-list';\nimport { providerErrorFacts } from '../../error/provider-error';\nimport { readProviderErrorDetails } from './provider-error-details';\n\nconst FALLBACK_ERROR_NAME = 'Error';\nconst FALLBACK_ERROR_MESSAGE = 'Unknown error';\n\n/**\n * Read one string field off an unknown error without letting a throwing getter\n * or proxy escape. Blank and whitespace-only values count as absent so a\n * persisted record never holds an empty string.\n */\nfunction readErrorField(error: object, field: 'name' | 'message'): string | undefined {\n let value: unknown;\n try {\n value = (error as Record<string, unknown>)[field];\n } catch {\n return undefined;\n }\n if (typeof value !== 'string') return undefined;\n return value.trim().length > 0 ? value : undefined;\n}\n\n/**\n * Reduce an unknown terminal error to the JSON-safe identity that gets stored.\n * Never mutates the supplied error and never invokes `toJSON`, so a hostile or\n * circular error object cannot change what lands in history — or break it.\n */\nexport function toPersistedErrorIdentity(error: unknown): MastraErrorPart['error'] {\n if (error === null || (typeof error !== 'object' && typeof error !== 'function')) {\n return { name: FALLBACK_ERROR_NAME, message: FALLBACK_ERROR_MESSAGE };\n }\n\n return {\n name: readErrorField(error, 'name') ?? FALLBACK_ERROR_NAME,\n message: readErrorField(error, 'message') ?? FALLBACK_ERROR_MESSAGE,\n ...readProviderErrorDetails(error),\n ...providerErrorFacts(error),\n };\n}\n\nexport type RecordTerminalErrorMessageArgs = {\n messageList: MessageList;\n /**\n * Materialization id of the failed attempt — the id its partial output was\n * stored under before error processors ran.\n */\n attemptId?: string;\n /**\n * Active response id after error processors ran. An error processor may have\n * rotated it, in which case it no longer matches `attemptId`.\n */\n activeId?: string;\n error: unknown;\n};\n\n/**\n * Record a terminal failure as an `error` part on the failed attempt's\n * assistant message, creating that message when the attempt produced no\n * output. Returns the message carrying the part, or undefined when there was\n * no assistant record to attach it to and none could be created.\n */\nexport function recordTerminalErrorMessage({\n messageList,\n attemptId,\n activeId,\n error,\n}: RecordTerminalErrorMessageArgs): MastraDBMessage | undefined {\n const errorPart: MastraErrorPart = { type: 'error', error: toPersistedErrorIdentity(error) };\n const messages = messageList.get.all.db();\n\n // Prefer the failed attempt's own record so a rotated response id cannot\n // split partial output from its error. Deliberately never falls back to an\n // unrelated last assistant message.\n const target =\n (attemptId ? messages.find(message => message.id === attemptId) : undefined) ??\n (activeId ? messages.find(message => message.id === activeId) : undefined);\n\n const targetParts = target?.role === 'assistant' ? target.content?.parts : undefined;\n if (target && Array.isArray(targetParts)) {\n // A retried attempt can reach this point more than once; history keeps one\n // error part per record.\n if (targetParts.some(part => part?.type === 'error')) return target;\n\n targetParts.push(errorPart);\n // Re-add the same object rather than a copy: MessageList tracks messages by\n // identity, so this re-registers the record as unsaved (a debounced mid-run\n // flush may already have drained it) without leaving a stale duplicate\n // behind. `merge: false` keeps the part on this record instead of letting\n // the merger fold it into whatever assistant message happens to be last.\n messageList.add(target, 'response', { merge: false });\n return target;\n }\n\n // Reusing an id that already belongs to a record we cannot append to would\n // make MessageList replace-by-id and orphan the previous object in its\n // tracking sets, so only reuse an id that is actually free.\n const id = [activeId, attemptId].find(candidate => candidate && !messages.some(message => message.id === candidate));\n const message: MastraDBMessage = {\n id: id ?? globalThis.crypto.randomUUID(),\n role: 'assistant',\n createdAt: new Date(),\n content: { format: 2, parts: [errorPart] },\n };\n\n messageList.add(message, 'response', { merge: false });\n return message;\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAa,qCAAqC;AAElD,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,KAAK,SAAA,MACR,GAAG,KAAK,MAAM,GAAG,kCAAkC,EAAE,KACrD;AACN;AAEA,MAAM,qBAAqB,CAAC,cAAc,cAAc;AASxD,SAASA,YAAU,OAAe,OAAwB;CACxD,IAAI;EACF,OAAQ,MAAkC;CAC5C,QAAQ;EACN;CACF;AACF;AAEA,SAAgB,cAAc,SAAsC;CAClE,IAAI,CAAC,WAAW,OAAO,YAAY,UAAU,OAAO,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