laguagu/claude-code-nextjs-skills / skills/ai-sdk-7
ai-sdk-7
VerifiedVercel 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.8 KB |
| references/agent-execution.md | markdown | 2.3 KB |
| references/core-functions.md | markdown | 1.6 KB |
| references/examples.md | markdown | 744 B |
| references/harnesses.md | markdown | 2.4 KB |
| references/media-and-files.md | markdown | 2.3 KB |
| references/migration-v6-to-v7.md | markdown | 5.6 KB |
| references/telemetry.md | markdown | 1.7 KB |
| references/tools.md | markdown | 2.0 KB |
| references/ui-hooks.md | markdown | 1.7 KB |
references/agent-execution.md
View on GitHub---
title: Agents in AI SDK 7
description: Build ToolLoopAgent and WorkflowAgent agents with AI SDK 7.
---
# Agent execution contracts
Choose `ToolLoopAgent` for an in-memory request lifecycle, `WorkflowAgent`
from `@ai-sdk/workflow` for durable workflow-backed execution, and
`HarnessAgent` for a runtime such as Claude Code or Codex. Text functions
default to one step, `ToolLoopAgent` to 20; `WorkflowAgent.stream()` has no default
step-count limit. Set `stopWhen` for the task budget.
ToolLoopAgent accepts generation/streaming calls and infers UI message types
with `InferAgentUIMessage`. Request state belongs in per-call options or
`prepareCall`, not a mutable singleton shared across tenants.
`runtimeContext` is shared loop state; `toolsContext` is validated per-tool
state through `contextSchema`. Put information the model needs in instructions
or messages, not only context.
WorkflowAgent is stream-first; `generate()` works from `@ai-sdk/workflow` 2.0.59 /
`ai` 7.0.128 with a 20-step default and throws on older versions. Streaming writes
`ModelCallStreamPart` chunks to a workflow writable and converts them at the UI
boundary with `createModelCallToUIChunkTransform()`. Durable tool work uses
`'use step'`; context must be serializable. Approval is tool-level
`needsApproval`; from `@ai-sdk/workflow` 2.0.105 (`ai` 7.0.173) `toolApproval` is
also accepted in the constructor or per `generate()`/`stream()` call and takes
precedence over `needsApproval`. Its functions run in workflow context, outside
the durable model steps. Only `'user-approval'` suspends the workflow: approved
calls run in the same step, denied calls get an `execution-denied` result. Older
versions have only `needsApproval`. UI types come from
`InferWorkflowAgentUIMessage`. It replaces Workflow DevKit's `DurableAgent`.
`@ai-sdk/workflow` 2.0.66 onward peer-requires `workflow ^5.1.0`. Install
`workflow@5`; the `workflow@beta` tag points to an older, incompatible 5.0 beta. Signed approvals use
`experimental_toolApprovalSecret: { environmentVariable }` so raw keys are not
serialized into durable steps.
Read installed workflow types before adapting core agent helpers. Start from
[agent docs](https://ai-sdk.dev/docs/agents/building-agents) and
[WorkflowAgent docs](https://ai-sdk.dev/docs/agents/workflow-agent);
for runtime-owned history see [harnesses.md](harnesses.md).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |