ai
7.0.176 · 17 Nov 2026Apache-2.048.6M / weekRepositoryHomepagenpmAtom feed
7.0.179 is the newest release of 7.x.
In short
29 breaking7 removed5 security5 deprecated78 new78 fixed12 internal
- Breaking
ai: Change type of experimental_context from unknown to generic
- Breaking
ai: Remove deprecated
mediatype part fromToolResultOutput - Breaking
ai: Make experimental_telemetry stable
- Breaking
ai: Change naming nomenclature for
*TelemetryIntegrationto*Telemetry - Breaking
ai: Carry prepareStep message overrides forward across steps
- Breaking
ai: Limit response messages in StepResult to messages created in that step
- Breaking
ai: remove/refactor event data sent via callbacks
- Breaking
provider: Adding new 'custom' content type
Release note
Major Changes
- Breaking
ai: Change type of experimental_context from unknown to generic
- Breaking
ai: Remove deprecated
mediatype part fromToolResultOutput - Breaking
ai: Make experimental_telemetry stable
- Breaking
ai: Change naming nomenclature for
*TelemetryIntegrationto*Telemetry - Breaking
ai: Carry prepareStep message overrides forward across steps
- Breaking
ai: Limit response messages in StepResult to messages created in that step
- Breaking
ai: remove/refactor event data sent via callbacks
- Breaking
provider: Adding new 'custom' content type
- Breaking
ai: Add support for uploading provider skills using the provider references abstraction
- Breaking
ai: Remove experimental_customProvider
- Breaking
ai: Rename
stepCountIstoisStepCount - Breaking
ai/core: Rename
ModelCallStreamParttoLanguageModelStreamPartand align stream model call naming (streamLanguageModelCall,experimental_streamLanguageModelCall).This updates experimental low-level stream primitives to use "language model call" terminology consistently.
- Breaking
Remove CommonJS exports from all packages. All packages are now ESM-only (
"type": "module"). Consumers usingrequire()must switch to ESMimportsyntax. - Breaking
Remove the deprecated
ToolCallOptionsexport.Use
ToolExecutionOptionsinstead. - Breaking
ai: Remove telemetry data from the user-facing event data
- Breaking
provider: Add support for provider references and uploading files as supported per provider
- Breaking
provider: Add new top-level reasoning parameter to spec and support it in
generateTextandstreamText - Breaking
provider: Change file part data property to be tagged with a type and remove the image part type
- Breaking
refactoring(ai): extract tool callback invocation into separate function and forward chunks before callback invocation
- Breaking
Rename experimental_context to context
- Breaking
Start v7 pre-release
- Breaking
provider: Align tool result output content file part types with top-level message file part types
- Breaking
ai: Remove deprecated isToolOrDynamicToolUIPart function
- Breaking
ai: Simplify unified telemetry creation
- Breaking
ai: Create new opentelemetry package (@ai-sdk/otel)
- Breaking
refactoring(ai): delay tool execution in stream text until model call is finished
- Breaking
ai: Decouple otel from core functions
- Breaking
ai: Reject system messages in messages or prompt by default (opt-in)
Patch Changes
Add
allowSystemInMessagesoption toToolLoopAgent.This exposes the same option that exists on
streamTextandgenerateText, whetherrole: "system"messages are allowed in thepromptormessagesfields. When unset, system messages are rejected because they can create a prompt injection attack risk. Ideally, use theinstructionsoption instead. Set totrueto allow system messages, orfalseto explicitly reject them.const agent = new ToolLoopAgent({ model, allowSystemInMessages: true, }); await agent.generate({ messages: [ { role: "system", content: "Server context" }, { role: "user", content: "Hello" }, ], });The option can also be returned from
prepareCallfor dynamic per-call configuration.ai: Decouple otel from generate/streamObject
ai: Change Tool.sensitiveContext to telemetry.includeToolsContext and make it opt-in
Add AI Gateway hint to provider READMEs
- Deprecated
Deprecate
streamTextresultfullStreamin favor ofstream. gateway: Enable retry support for gateway errors
ai: Rename onStepFinish to onStepEnd
Fix URL of hero animation in README
ai: doStream should reflect transformed values
ai: Rename onObjectStepFinish to onObjectStepEnd
- Deprecated
ai: Deprecate properties on result that have moved to finalStep
refactoring: Rename context to runtimeContext
ai: Introduce experimental callbacks for embed function
Rename onFinish to onEnd
ai: enable:true for telemetry by default
ai: Extract streamModelCall function for streaming text generation
- Deprecated
Make
generateTextandstreamTextresultusagereport total usage across all steps and deprecatetotalUsage. refactoring: Rename toolNeedsApproval to toolApproval
- Deprecated
ai: Add
instructionsas the primary prompt option and deprecatesystem ai: Emit streaming chunks throught the onChunk callback
ai: Validate tool context against contextSchema at runtime
Tool execution and approval callbacks now validate each tool's
toolsContextentry against itscontextSchema. Invalid tool context now throwsTypeValidationErrorwith tool-context validation metadata inerror.context.refactoring(ai): extract filterActiveTools and expose it as experimental_filterActiveTools
Instructions as prepareStep input
ai: Skip stringifying text when streaming partial text
ai: Break
CallSettingsapart intoLanguageModelCallOptionsandRequestOptionsai: Enforce
callOptionsSchemaat runtime inToolLoopAgentToolLoopAgentSettings.callOptionsSchemawas declared and documented as a runtime schema foroptions, buttool-loop-agent.tsnever invoked it. Any invariant a developer encoded in the schema was silently bypassed at runtime, and uncheckedoptionsflowed straight intoprepareCalland anyinstructionstemplate that interpolated them.ToolLoopAgent.prepareCallnow validates caller-suppliedoptionsagainstcallOptionsSchema(when set) viasafeValidateTypes, throwingInvalidArgumentErroron failure before forwarding toprepareCall/generateText/streamText.ui: Export
isDynamicToolUIPartfromaipackage- Deprecated
stream-text: Expose standalone stream transformation helpers and deprecate the equivalent
streamTextresult methods.The new
toUIMessageChunkandtoUIMessageStreamhelpers let you convert astreamTextstream(or any compatibleReadableStream<TextStreamPart<TOOLS>>) into UI message chunks without going through the result object — useful for custom transports, tests, and other producers ofTextStreamPart.result.toUIMessageStreamResponse(options)andresult.pipeUIMessageStreamToResponse(response, options)can migrate by passingtoUIMessageStream({ stream: result.stream, ...options })tocreateUIMessageStreamResponseorpipeUIMessageStreamToResponse.The new
toTextStreamhelper extracts text deltas from astreamTextstream, soresult.toTextStreamResponse(options)andresult.pipeTextStreamToResponse(response, options)can migrate tocreateTextStreamResponse({ stream: toTextStream({ stream: result.stream }), ...options })andpipeTextStreamToResponse({ response, stream: toTextStream({ stream: result.stream }), ...options }).result.toUIMessageStream,result.toUIMessageStreamResponse,result.pipeUIMessageStreamToResponse,result.toTextStreamResponse, andresult.pipeTextStreamToResponseare now@deprecated. They still work in v7 and will be removed in the next major release. Migration snippets are in the v6 → v7 migration guide. - Removed
Remove the deprecated
experimental_prepareStepoption fromgenerateText.Use
prepareStepinstead. ai: Unify generate text event callbacks
Add timeBetweenOutputTokensMs stats
ai: Exclude request and response bodies from text generation results by default to reduce memory usage.
Skip validation for tool parts in terminal states when tool schema is no longer registered
ai: Return schema-transformed elements in array output mode
Previously final array output validation checked each element against the schema but returned the raw model output. Array output now returns the validated values so Zod transforms, coercions, defaults, and pipes are applied consistently with object output.
- Security
security: Validate redirect targets in download functions to prevent SSRF bypass
Both
downloadBlobanddownloadnow validate the final URL after following HTTP redirects, preventing attackers from bypassing SSRF protections via open redirects to internal/private addresses. ai: Enforce
timeout.stepMsfor the whole step instreamTextPreviously
streamText's step timer was cleared synchronously right after the step's stream was registered, before the stream produced anything, sostepMsnever aborted a step that stalled before emitting content. The step timer now survives until the step's stream finishes or aborts, matchinggenerateText.chunkMs/totalMsand normal step-finish cleanup are unchanged.ai: Allow multiple integrations to be registered at once
ai: Preserve
allowSystemInMessagesacrossstreamTextretriesAdd sensitiveContext property to Tool
ai: Add approval guard for denied tool outputs
- Removed
ai: Remove ExtractLiteralUnion export
ai: Harden
getMediaTypeFromUrlagainst prototype-property collisionsgetMediaTypeFromUrl(used to infer media types forfile-url/image-urlparts) usedext in URL_EXTENSION_TO_MEDIA_TYPEagainst a plain object literal. A URL ending in.constructortherefore resolved through the prototype chain and returned theObjectconstructor function, violating the helper's: stringreturn type and forwarding a non-string value to provider adapters.Switch to
Object.hasOwn(...)so attacker-controlled extensions like.constructorcannot resolve to inheritedObject.prototypekeys.ai: Skip global telemetry registration when local integration defined
ai: Support several tools in hasToolCall stop condition
ui: Make
inputoptional onoutput-errortool and dynamic-tool UI message partsvalidateUIMessagesrejected persisted assistant messages whoseoutput-errortool parts had noinputkey. This happened for any errored tool call where the SDK setinput: undefined(e.g.NoSuchToolError/InvalidToolInputError): JSON serialization stripped theundefinedvalue, and Zod 4.4+ treats a missingz.unknown()key as a validation failure (previously it was implicitly optional). The schema now matches the runtime shape produced byprocess-ui-message-stream, so reloading a thread that contains an errored tool call no longer throwsAI_TypeValidationError.Expose
finalStepon text generation results- Removed
ai: Remove otel Tracer api from telemetry settings
ai: Flatten model attributes for telemetry
refactoring: Rename tool execution events
Return validated elements from generateText array output
ai: Move opentelemetry to new package
harness: Implement harness specification
ai: Include tool input on tool result for provider executed dynamic tools
ai: Remove onChunk event from telemetry
ai: Add sensitiveRuntimeContext option
ai: Pass all stream text parts to
onChunkai: Force template check on 'kind' param
Flexible tool descriptions
- Removed
ai: Remove deprecated LanguageModelUsage properties
agents: Tag outgoing requests with an ai-sdk-agent user-agent segment for usage attribution (tool-loop, workflow)
ai: Make the experimental lifecycle callbacks stable
Better context type inference
Make sandbox experimental
ai: Introduce experimental callbacks for rerank function
Trigger release for all packages after provenance setup
ai: Fix
lastAssistantMessageIsCompleteWithApprovalResponsesto no longer ignoreproviderExecutedtool approvalsai: Rename the core-event types
types: Move shared tool set utility types into provider-utils
Moved
ToolSet,InferToolSetContext, andUnionToIntersectioninto@ai-sdk/provider-utilsand updatedaiinternals to import them directly from there. This keeps the shared tool typing utilities colocated with the core tool type definitions.ai: Pass result provider metadata across the stream
ai: Expose Experimental_ModelCallStreamPart type
Add performance statistics
ai: Skip passing invalid JSON inputs to response messages
ai: Add experimental_refineToolInput option to ToolLoopAgent, generateText, streamText
ai: Download tool-result file URLs
More precise default message for tool execution denial
Post-publish release notifications now link to each package’s GitHub release and npm page.
anthropic: Preserve the error code returned by model
ai: Add new
isLoopFinishedstop condition helper for unlimited stepsai: Add toolMs to timeout configuration
ai: Concurrent event notification
Retain stack traces on async errors
refactoring: executeTool uses tool as parameter
ai: Handle partial unicode escapes in fixJson
Consider file outputs and tool calls for time to first output
Move includeRawChunks to include.rawChunks
Add deprecated tool call lifecycle callback aliases for AI SDK 6 compatibility.
ai: Access runtime context in tool approval functions
ai: Add a ModelCall start/end event
refactoring: Introduce Arrayable type
ai: Add approval reason to automatic tool approvals
ai: Allow tool approval functions to return undefined
ai: Remove telemetry dependency on onChunk callback
openai-compatible: Emit warning when using kebab-case instead of camelCase
- Breaking
Raise minimum supported Node.js version to 22. Supported versions: 22, 24, and 26.
ai: Wrap the model call in telemetry context
ai: Reject
streamTextresult promises withNoOutputGeneratedErrorwhen the model stream ends without producing any output. Previously such streams resolved with an empty step. Incomplete streams with partial output still resolve with the partial result.- Removed
Remove deprecated experimental generateImage exports.
- Removed
Remove the deprecated
experimental_outputalias and document theoutputmigration for AI SDK 7 Remove custom User-Agent header from HttpChatTransport to fix CORS preflight failures in Safari and Firefox
Rename rerank telemetry finish callback to
onRerankEnd.Feat (ai/core): support plain string model IDs in
rerank()functionThe
rerank()function now accepts plain model strings (e.g.,'cohere/rerank-v3.5') in addition toRerankingModelobjects, matching the behavior ofgenerateText,embed, and other core functions.mcp: Propagate the server name through dynamic tool parts
Introduce responseMessages on GenerateTextResult and StreamTextResult
Trigger initial canary release
ai: Decouple otel from embed functions
provider: Preserve error type prefix in getErrorMessage
Rename telemetry onFinish to onEnd
ai: Add missing usage attributes
ai: Add experimental callbacks for structured outputs
ai: Add per-tool timeout overrides via toolTimeouts
ai: Make input optional on input-streaming UIMessagePart variants
ai: Add toolNeedsApproval option
provider: Add experimental Realtime API support for voice conversations
Adds first-class support for realtime (speech-to-speech) APIs:
Experimental_RealtimeModelV4spec in@ai-sdk/providerwith normalized event types and factoryOpenAI, Google, and xAI realtime provider implementations
openai.experimental_realtime()/google.experimental_realtime()/xai.experimental_realtime()work in both server and browser.getToken()static method on each provider for server-side ephemeral token creationexperimental_getRealtimeToolDefinitionshelper for provider session tool definitionsexperimental_useRealtimehook in@ai-sdk/reactreturningUIMessage(aligned withuseChat), withonToolCallandaddToolOutputfor client-driven tool executioninputAudioTranscriptionsession config for showing transcribed user audio messages when supported by the provider
ai: Default missing embedding warnings to an empty array
ai: Refresh
customProviderandcreateProviderRegistryto support file and skill upload abstractionsai: Limit tool execution time duration to actual tool execution
ai: Allow passing provider instance to
uploadFileanduploadSkillas shorthandai: Include generated files in OTEL response attributes
ai: Do not re-validate tool input for output-error parts in validateUIMessages
ai: Change sensitiveRuntimeContext to telemetry.includeRuntimeContext and make it opt-in
ai: Add toolMetadata for tool specific metdata
Add request.messages to StepResult
provider-utils: Add
spawnCommandmethod toExperimental_Sandboxto allow for detached command executionFix test mocks to return the first array-backed result on the first call
ai: Remove stopWhen from onStart event
Rename onEmbedFinish to onEmbedEnd
Split
prepareToolsAndToolChoice()intoprepareTools()andprepareToolChoice()ai: Remove unnecessary data from events
- Security
Harden download URL SSRF guard against hostname and redirect bypasses
validateDownloadUrland the file download helpers (downloadBlob,download) could be bypassed in several ways when handling untrusted URLs:A fully-qualified hostname with a trailing dot (e.g.
localhost.,myhost.local.) skipped the localhost/.localblocklist.IPv6 addresses that embed an IPv4 address in their last 32 bits — IPv4-compatible (
::127.0.0.1), IPv4-translated (::ffff:0:127.0.0.1), and NAT64 (64:ff9b::127.0.0.1, including the64:ff9b:1::/48local-use prefix) — were not decoded and checked against the private IPv4 ranges.Redirects were validated only after
fetchhad already followed them, so the request to a redirect target (e.g. an internal/metadata address) had already been issued before the check ran.Several reserved/internal address ranges were not blocked: CGNAT (
100.64.0.0/10, used by some cloud providers for internal traffic), benchmarking (198.18.0.0/15), IETF protocol assignments (192.0.0.0/24), the reserved240.0.0.0/4block (including the255.255.255.255broadcast address), and IPv6 site-local (fec0::/10) and multicast (ff00::/8).
The validator now strips trailing dots before the hostname checks and fully expands IPv6 addresses to detect embedded private IPv4 targets. The download helpers now follow redirects manually (
redirect: 'manual'), re-validating each hop before requesting it, so an unsafe redirect target is never fetched. When a redirect cannot be inspected because the runtime returns an opaque response, the helpers fail closed (reject the redirect) on the server; only in a real browser — where SSRF is not reachable (fetch is constrained by CORS and cannot reach a server's internal network or cloud-metadata endpoints) — is the redirect followed natively so legitimate redirected downloads keep working. Promote
generateSpeechandSpeechResultto stable exports.Promote
transcribeandTranscriptionResultto stable exports, with deprecated experimental aliases for backwards compatibility.Update step performance metrics with explicit effective, input, output, and total token throughput fields.
- Security
Harden stream text processing and middleware against prototype pollution from stream part IDs.
ai: Use tracing channels to track parent-child context
Sandbox shell execution abstraction
Trigger initial beta release
Make include stable
ai: Omit reasoning-start/end when sendReasoning is false
ai: Support automatic tool approval in ui messages
provider-utils: Add
readFileandwriteFileplus convenience wrappers toExperimental_Sandboxabstractionai: Expose initial and response messages in prepareStep
ai: Generic tool approval function
Support tools with optional context
ai: Accumulative properties on StreamTextResult, GenerateTextResult
ai: Introduce onAbort hook to close telemetry spans
ai: Separate toolsContext from context
ai: Tag step/chunk timeout aborts with
TimeoutErrorreasonWhen
timeout: { stepMs }ortimeout: { chunkMs }fires, the abort reason is now aTimeoutErrorDOMException, matching whatAbortSignal.timeout()produces natively. Consumers can distinguish a framework timeout from a user-initiated cancel viasignal.reason.name === 'TimeoutError'.Serialize
undefinedtool output tonullin UI message chunksai: Create a diagnostics channel to push event data
security: re-validate tool approvals from client message history before execution
The approval-replay path in
generateText/streamText(andWorkflowAgent.stream) reconstructed approved tool calls from the client-supplied messages array and executed them without re-validating input against the tool's schema or re-applying the approval policy. A client could forge an assistant message with a pre-approved tool-call part and have the server execute a tool with attacker-chosen arguments.The replay path now validates HMAC signature (when
experimental_toolApprovalSecretis configured), re-validates tool-call input against the tool's input schema, and re-resolves the approval policy before execution.Add a
toolOrderoption to control the order in which tools are sent to provider APIs.- Removed
refactoring(ai): remove deprecated experimental_activeTools option
ai: Decouple otel from rerank function
README updates
Redact server error details from UI message streams by default
toUIMessageStream,createUIMessageStream, andtoUIMessageChunkdefaulted theironErrorcallback togetErrorMessage, which serializes the raw error (error.toString()/JSON.stringify(error)) into the client-facing{ type: 'error', errorText }chunk — and also intotool-output-errorparts. The documented default was() => 'An error occurred.', so applications relying on the documented behavior were unknowingly streaming server exception details (internal hostnames, paths, provider request data, validation inputs) to end users.The default
onErrornow returns the documented generic'An error occurred.'. Raw error details are only emitted when the developer explicitly supplies anonErrorhandler. This also redactstool-output-errorand invalid-tool-input error text by default; pass anonErrorto surface richer messages.- Security
Harden UI message stream processing against prototype pollution from chunk IDs.
Feat (video): add first-class
generateAudiocall optionIntroduce Instructions type
provider-utils: Cancel response body on download rejection to prevent socket leak
When a download was rejected early — because the
Content-Lengthheader exceeded the size limit, the response status was not ok, or a redirect resolved to a blocked URL — the fetch response body was left unconsumed and uncancelled. With WHATWG Fetch/undici this leaves the underlying TCP socket open instead of returning it to the connection pool, allowing an attacker-controlled origin to exhaust file descriptors and cause a denial of service. The body is now cancelled on all early-rejection paths inreadResponseWithSizeLimit,download, anddownloadBlob, andfetchWithValidatedRedirectscancels each redirect hop's body before following or rejecting the next hop.ai: Fix auto-complete on provider registry and custom provider
Rename Sandbox.executeCommand to Sandbox.runCommand
refactoring(ai): simplify mergeAbortSignals
ai: Allow prepareStep to override sandbox per step
- Security
mcp: Prevent prototype pollution by using secureJsonParse
Introduce include.requestMessage option for step request message storage opt-in
ai: Move onToolExecutionStart and onToolExecutionEnd to stable
Use instructions on ToolCallRepairFunction, parseToolCall, and events
ai: Automatic tool approval
ai: Fix
providerExecutedtool approvals being passed to language model twiceHonor
tool.toModelOutputinWorkflowAgent.WorkflowAgentnow routes successful local, provider-executed, and approved tool results through each tool's optionaltoModelOutputhook, matchinggenerateText,streamText, andToolLoopAgent. Previously the hook was ignored and results were always serialized astextorjson.Internally exports the shared tool-result model-output helpers from
ai/internal, and uses the sharedgetErrorMessagebehavior for workflow tool error results.workflow: Reuse the core tool-approval validation in WorkflowAgent
WorkflowAgent.streampreviously reconstructed approved tool calls with a copy of the core collection logic and validated them inline. Because the logic was duplicated, it could drift from the hardenedgenerateText/streamTextimplementation. WorkflowAgent now collects approvals via the sharedcollectToolApprovalsand re-validates each one through the sharedvalidateApprovedToolApprovals(input-schema re-validation, HMAC signature verification when configured, and approval-policy re-resolution) in addition to its existingneedsApprovalguard, so a client-forged approval cannot execute a tool with unvalidated input. The duplicated collector was removed;collectToolApprovalsandvalidateApprovedToolApprovalsare now exported fromai/internal.Roll
image-*tool output types into their equivalentfile-*typesai: Rename ui message stream onFinish to onEnd
devtools: Add new devtools integration for telemetry
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.