Move makeAssistantTool, useAssistantTool, makeAssistantToolUI, and useAssistantToolUI registrations to the toolkit API.
The component and hook based tool APIs are deprecated:
makeAssistantTooluseAssistantToolmakeAssistantToolUIuseAssistantToolUI
Use a toolkit registered with Tools({ toolkit }) instead. A toolkit keeps the model contract, browser execution, and tool-call rendering in one named map, which avoids duplicate registrations and makes the client and backend split explicit. Defining Tools owns the toolkit API; this page only maps the old calls onto it.
What replaces what
| Before | After |
|---|---|
toolName | The key in the toolkit |
Tool with an execute that runs in the browser | An entry with execute that starts with "use client" (generative), or type: "frontend" (plain) |
Tool with type: "human" | execute: humanTool() (generative), or type: "human" (plain) |
makeAssistantToolUI and useAssistantToolUI | render or renderText on the entry, with execute: externalTool() (generative) or type: "backend" (plain) when another system runs the tool |
description, parameters, render, renderText, display, disabled, providerOptions | The same fields on the entry |
A tool whose execute closes over component state | execute: stubTool() plus useAuiToolOverrides; see Dynamic Tools |
| A tool component you mount or unmount to turn the tool on or off | useAuiToolOverrides({ name: { disabled: true } }); see Disabling a tool |
| A renderer that closes over props or state | useInlineRender; see Renderers that need props or state |
| A renderer for one message surface | The part.toolUI children API of MessagePrimitive.Parts; see Tool Resolution |
Before
import { AssistantRuntimeProvider, makeAssistantTool } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import { z } from "zod";
const WeatherTool = makeAssistantTool({
toolName: "get_weather",
description: "Get the current weather for a city.",
parameters: z.object({
city: z.string(),
}),
execute: async ({ city }) => fetchWeather(city),
render: ({ args, result }) => (
<WeatherCard city={args.city} weather={result} />
),
});
export function App() {
const runtime = useChatRuntime();
return (
<AssistantRuntimeProvider runtime={runtime}>
<WeatherTool />
<Thread />
</AssistantRuntimeProvider>
);
}On the server, this tool arrived in the request body and your route turned it into an AI SDK tool with frontendTools(tools).
Choose a path
| Plain toolkit | "use generative" toolkit | |
|---|---|---|
| Build plugin | None | withAui, aui(), or the Metro plugin |
| Where the schema comes from | The client uploads it on every request | The server build of the toolkit |
| Server route | Unchanged: frontendTools(tools) | Import the toolkit with AISDKToolkit |
The generative path is the default for new code. The plain path moves the registration with no build or route changes and is a safe first step.
After: "use generative"
"use generative";
import { defineToolkit } from "@assistant-ui/react";
import { z } from "zod";
export default defineToolkit({
get_weather: {
description: "Get the current weather for a city.",
parameters: z.object({
city: z.string(),
}),
execute: async ({ city }) => {
"use client";
return fetchWeather(city);
},
render: ({ args, result }) => (
<WeatherCard city={args.city} weather={result} />
),
},
});After: plain toolkit
"use client";
import { defineToolkit } from "@assistant-ui/react";
import { z } from "zod";
export const toolkit = defineToolkit({
get_weather: {
type: "frontend",
description: "Get the current weather for a city.",
parameters: z.object({
city: z.string(),
}),
execute: async ({ city }) => fetchWeather(city),
render: ({ args, result }) => (
<WeatherCard city={args.city} weather={result} />
),
},
});Register the toolkit
Both paths register the toolkit once on the runtime provider, where const config = AuiConfig({ tools: Tools({ toolkit }) }):
"use client";
import {
AssistantRuntimeProvider,
AuiConfig,
Tools,
} from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
import toolkit from "./toolkit";
export function App() {
const runtime = useChatRuntime({
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
});
const config = AuiConfig({ tools: Tools({ toolkit }) });
return (
<AssistantRuntimeProvider runtime={runtime} config={config}>
<Thread />
</AssistantRuntimeProvider>
);
}For the plain toolkit, import the named export: import { toolkit } from "./toolkit".
Update the route (generative only)
A compiled client does not upload the schemas of its frontend and human tools, because it assumes your server imports the same file. A route that still calls only frontendTools(tools) never tells the model about them. Import the toolkit through AISDKToolkit:
import { AISDKToolkit } from "@assistant-ui/ai-sdk";
import toolkit from "../../toolkit";
const aiToolkit = new AISDKToolkit({ toolkit });
export async function POST(req: Request) {
const { messages, tools } = await req.json();
const aiSDKTools = {
...frontendTools(tools ?? {}),
...(await aiToolkit.tools({ frontend: tools })),
// your other server tools
};
// ...
}If no server of yours imports the toolkit, compile with the backendless option so the client keeps uploading every schema. Backend tools has the full route.
Mechanical steps
- Create a toolkit with
defineToolkit. - Move each
toolNameinto the toolkit key. - Move
description,parameters,execute,providerOptions,render,renderText, anddisplayonto the entry, then apply the table above fortype. In a"use generative"file never writetype; the compiler infers it fromexecute. - Register the toolkit once with
config={config}on your runtime provider. - Remove
<Tool />,<ToolUI />,useAssistantTool(...), anduseAssistantToolUI(...). - For a generative toolkit, update the route as above.
Search your code for makeAssistantTool and useAssistantTool to confirm nothing is left.
UI-only tool renderers
A makeAssistantToolUI or useAssistantToolUI call attached a renderer to a tool that runs elsewhere, such as your backend, an MCP server, or LangGraph:
const WebSearchUI = makeAssistantToolUI({
toolName: "web_search",
render: ({ args, result }) => (
<SearchResults query={args.query} results={result?.results ?? []} />
),
});Move the renderer onto a toolkit entry whose key matches the tool name. In a generative file, externalTool() leaves the entry off the server build and keeps it on the client as type: "backend":
"use generative";
import { defineToolkit, externalTool } from "@assistant-ui/react";
import { z } from "zod";
export default defineToolkit({
web_search: {
parameters: z.object({ query: z.string() }),
execute: externalTool(),
render: ({ args, result }) => (
<SearchResults query={args.query} results={result?.results ?? []} />
),
},
});Without the compiler, write { type: "backend", render } in a plain toolkit. Either way the entry uploads no schema and runs no browser code; it only attaches UI to matching tool-call parts. See Defining Tools for both shapes. For MCP server catalogs, spread defineMcpToolkit({ ... }) into the toolkit; see MCP.
Tools that use component state
A useAssistantTool call inside a component could close over its state:
function TaskBoard() {
const [tasks, setTasks] = useState<Task[]>([]);
useAssistantTool({
toolName: "add_task",
type: "frontend",
description: "Add a task to the board.",
parameters: z.object({ title: z.string() }),
execute: async ({ title }) => {
setTasks((prev) => [...prev, { id: crypto.randomUUID(), title }]);
return { ok: true };
},
});
return <TaskList tasks={tasks} />;
}A toolkit entry cannot close over state, so split the tool: the entry declares the contract with execute: stubTool(), and useAuiToolOverrides in the same component supplies the executor. Dynamic Tools walks through the full rewrite of this component.
Warning
useAuiToolOverrides is experimental and its API may change.