What this thread does
The problem
Choose the fix by the failing boundary: provider call, runtime validation, structured output, or message conversion. Our recommendation: preserve the full error and nested cause in a redacted local reproduction.
Versions and status
| Baseline | Official evidence |
|---|---|
ai@7.0.145 | Vercel release and manifest |
| Apache-2.0 | Same manifest |
The reports below provide examples of error messages. Our diagnostic advice: preserve the configured model while isolating the failure.
What changed
The conditional fixes, reproduction commands and checklists below are our recommendations. API behavior and issue reports are attributed separately.
The official migration guide says convertToModelMessages() is async in AI SDK 6. The next guide says AI SDK 7 rejects system messages in prompt or messages by default and recommends top-level instructions. Check these boundaries before rewriting a prompt.
AI_APICallError
Exact example APICallError [AI_APICallError]: Resource has been exhausted (e.g. check quota). From report #4842, with HTTP 429. Our advice: inspect the provider response and cause.
Cause The report shows HTTP 429 with a resource-exhaustion message after retries. The official reference lists statusCode, isRetryable, responseBody and cause.
Fix and commands Use APICallError.isInstance(error) and inspect the status and redacted response. Our recommendation: set maxRetries: 0 for a controlled reproduction; official settings says 0 disables retries. Our example inventory command: pnpm list ai --depth 0 (no placeholders).
Do not Increase retries indefinitely, change the JSON schema for quota exhaustion, or expose raw prompts/headers. Our advice: inspect provider quota controls before changing retry settings.
AI_TypeValidationError
Exact example prefix AI_TypeValidationError: Type validation failed from report #12152. The reported client parser rejected provider metadata on a tool-input-start event.
Cause Type validation failed. The official reference provides value and cause. Identify the failing path and whether this is provider data, a UI event, or application input.
Fix and commands Use TypeValidationError.isInstance(error). Our example inventory command: pnpm list ai @ai-sdk/react @ai-sdk/google --depth 0 (no placeholders); our recommendation is to investigate version skew. Correct the boundary proven wrong, or update affected packages to a compatible release supported by its changelog. Replay the rejected event through the parser.
Do not Cast to any, disable validation, or indiscriminately strip metadata. Our recommendation: do not adopt the reported metadata-stripping workaround without investigating the rejected event.
AI_NoObjectGeneratedError
Exact example NoObjectGeneratedError [AI_NoObjectGeneratedError]: No object generated: could not parse the response. From report #11450. The report shows fenced JSON and a parsing error with search enabled.
Cause The official reference distinguishes missing, unparseable and schema-invalid output. finishReason can identify truncation.
Fix and commands Use NoObjectGeneratedError.isInstance(error) and inspect redacted cause, text and finishReason. Our recommendation: confirm generateText({ model, output: Output.object({ schema }), prompt }) uses the intended schema. Our example inventory command: pnpm list ai @ai-sdk/google --depth 0 (no placeholders). Reproduce without optional tools to isolate the interaction. If truncation is proven, adjust maxOutputTokens within the configured model's official limit; for schema failure, correct the specific field and replay it.
Do not Treat partial JSON as success, suppress the exception, or remove search while still promising researched answers.
Invalid prompt / ModelMessage[]
Exact example Invalid prompt: The messages must be a ModelMessage[] in issue #8520. The report includes AI_TypeValidationError as the nested cause.
Cause The reporter encountered this error after saving tool calls, aborting, and restarting generation. Our advice: do not infer a global null/undefined replacement rule from this error.
Fix and commands Locate message-conversion and generation calls in your application. Our example for UI history: messages: await convertToModelMessages(uiMessages) (uiMessages is a placeholder for your UI-message array). The official conversion reference documents ignoreIncompleteToolCalls: true to skip calls without results; our recommendation is to use it only when deliberately abandoning those calls. Repair malformed output at its producer and replay the failed history.
Do not Pass a conversion Promise as messages, replace every null with a string, or delete all tool history. For system-role rejection after an upgrade, our recommendation is to follow the migration guide: move system instructions to instructions when possible; it also documents allowSystemInMessages: true for trusted histories.
How to migrate
1. Capture the first failing boundary, package inventory and redacted nested cause. 2. Select the matching branch above. Apply the smallest evidence-backed fix, preserving the configured model. 3. If a major upgrade triggered it, read the linked migration guides and review conversion, provider/UI compatibility and system-message handling before deploying.
What to test
Replay the failed fixture and a valid control. Include an aborted tool call, a completed tool result, provider rejection, malformed JSON and schema-invalid JSON. Check that failures remain failures and the UI gets a useful redacted message. Our recommendation: use the project's existing test runner.
Pitfalls
Our advice: fix deterministic schema mismatches before retrying. Our recommendation: do not infer a fixed package version from an error message alone.
Prompt for your agent
Read the linked official error reference and conversion/migration pages before editing; do not guess APIs, model IDs or fixed versions. Inspect installed packages and the redacted nested cause. Identify the failing boundary, propose the smallest conditional fix, and replay the failed fixture plus a valid control. Keep validation enabled and do not replace missing output with success. Report tests you could not run.
Limits
The issue #8520 message is Invalid prompt: The messages must be a ModelMessage[].
Started from a post by @raymondhechen, packaged by the editor. Original post