Skip to content
Back to skills

Vercel Ai Sdk Knowledge Patch

ASecurity

Vercel AI SDK

  • 25 stars
  • 0 votes
  • 0 copies
  • 9 views
  • Added September 5, 2026
developmentrustgoreactvuenodeapi

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill vercel-ai-sdk-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Vercel Ai Sdk Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Vercel Ai Sdk Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-vercel-ai-sdk-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-vercel-ai-sdk-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: vercel-ai-sdk-knowledge-patch
description: Vercel AI SDK
version: "7.0.182"
license: MIT
metadata:
  author: Nevaberry
---


# Vercel AI SDK

Load this skill for SDK migrations, generation, tool loops, approvals, chat,
streaming, MCP, media, provider runtimes, and telemetry. Use the topic references
for API examples and behavior tied to a particular SDK or provider version.

| Reference | Topics |
| --- | --- |
| [Migration and compatibility](references/migrations.md) | Runtime requirements, renames, result shapes, validation, skill discovery |
| [Agents and tools](references/agents-and-tools.md) | Loop control, context, callbacks, repair, approval replay, discovery, workflows, steering |
| [Generation and media](references/generation-and-media.md) | Structured output, decisions, extraction, embeddings, batches, files, images, video, audio |
| [MCP and runtimes](references/mcp-and-runtimes.md) | Transports, typed tools, resources, prompts, elicitation, apps, sandboxes, harnesses, uploaded skills |
| [Providers and observability](references/providers-and-observability.md) | Reasoning, provider data, telemetry, durable traces, warnings |
| [UI and streams](references/ui-and-streams.md) | Chat, persistence, validation, transforms, retries, timeouts, reconnects, realtime sessions |

## Migration and deprecation essentials

v7 requires Node.js 22+ and ESM imports. Set `"type": "module"` or use `.mjs`.
Run `npx @ai-sdk/codemod v7` for mechanical changes, then review message handling,
context, and result shapes separately.

- Replace the generation option `system` with `instructions`. System messages
  embedded in `prompt` or `messages` require `allowSystemInMessages: true`.
- Use unprefixed `customProvider` and `generateImage`, and the option names
  `output`, `prepareStep`, and `telemetry`.
- Core generation uses `onEnd` instead of `onFinish`, and `result.stream`
  instead of `result.fullStream` for the complete event stream.
- Replace deprecated result response methods with top-level
  `createUIMessageStreamResponse` and `createTextStreamResponse`.
- Use `repairToolCall` for text generation and `repairText` for `generateObject`
  and `streamObject`; their experimental names remain deprecated aliases.
- Import `generateSpeech`, `transcribe`, `SpeechResult`, and
  `TranscriptionResult` without experimental prefixes.
- Use `GeneratedFile` instead of `Experimental_GeneratedImage`.
- Import `LanguageModelStreamPart` and `filterActiveTools` instead of their
  deprecated experimental exports.
- Use `experimental_decide` in place of `experimental_evaluate`.
- The Vue `useChat` composable replaces the deprecated `Chat` class.

Top-level `content`, `toolCalls`, `toolResults`, `files`, `sources`, `warnings`,
and `usage` aggregate across steps. For streamed final-step usage, read
`(await result.finalStep).usage`. Retaining request and response bodies requires
opting in.

Validate untrusted messages before passing them to `generateText`, `streamText`,
`generateObject`, or `streamObject`: these APIs trust the caller's `ModelMessage`
shape. Other inputs rely on declared types for shape checks; value constraints
such as integer ranges and finite decision JSON numbers are still validated.

## Tool approvals and replay

Move rules from deprecated tool-level `needsApproval` to per-run `toolApproval`
on `generateText`, `streamText`, or `ToolLoopAgent`. For example,
`toolApproval: { publishDraft: 'user-approval' }` gates that tool. Per-tool or
catch-all functions can approve, deny, or ask the user.

Replay revalidates input and policy. Pending approvals can resume from earlier
messages until superseded by a user message. Replay preserves schema-transformed
approved inputs and rejects histories whose reconstructed output differs,
including signed histories missing the original input.

Opt-in HMAC signing binds the original input to the approval. Automatic denials
no longer receive signatures: rotate `experimental_toolApprovalSecret` to
invalidate signatures issued for denials by older versions, then request any
still-pending approvals again.

UI stream resumption preserves approval state. If the final tool message has
multiple responses for one call, the first response determines execution.
Include an approved call's result in later conversation context; persisted
outputs for unavailable tools are withheld. Approval continuations restore
server-defined tool metadata, dynamic status, and title before policy evaluation.

## Agent control and tool execution

`ToolLoopAgent` evaluates `stopWhen` after a step returns tool results and defaults
to `isStepCount(20)`. Arrays stop when any condition matches; custom predicates
receive `{ steps }`. `stopWhen: isLoopFinished()` removes the step cap while
preserving normal loop exits.

With `toolChoice: 'required'`, a tool with only a description and input schema can
carry the final answer. Calling it ends the loop and leaves its arguments in
`result.staticToolCalls`. Read `stoppedBy` from generation results, the `onEnd`
event, or the finish stream part to determine why the loop ended.

Initialize shared state with `runtimeContext`; read it in `prepareStep`, approvals,
and lifecycle callbacks. A step can return updated context for later steps.
Declare tool context with `contextSchema`, provide values under the tool's key in
`toolsContext`, and read `context` in the second argument to `execute`.

A `prepareStep` callback can override individual model call settings. Constructor
lifecycle handlers run before per-call handlers for the same event.
Register `onStepError` to observe step failures; `ToolLoopAgent` also accepts
`onError` and `onAbort`.

