npx skills add ...
npx skills add assistant-ui/skills --skill tools
Defines model-callable tools and renders their calls in assistant-ui. The authoring model: a \"use generative\" file whose default export is defineToolkit({...}), compiled by withAui from @assistant-ui/next, aui() from @assistant-ui/vite, or withAui from @assistant-ui/metro, mounted with AuiConfig({ tools: Tools({ toolkit }) }), and exposed to the model with new AISDKToolkit({ toolkit }).tools({ frontend }). Covers the tool kinds (backend, \"use client\" frontend, humanTool(), providerTool(), externalTool(), stubTool(), defineMcpToolkit()), render and display, ToolCallMessagePartProps, approval gates, MCP servers, MCP Apps, WebMCP, and sub-agent messages. Reach for it when a tool is never called, a tool UI does not render, a frontend result never reaches the model, humanTool() throws at runtime, or an approval gate cannot be answered. For model-composed UI use generative-ui, for MCP servers users add in the browser use react-mcp, and for the styled ToolFallback and ToolGroup use elements.
npx skills add assistant-ui/skills --skill tools
Always consult assistant-ui.com/llms.txt for the latest API.
A tool is a named capability the model can call. In assistant-ui you declare tools in a toolkit, a map whose keys are the tool names the model sees and whose values carry the schema, the executor, and the renderer. The supported authoring path is a "use generative" file compiled by a build plugin, which splits one file into a server build (schema plus backend executors) and a client build (schema plus renderers plus browser executors).
toModelOutput, providerOptions, stubs, splitting and merging files, backendlessuseToolArgsStatus, deferred rendering, streaming args, ToolFallback and ToolGrouphuman() interrupts, and the full approval gate surfacedefineMcpToolkitui:// widgets with McpAppRendererunstable_useWebMcpProvidermakeAssistantTool family and how to migrate off itThe directive does nothing without a compiler.
Vite and TanStack Start add aui() from @assistant-ui/vite to plugins instead; Expo and bare React Native wrap the Metro config with withAui from @assistant-ui/metro. All three take an aui options object, documented in toolkits.md.
To scope a toolkit to part of the tree instead, wrap that subtree in <AuiProvider extends={aui} config={config}> with const aui = useAui(). useChatRuntime() targets /api/chat by default.
The same import resolves to the server build inside a route handler.
AISDKToolkit.tools() registers every toolkit tool with the model, wires the backend execute where the server build carries one, merges the frontend tools the client uploaded in the request body, and opens any MCP servers the toolkit spreads in. A server execute wins over an uploaded entry of the same name.
The kind is inferred from execute and written back as type. You never author type in a "use generative" file.
execute you write | Inferred kind | Server build keeps | Client build keeps |
|---|---|---|---|
plain async () => ... | backend | schema plus execute, guarded by server-only | schema plus render |
async () => { "use client"; ... } | frontend | schema only | schema plus execute plus render or renderText |
humanTool() | human | schema only | schema plus render |
stubTool() | frontend, executor supplied at runtime | schema only | schema plus render or renderText |
providerTool({ ... }) | provider | schema plus provider config | schema plus provider config |
externalTool() | backend, defined elsewhere | omitted | type: "backend" plus render or renderText |
The compiler enforces at build time that every tool declares an execute, that a frontend tool declares a render or renderText, and that a human tool declares a render. humanTool() and stubTool() have no runtime implementation and throw when reached, which means that file was never compiled; externalTool() is a compile-time marker in the same way.
render receives the live call as ToolCallMessagePartProps.
| Field | Type | Notes |
|---|---|---|
args | TArgs | Parsed arguments, partial while streaming |
argsText | string | Raw, possibly partial JSON |
result | TResult | undefined | Present once the call has a result |
isError | boolean | undefined | Whether the result represents a failure |
status | ToolCallMessagePartStatus | running, complete, incomplete with a reason, or requires-action with reason: "tool-calls" | "interrupt" |
toolName, toolCallId | string | Model-visible name and the stable id of this invocation |
timing | ToolCallTiming | undefined | Wall clock start and completion, when tracked |
interrupt | { type: "human"; payload: unknown } | undefined | A paused human() request from a frontend executor |
approval | object | undefined | Server-side gate: id, approved?, options?, optionId?, resolution? |
addResult | (result) => void | Completes a human tool from the UI |
resume | (payload: unknown) => void | Answers an interrupt |
respondToApproval | (response: ToolApprovalResponse) => Promise<void> | Answers an approval gate |
For a one-line status instead of a component, set renderText with running and complete values, each a string or a function of ({ args, result }). Set display: "standalone" on the entry to keep the UI outside the collapsed tool group. Tools with no renderer fall back to the ToolFallback element.
Some runtimes pause on the server and emit an approval request the client must answer before the tool runs. The AI SDK v7 runtime emits one for every tool listed in the call-level toolApproval option.
approval.approved has three states. undefined means the gate is open and is the only state in which respondToApproval is legal. true means the decision was recorded as allow and the server is producing the result. false means it was recorded as deny; the runtime records an error result and exposes approval.reason. approval.isAutomatic is true when a server-side policy granted the decision rather than the user, so render a badge instead of buttons.
respondToApproval returns a promise that resolves once the runtime accepted the response and rejects when it could not be recorded, for example an expired gate or a refused answer. Await it before disabling the controls so a refused response leaves the request retryable. toolApprovalAcceptsText(approval) reports whether the request takes a free-form answer, on its own or alongside its options, so a renderer knows whether to offer a text field. The full option, question, and resolution surface is in human-in-loop.md.
A human tool has no executor: the run pauses until the renderer supplies the result.
Call addResult exactly once. Use a human tool when the user supplies the tool result itself, and an approval gate when the backend owns the action and only needs permission.
humanTool() or stubTool() throws at runtime
"use generative" as the file's first line.A tool UI never renders
prefix.const config = AuiConfig({ tools: Tools({ toolkit }) }) passed as config on the provider. Pass a stable toolkit from module scope or useMemo.The model never learns about a frontend or human tool
aui: { backendless: true }.A frontend tool result never reaches the model
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls from ai, and lastAssistantMessageIsCompleteWithApprovalResponses for approval gates.toModelOutput is ignored on round-tripped results
convertToModelMessages(messages, { tools }) as well as to streamText.A build warning about tool names
makeTool() came from an opaque factory call: write it as an inline object, or spread a compiler-visible defineToolkit(...) or defineMcpToolkit(...) fragment.respondToApproval rejects
approval.approved is undefined. A text answer to a request that declares neither display: "text" nor allowFreeform throws, as does an unknown optionId.MCP connections pile up
AISDKToolkit at module scope so clients pool across requests, and call aiToolkit.close() from onFinish.ToolFallback and ToolGroup files and the rest of the cataloguseChatRuntime and the AI SDK route the toolkit plugs into