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/ui-hooks.md

View on GitHub
---
title: AI SDK 7 UI Hooks
description: useChat, UIMessage streams, tool parts, approvals, harness UI, and workflow UI.
---

# Chat, workflow and harness UI

`useChat` manages conversation/stream state, while the component owns input.
Configure `DefaultChatTransport` for ordinary HTTP chat and return matching
UI-message chunks. Infer tool types; narrow part state before reading
input/output, and handle dynamic parts separately.

Manual approval requests are parts in `approval-requested` state whose `part.approval.isAutomatic` is not true (automatic decisions pass through the same state); answer with
`addToolApprovalResponse({ id: part.approval.id, approved })`. Automatic policy
decisions do not need a fabricated user response. Continue with
`sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses`
(or `...WithToolCalls` for client-executed tools). The client `useChat`
`onFinish` keeps its name in v7.

Persist validated UI messages for UI restoration. Preserve protocol-valid
tool-call/result and provider context when building model history; do not
strip all non-text parts as a universal fix.

Harness routes authorize/create/resume a session, inject it into the call and
persist opaque resume state. The harness owns history.

Workflow routes convert model chunks at the response boundary. For
`WorkflowChatTransport`, the POST response carries an `x-workflow-run-id`
header and `GET {api}/{runId}/stream?startIndex=<n>` returns the run's readable
stream for reconnection. Ordinary chat resumption is a different contract.

Read [AI SDK UI docs](https://ai-sdk.dev/docs/ai-sdk-ui/overview) and the selected
agent package's integration guide. Test cancellation, direct reload and a
second restored turn alongside successful streaming.
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