Tool execution can return an `AsyncIterable` for progress updates; the final
result is the last value yielded. `onInputAvailable` runs for valid streamed
inputs and follows the repaired tool if repair changes the tool. Input callbacks
receive the individual tool's context.

`toolChoice: 'none'` gates calls in `generateText`, `streamText`, and
`WorkflowAgent`. Rejected calls skip `repairToolCall` and
`experimental_refineToolInput`; streamed runs withhold those tool parts.
Tools governed by a tool caller are protected from direct execution.

Code-mode can discover and update tools mid-conversation; `WorkflowAgent` supports
deferred discovery. Use a `search` callback to select and rank eligible deferred
tools, with `maxResults` to cap the result count.

## Durable runs and steering

Construct `WorkflowAgent` from `@ai-sdk/workflow` with `{ model, tools, runtimeContext }`
for restarts or delayed approvals. It persists execution between steps and
supports workflow streaming, `prepareCall`, provider model serialization, and
approval resumption. `await agent.generate({ prompt })` returns the core result
with typed output from a durable loop that defaults to 20 steps.

In `WorkflowAgent.prepareStep`, returned `instructions` replace and carry forward
the current instructions, `providerOptions` merge with agent options, and
`headers` override matching call headers. Workflow `toolApproval` policies run
in workflow context: approved calls execute in the same step, and denied calls
return `execution-denied` without pausing.

Experimental steering is supported by `generateText`, `streamText`, and
`ToolLoopAgent`. Use `steering.queue()` to defer a message until the current task
completes, or the interrupt option to cancel a model call before output begins.

## Streaming, timeouts, and termination

Set `streamRetries` on `streamText` for provider errors after streaming starts.
The retry-aware `onError` can direct one recovery even with `streamRetries: 0`;
recovered results and metadata come from the successful attempt.

Use `timeout.totalMs` for the run, `stepMs` for the complete step including local
tools, `firstChunkMs` for the first content, and `chunkMs` for gaps between chunks.
The content timeout budgets stop at each model response's end and reset on retry.
Use `toolMs` as the default tool limit and `timeout.tools` for per-tool limits.
Abort reasons propagate to stream and UI consumers as `TimeoutError`.

`streamText` passes call ID and abort reason to `onAbort`; aborting a multi-step
run skips `onEnd`. UI stream end callbacks report consumer cancellation, and
client disconnects cancel response streams. Await Node.js response piping to
catch stream read and write errors.

Handle `finishReason === 'interrupted'` in incomplete-response checks and
exhaustive finish-reason types. When providers begin emitting it for streams
without a completion signal, partial output is returned and tool execution,
agent continuation, and automatic UI follow-ups stop.

From 7.0.144 onward, use `experimental_streamTextLowMemory(options)` instead of
`streamText({ ...options, experimental_lowMemory: true })`. Consume it once:
it keeps neither a replay buffer nor retained final-content results.

Compatible providers emit typed heartbeats with `includePings: true`, which is
off by default. Handle `ping` in exhaustive core stream switches; pings pass
through retries but are excluded from generated content and UI streams.
Optional SSE heartbeats keep idle UI message streams open.

## Chat and persisted messages

React `useChat` can call an agent through `new DirectChatTransport({ agent })`.
Callbacks use current props and state; `sendAutomaticallyWhen` accepts async
conditions. `experimental_queue` queues messages during an active response and
waits for those async decisions, retaining request options when sending a tool
approval first.

With `useChat({ resume: true })`, interrupted streams can resume when the page
becomes visible. Remounting a shared chat already submitted or streaming leaves
the active request in place. A message replaced through `sendMessage` gets a new
ID; use the replacement's ID when persisting it.

`validateUIMessages` preserves parsed metadata and data, including schema
transforms. Validation stops at the first invalid message or part and checks
schemas for the declared part type. Register `dataPartSchemas` by the bare name,
such as `weather` for `data-weather`; invalid streamed data raises
`TypeValidationError`.

Read static tool input errors from `input`, following the deprecation of
`rawInput` on `output-error` parts. UI streams send the same error text the model
received for failed and invalid calls. Use `redactToolErrors: true` to restore
masking, or `false` to preserve that text even with an `onError` callback.

## Structured output, reasoning, and telemetry

Use `minItems` and `maxItems` with `Output.array` to bound structured arrays.
Array output preserves schema transforms, coercions, defaults, and pipes.
`Output.object` and `Output.array` infer unions when given union-typed schemas.
Streamed structured output comes from the final tool-loop step; partial JSON
may include `null` or the empty string.

Set portable `reasoning` to `'high'` or `'max'`; model-specific provider options
remain available. Providers may coerce `'max'` with a compatibility warning;
exhaustive `ReasoningLevel` maps and switches must handle `max`.
Language-model-backed `experimental_decide` calls default to disabled reasoning
when omitted. Mixed decision state uses ordered text, file, and JSON parts;
wrap a JSON array in an object or JSON part because a top-level array means parts.

Register `new OpenTelemetry()` from `@ai-sdk/otel` with `registerTelemetry` from
`ai`; put custom tracers in the integration constructor. For durable traces, use
the same `OpenTelemetryIdGenerator` instance for the tracer provider's
`idGenerator` and `sampler` and the integration's `durable` option.
`recordInputs` and `recordOutputs` govern nested content and raw span results.
Read `aiVersion` on telemetry events; use `onWarning` for per-call warnings.

Files in this skill

  • SKILL.md10.6 KB
  • coverage.json1.1 KB
  • references/agents-and-tools.md10.2 KB
  • references/generation-and-media.md5.3 KB
  • references/mcp-and-runtimes.md4.1 KB
  • references/migrations.md2.2 KB
  • references/providers-and-observability.md2.9 KB
  • references/ui-and-streams.md3.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.