Patch Changes
-
11323f9: Prevent excessive memory and CPU usage when validating malformed UI messages.
validateUIMessages,safeValidateUIMessages, and the agent UI stream helpers reported the issues of every part schema for every invalid part, so a small request with many malformed parts could exhaust memory. Each part is now validated against the schemas for its type only, validation stops at the first invalid message or part, and an invalid JSON value in provider or tool metadata is reported as a single issue. -
2ebc78b: Forward the provider's configured fetch transport when downloading file inputs. Add a
fetchoption tocreateDownloadso core downloads can also useguarded-fetchfor opt-in DNS validation on Node.js. The function returned bycreateDownloadcan now also be passed asexperimental_downloadtogenerateTextandstreamText, andexperimental_downloadnow also handles generated file URLs returned by the model, so one hook covers all core downloads. Document that the default URL checks do not resolve DNS and recommend the guarded transport or network egress controls for untrusted URLs.Keep Azure image and Vertex tool-result downloads separate from provider authentication wrappers so file hosts never receive Azure bearer tokens or Vertex Express Mode API keys.
Pass the call's abort signal to custom download requests, including prompt assets and generated files, so
experimental_download: createDownload({ fetch })preserves cancellation and timeouts. -
cb4fa52: add experimental extract api and extraction model spec
-
ceeee29: Warn when a UI message stream sends a tool error text that differs from the text the model received and then sends reasoning from a later step. By default,
toUIMessageStreamsends "An error occurred." to the client for a failed tool call, while the model receives the full error text during a multi-step call. Converting the stored UI messages back withconvertToModelMessagesthen changes the tool result, and models that bind reasoning to the preceding messages (for example Anthropic models with preserved thinking) reject the request. The request still fails after this change; the warning and the updated documentation explain the cause and the available options. -
1a94af3: Send the error text of failed tool calls to the client as the model received it.
toUIMessageStreamandtoUIMessageChunkreplaced the error text of failed tool calls with "An error occurred." by default. The model had already received the full text during a multi-step call, so UI messages that were converted back withconvertToModelMessagescontained a different tool result. Models that bind reasoning to the preceding messages rejected that history (for example Anthropic models with preserved thinking, with HTTP 400 "The block is bound to a different conversation"), and other models continued from an error they never received.UI messages now keep the model's error text for tool execution errors and invalid tool calls. This text reaches the client. To keep details away from the model and the client, throw an error with a safe message from the tool's
executefunction. The error text of an invalid tool call contains the generated input, the validation messages of the input schema, or the names of the available tools;executedoes not run for it. To restore the previous behavior, set the newredactToolErrors: trueoption. A providedonErrorkeeps handling failed tool calls unless you setredactToolErrors: false. Stream errors are still masked by default. -
Updated dependencies [640569d]
-
Updated dependencies [4e43721]
-
Updated dependencies [2ebc78b]
-
Updated dependencies [cb4fa52]
- @ai-sdk/gateway@4.0.144
- @ai-sdk/provider-utils@5.0.80
- @ai-sdk/provider@4.0.38