ai-sdk-7
Skill72 starsChanged 18 days agoMITView on GitHub
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 AI SDK v6 code use ai-sdk-6; for version discovery and general doc lookup use ai-sdk.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/ai-sdk-6/references/agents.mdAGENTS.md
- skills/ai-sdk-7/references/agents.mdAGENTS.md
- skills/openai-agents-sdk/references/agents.mdAGENTS.md
- skills/react-best-practices/AGENTS.mdAGENTS.md
- skills/vercel-react-view-transitions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agent-harness-reviewSkill
- ai-appSkill
- ai-elementsSkill
- ai-sdk-6Skill
- ai-sdkSkill
- cache-componentsSkill
- chrome-devtoolsSkill
- frontend-designSkill
- goSkill
- handoffSkill
- hetzner-cloudSkill
- iconsSkill
- next-best-practicesSkill
- nextjs-chatbotSkill
- nextjs-seoSkill
- nextjs-shadcnSkill
- openai-agents-sdkSkill
- postgres-semantic-searchSkill
- react-best-practicesSkill
- shadcnSkill
- supabase-postgres-best-practicesSkill
- vercel-react-view-transitionsSkill
- web-design-guidelinesSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Read the resolved ai/docs/, provider docs and installed source/types first.
- Very specific: line 39
Use runtimeContext for server loop state and schema-validated toolsContext for per-tool state.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AI SDK 7 implementation and migration
Apply this skill to ai@7; use ai-sdk to resolve unknown versions and
ai-sdk-6 for v6 maintenance. Match provider and UI package versions to the
project. AI SDK 7 requires Node.js 22+ and AI SDK packages are ESM-only.
Read the resolved ai/docs/, provider docs and installed source/types first;
each ai-sdk.dev/docs/... link in this skill has an offline copy under ai/docs/
(path mapping in ai-sdk). Harness, WorkflowAgent and migration guides live
in ai/docs/03-ai-sdk-harnesses/, 03-agents/07-workflow-agent.mdx and
08-migration-guides/23-migration-guide-7-0.mdx; the companion packages ship
only types. Use official docs or the matching
repository tag when local docs are unavailable. Experimental package APIs need
a fresh check before adding long-lived wrappers.
| Need | Entry point |
| In-memory agent loop | ToolLoopAgent from ai |
| Durable agent | WorkflowAgent from @ai-sdk/workflow + workflow 5 |
| Claude Code/Codex/Pi runtime | HarnessAgent from @ai-sdk/harness/agent + adapter + sandbox package |
| OpenTelemetry | registerTelemetry(new OpenTelemetry()), @ai-sdk/otel |
| Stalled calls | timeout: ms or { totalMs, stepMs, firstChunkMs, chunkMs, toolMs } |
Important boundaries
- Text functions and ToolLoopAgent use
instructions; loop limits useisStepCount. Core, agent and server UI-stream helpers useonEnd/onStepEnd(onFinishremains a deprecated alias); clientuseChat/ChatkeepsonFinish. prepareStepinstruction/message overrides carry forward. Results such asusageand tool arrays aggregate all steps;finalSteppreserves final-step access, and is awaited for streams.- Use
runtimeContextfor server loop state and schema-validatedtoolsContextfor per-tool state. Neither is model-visible merely by being context. - Approval, persistence and lifecycle differ across ToolLoopAgent, WorkflowAgent, HarnessAgent and provider-executed tools. Choose the runtime for the actual durability/permission requirements.
- Resolve model IDs and capabilities from the configured provider. Avoid
overlapping reasoning settings: provider options can override top-level
reasoning.
Core shape
Checked with ai@7.0.124, @ai-sdk/react@4.0.127, zod@4.6.5, React 19 and
TypeScript 5.9: tsc --noEmit, plus a mock-model run through one tool step and
the follow-up answer. A string model resolves through the AI Gateway.
// app/api/chat/route.ts
import { convertToModelMessages, createUIMessageStreamResponse, isStepCount, streamText, tool,
toUIMessageStream, validateUIMessages, type InferUITools, type UIDataTypes, type UIMessage } from 'ai';
import { z } from 'zod';
const tools = {
weather: tool({
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => ({ city, celsius: 21 }),
}),
};
export type ChatMessage = UIMessage<never, UIDataTypes, InferUITools<typeof tools>>;
export async function POST(req: Request) {
const { messages } = await req.json();
const uiMessages = await validateUIMessages<ChatMessage>({ messages, tools });
const result = streamText({
model: 'provider/model-id', // configured gateway ID, or a provider instance
instructions: 'Answer briefly.',
messages: await convertToModelMessages(uiMessages),
tools,
stopWhen: isStepCount(5),
});
return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) });
}// app/page.tsx
'use client';
import { useChat } from '@ai-sdk/react';
import { DefaultChatTransport } from 'ai';
import type { ChatMessage } from './api/chat/route';
const transport = new DefaultChatTransport<ChatMessage>({ api: '/api/chat' });
export default function Chat() {
const { messages, sendMessage, status } = useChat<ChatMessage>({ transport });
return (
<form action={(form) => void sendMessage({ text: String(form.get('text')) })}>
{messages.map((m) => <div key={m.id}>{m.parts.map((part, i) =>
part.type === 'text' ? <p key={i}>{part.text}</p>
: part.type === 'tool-weather' && part.state === 'output-available'
? <p key={i}>{part.output.city}: {part.output.celsius} °C</p> : null)}</div>)}
<input name="text" disabled={status === 'submitted' || status === 'streaming'} />
</form>
);
}The v6 spellings (system, stepCountIs, result.toUIMessageStreamResponse())
still compile in 7.0.124; system and the response method are deprecated.
Read for the feature
- Agents: in-memory/durable execution and context.
- Harnesses: runtime-owned sessions and permissions.
- Core functions: output, stream and result contracts.
- Tools: approval boundaries, MCP Apps and sandbox handles.
- UI hooks: UI streams, approval and resumption.
- Migration: semantic changes and codemods.
- Telemetry: registration and data controls.
- Media/files: provider references and capability gates.
- Examples: current official implementations.
Typecheck and exercise the changed multi-turn, tool, stream or resume path. A successful compile does not prove approval policy or persistence behavior.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

