Skip to content

laguagu/claude-code-nextjs-skills / skills/ai-sdk-7

ai-sdk-7

Verified

Vercel AI SDK v7 development and migration. Use when building or upgrading AI SDK 7 apps, especially ToolLoopAgent, WorkflowAgent, HarnessAgent, Claude Code/Codex/Pi harnesses, runtimeContext, toolsContext, toolApproval, telemetry, reasoning, file or skill uploads, realtime, video generation, or v6-to-v7 breaking changes. For version discovery, v6 code and general doc lookup use ai-sdk.

references/migration-v6-to-v7.md

View on GitHub
---
title: Migrate AI SDK v6 to v7
description: Checklist for upgrading AI SDK 6 applications to AI SDK 7.
---

# Migrate AI SDK 6 to 7

Use the [official migration guide](https://ai-sdk.dev/docs/migration-guides/migration-guide-7-0)
as the complete checklist. A v6 install does not contain it; after upgrading
`ai` it is at `node_modules/ai/docs/08-migration-guides/23-migration-guide-7-0.mdx`.
Vercel also publishes a migration skill
(`npx skills add vercel/ai --skill migrate-ai-sdk-v6-to-v7`). Keep a recoverable
baseline, upgrade compatible packages, run the v7 codemod with the project's
runner (`bunx --bun @ai-sdk/codemod v7` in a Bun project), then review the diff.
Codemods do not cover every semantic change.

## Renames to search for

- Core: `system` → `instructions` (also in `prepareStep` results, the options
  passed to `experimental_repairToolCall`, and lifecycle event fields),
  `stepCountIs` → `isStepCount`, `experimental_output` → `output`,
  `experimental_prepareStep` → `prepareStep`, `experimental_activeTools` →
  `activeTools`, `experimental_customProvider`/`_generateImage`/`_transcribe`/
  `_generateSpeech` → unprefixed, `CallSettings` →
  `LanguageModelCallOptions & Omit<RequestOptions, 'timeout'>`.
- Callbacks: `onFinish` → `onEnd`, `onStepFinish` → `onStepEnd`,
  `experimental_onStart`/`_onStepStart` → `onStart`/`onStepStart`,
  `experimental_onToolCallStart`/`_onToolCallFinish` →
  `onToolExecutionStart`/`onToolExecutionEnd`, embed/rerank
  `experimental_onFinish` → `onEnd`.
- Telemetry/streams: `experimental_telemetry` → `telemetry` (tracer moves into
  `new OpenTelemetry({ tracer })`), `experimental_include` → `include`,
  `includeRawChunks` → `include.rawChunks`, `fullStream` → `stream`.
  V6 `experimental_telemetry.metadata` has no v7 counterpart (`ai@7.0.137`);
  move labels to top-level `runtimeContext` and explicitly allowlist fields with
  `telemetry.includeRuntimeContext`.
- Tools/types: tool callback `experimental_context` → `context` (values via
  `toolsContext`), top-level `experimental_context` → `runtimeContext` (split
  per-tool data into `toolsContext`), `ToolCallOptions` →
  `ToolExecutionOptions`, `isToolOrDynamicToolUIPart` → `isToolUIPart`
  (already the preferred static-or-dynamic predicate in v6),
  `needsApproval: true` → `tools: { myTool }, toolApproval: { myTool: 'user-approval' }`
  (keyed by the tool's name).
- Usage/results: `totalUsage` → `usage` (now all steps; `finalStep.usage` is the
  old `usage`), `usage.cachedInputTokens` → `usage.inputTokenDetails.cacheReadTokens`,
  `usage.reasoningTokens` → `usage.outputTokenDetails.reasoningTokens`;
  `step.response.messages` is per step, use `result.responseMessages` for all.
- Response helpers: `result.toUIMessageStreamResponse(opts)` →
  `createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream, ...opts }) })`;
  likewise `pipeUIMessageStreamToResponse`, `toTextStream` +
  `createTextStreamResponse`/`pipeTextStreamToResponse`.
- Content parts: the v7 codemod maps tool-result `media` → deprecated `file-data`;
  manually migrate inline outputs to `{ type: 'file', mediaType, data: { type: 'data', data } }`.
  `image-*`/`file-*` result variants and user `image` parts → `file` parts with `mediaType`.
- Providers: Anthropic `cacheCreationInputTokens` metadata →
  `usage.inputTokenDetails.cacheWriteTokens`; Google `GoogleGenerativeAI*`
  names → `Google*`; `xai(id)` uses the Responses API (`xai.chat(id)` keeps Chat
  Completions); OpenAI Responses with reasoning defaults `reasoningSummary` to
  `'detailed'` (`null` disables).

## Changes that need deliberate review

| Area | Migration contract |
| --- | --- |
| Runtime | Node.js 22+, ESM-only AI SDK packages; `require()` is officially unsupported, though it may load through require(esm) on Node ≥22.12 |
| Step preparation | Returned instructions and messages carry into later steps |
| Trusted history | System messages in `messages`/`prompt` rejected by default; `allowSystemInMessages` only for trusted stored history |
| Callbacks | Rename core/agent/UI-stream callbacks only; client `useChat` `onFinish` keeps its name |
| Streaming | `onChunk` sees all parts, not only text/tool deltas |
| Results | Top-level usage/content/tool arrays aggregate; use `finalStep` for final-step access |
| Context | Shared `runtimeContext`; per-tool `toolsContext` + `contextSchema` |
| Approval | Core/ToolLoopAgent `toolApproval` (tool-level `needsApproval` deprecated there); WorkflowAgent keeps `needsApproval` and from `@ai-sdk/workflow` 2.0.105 also takes `toolApproval`, which takes precedence |
| Telemetry | Opt out with `telemetry.isEnabled: false`; global registration optional; bodies and context excluded unless included |
| Reasoning | Provider settings override overlapping top-level `reasoning` |
| Files | Canonical `file` parts; tool outputs use tagged `data`; handle deprecated `file-data` in persisted/legacy outputs and `reasoning-file` |
| MCP | HTTP/SSE `redirect` defaults to `'error'`; `'follow'` only for trusted servers |

Search the migration guide for remaining removed/renamed symbols. An alias
being deprecated does not mean it is already removed; migrate in the documented
scope instead of global textual replacement.

Audit replay/serialization, usage accounting and approval policies separately
from type errors. Verify request/response body inclusion if integrations inspect
those fields. Consult only the package sections the app uses.

Run typecheck and relevant integration tests. Exercise multi-step tools, manual
denial, restored history and streaming failure when those paths changed.
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall