@assistant-ui/mcp-docs-server 0.1.31 → 0.1.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/.docs/organized/code-examples/waterfall.md +23 -25
  2. package/.docs/organized/code-examples/with-a2a.md +28 -28
  3. package/.docs/organized/code-examples/with-ag-ui.md +35 -30
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +16 -14
  5. package/.docs/organized/code-examples/with-artifacts.md +44 -38
  6. package/.docs/organized/code-examples/with-assistant-transport.md +68 -56
  7. package/.docs/organized/code-examples/with-browser-extension.md +357 -0
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +425 -90
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +30 -29
  10. package/.docs/organized/code-examples/with-cloud.md +16 -14
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +19 -17
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +29 -26
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +20 -18
  14. package/.docs/organized/code-examples/with-expo.md +37 -31
  15. package/.docs/organized/code-examples/with-external-store.md +13 -11
  16. package/.docs/organized/code-examples/with-ffmpeg.md +327 -290
  17. package/.docs/organized/code-examples/with-generative-ui.md +1195 -194
  18. package/.docs/organized/code-examples/with-google-adk.md +13 -11
  19. package/.docs/organized/code-examples/with-heat-graph.md +16 -14
  20. package/.docs/organized/code-examples/with-image-generation.md +456 -0
  21. package/.docs/organized/code-examples/with-interactables.md +322 -244
  22. package/.docs/organized/code-examples/with-langchain.md +18 -16
  23. package/.docs/organized/code-examples/with-langgraph.md +95 -88
  24. package/.docs/organized/code-examples/with-livekit.md +30 -27
  25. package/.docs/organized/code-examples/with-mcp.md +754 -0
  26. package/.docs/organized/code-examples/with-opencode.md +70 -70
  27. package/.docs/organized/code-examples/with-react-hook-form.md +24 -22
  28. package/.docs/organized/code-examples/with-react-ink.md +4 -4
  29. package/.docs/organized/code-examples/with-react-router.md +20 -18
  30. package/.docs/organized/code-examples/with-resumable-stream.md +661 -0
  31. package/.docs/organized/code-examples/with-store.md +22 -20
  32. package/.docs/organized/code-examples/with-tanstack.md +18 -19
  33. package/.docs/organized/code-examples/with-tap-runtime.md +31 -28
  34. package/.docs/raw/docs/(docs)/architecture.mdx +43 -2
  35. package/.docs/raw/docs/(docs)/cli.mdx +2 -2
  36. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +34 -26
  37. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +32 -26
  38. package/.docs/raw/docs/(docs)/index.mdx +2 -2
  39. package/.docs/raw/docs/(docs)/installation.mdx +2 -2
  40. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +26 -24
  41. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
  42. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +20 -12
  43. package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
  44. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +41 -16
  45. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +12 -23
  46. package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +20 -0
  47. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +37 -8
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +11 -9
  49. package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +64 -0
  50. package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +22 -0
  51. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +52 -0
  52. package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +46 -0
  53. package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
  54. package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
  55. package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
  56. package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
  57. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +18 -13
  58. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +31 -52
  59. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
  60. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +15 -28
  61. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +64 -18
  62. package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +434 -0
  63. package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +24 -0
  64. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +11 -12
  65. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +109 -0
  66. package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +58 -0
  67. package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +22 -0
  68. package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +20 -0
  69. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +109 -132
  70. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +78 -221
  71. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +127 -242
  72. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +39 -20
  73. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +66 -87
  74. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +50 -58
  75. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +80 -48
  76. package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +67 -0
  77. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +323 -461
  78. package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +36 -43
  79. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +29 -24
  80. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
  81. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +202 -588
  82. package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +65 -0
  83. package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +35 -22
  84. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +57 -140
  85. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +70 -161
  86. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +84 -108
  87. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +77 -96
  88. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -349
  89. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +9 -21
  90. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +10 -21
  91. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +15 -70
  92. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +18 -13
  93. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +25 -28
  94. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +11 -63
  95. package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +20 -0
  96. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +11 -48
  97. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +10 -47
  98. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
  99. package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +85 -0
  100. package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
  101. package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +127 -0
  102. package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
  103. package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +91 -0
  104. package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +48 -0
  105. package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +62 -0
  106. package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +22 -0
  107. package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +19 -0
  108. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +143 -0
  109. package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +22 -0
  110. package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +54 -0
  111. package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +36 -0
  112. package/.docs/raw/docs/cloud/ai-sdk.mdx +1 -3
  113. package/.docs/raw/docs/cloud/index.mdx +2 -2
  114. package/.docs/raw/docs/guides/attachments.mdx +4 -4
  115. package/.docs/raw/docs/guides/branching.mdx +1 -1
  116. package/.docs/raw/docs/guides/chain-of-thought.mdx +12 -14
  117. package/.docs/raw/docs/guides/context-api.mdx +6 -5
  118. package/.docs/raw/docs/guides/dictation.mdx +2 -2
  119. package/.docs/raw/docs/guides/editing.mdx +1 -1
  120. package/.docs/raw/docs/guides/image-generation.mdx +74 -0
  121. package/.docs/raw/docs/guides/index.mdx +5 -14
  122. package/.docs/raw/docs/guides/latex.mdx +2 -2
  123. package/.docs/raw/docs/guides/mentions.mdx +6 -6
  124. package/.docs/raw/docs/guides/message-timing.mdx +38 -5
  125. package/.docs/raw/docs/guides/quoting.mdx +1 -1
  126. package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +212 -0
  127. package/.docs/raw/docs/guides/resumable-stream-stores.mdx +152 -0
  128. package/.docs/raw/docs/guides/resumable-streams.mdx +210 -0
  129. package/.docs/raw/docs/guides/slash-commands.mdx +2 -2
  130. package/.docs/raw/docs/guides/speech.mdx +2 -2
  131. package/.docs/raw/docs/guides/suggestions.mdx +89 -5
  132. package/.docs/raw/docs/guides/voice.mdx +2 -2
  133. package/.docs/raw/docs/ink/adapters.mdx +37 -1
  134. package/.docs/raw/docs/ink/custom-backend.mdx +59 -8
  135. package/.docs/raw/docs/ink/hooks.mdx +98 -85
  136. package/.docs/raw/docs/ink/index.mdx +10 -11
  137. package/.docs/raw/docs/ink/migration.mdx +1 -1
  138. package/.docs/raw/docs/ink/primitives.mdx +350 -9
  139. package/.docs/raw/docs/integrations/auth/better-auth.mdx +1 -1
  140. package/.docs/raw/docs/integrations/auth/clerk.mdx +1 -1
  141. package/.docs/raw/docs/integrations/auth/next-auth.mdx +1 -1
  142. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +3 -3
  143. package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
  144. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +2 -2
  145. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
  146. package/.docs/raw/docs/integrations/gateways/index.mdx +9 -4
  147. package/.docs/raw/docs/integrations/index.mdx +17 -5
  148. package/.docs/raw/docs/integrations/observability/langfuse.mdx +8 -1
  149. package/.docs/raw/docs/integrations/observability/langsmith.mdx +8 -4
  150. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
  151. package/.docs/raw/docs/migrations/toolkit-tools.mdx +226 -0
  152. package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
  153. package/.docs/raw/docs/primitives/composer.mdx +53 -0
  154. package/.docs/raw/docs/primitives/index.mdx +2 -2
  155. package/.docs/raw/docs/primitives/message.mdx +9 -10
  156. package/.docs/raw/docs/primitives/suggestion.mdx +9 -0
  157. package/.docs/raw/docs/react-native/hooks.mdx +57 -82
  158. package/.docs/raw/docs/react-native/index.mdx +4 -4
  159. package/.docs/raw/docs/react-native/migration.mdx +1 -1
  160. package/.docs/raw/docs/react-native/primitives.mdx +2 -2
  161. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +7 -4
  162. package/.docs/raw/docs/runtimes/a2a/overview.mdx +2 -2
  163. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +2 -2
  164. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +32 -1
  165. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +2 -2
  166. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +7 -2
  167. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
  168. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +129 -1
  169. package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
  170. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +27 -2
  171. package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -1
  172. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +18 -7
  173. package/.docs/raw/docs/runtimes/custom/overview.mdx +2 -2
  174. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
  175. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +2 -2
  176. package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
  177. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
  178. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +2 -2
  179. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
  180. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
  181. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
  182. package/.docs/raw/docs/runtimes/opencode/overview.mdx +2 -2
  183. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
  184. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -5
  185. package/.docs/raw/docs/tools/backend.mdx +136 -0
  186. package/.docs/raw/docs/tools/defining-tools.mdx +413 -0
  187. package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
  188. package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
  189. package/.docs/raw/docs/tools/index.mdx +76 -0
  190. package/.docs/raw/docs/{guides → tools}/interactables.mdx +3 -3
  191. package/.docs/raw/docs/tools/mcp-apps.mdx +231 -0
  192. package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +77 -50
  193. package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +19 -21
  194. package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
  195. package/.docs/raw/docs/tools/user-managed-mcp.mdx +337 -0
  196. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +11 -1
  197. package/.docs/raw/docs/ui/directive-text.mdx +3 -3
  198. package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
  199. package/.docs/raw/docs/ui/model-selector.mdx +8 -8
  200. package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
  201. package/.docs/raw/docs/ui/reasoning.mdx +4 -5
  202. package/.docs/raw/docs/ui/sources.mdx +17 -0
  203. package/.docs/raw/docs/ui/streamdown.mdx +34 -2
  204. package/.docs/raw/docs/ui/thread-list.mdx +2 -2
  205. package/.docs/raw/docs/ui/thread.mdx +2 -2
  206. package/.docs/raw/docs/ui/tool-group.mdx +5 -6
  207. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
  208. package/README.md +14 -72
  209. package/dist/constants.d.ts +12 -9
  210. package/dist/constants.d.ts.map +1 -1
  211. package/dist/constants.js +13 -9
  212. package/dist/constants.js.map +1 -1
  213. package/dist/index.d.ts +7 -3
  214. package/dist/index.d.ts.map +1 -1
  215. package/dist/index.js +25 -24
  216. package/dist/index.js.map +1 -1
  217. package/dist/prepare-docs/code-examples.d.ts +4 -1
  218. package/dist/prepare-docs/code-examples.d.ts.map +1 -1
  219. package/dist/prepare-docs/code-examples.js +109 -121
  220. package/dist/prepare-docs/code-examples.js.map +1 -1
  221. package/dist/prepare-docs/copy-raw.d.ts +4 -1
  222. package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
  223. package/dist/prepare-docs/copy-raw.js +45 -42
  224. package/dist/prepare-docs/copy-raw.js.map +1 -1
  225. package/dist/prepare-docs/prepare.d.ts +1 -2
  226. package/dist/prepare-docs/prepare.js +17 -17
  227. package/dist/prepare-docs/prepare.js.map +1 -1
  228. package/dist/stdio.d.ts +1 -3
  229. package/dist/stdio.js +6 -3
  230. package/dist/stdio.js.map +1 -1
  231. package/dist/tools/docs.d.ts +20 -15
  232. package/dist/tools/docs.d.ts.map +1 -1
  233. package/dist/tools/docs.js +140 -161
  234. package/dist/tools/docs.js.map +1 -1
  235. package/dist/tools/examples.d.ts +20 -15
  236. package/dist/tools/examples.d.ts.map +1 -1
  237. package/dist/tools/examples.js +74 -86
  238. package/dist/tools/examples.js.map +1 -1
  239. package/dist/tools/tests/test-setup.d.ts +5 -2
  240. package/dist/tools/tests/test-setup.d.ts.map +1 -1
  241. package/dist/tools/tests/test-setup.js +21 -28
  242. package/dist/tools/tests/test-setup.js.map +1 -1
  243. package/dist/utils/logger.d.ts +8 -5
  244. package/dist/utils/logger.d.ts.map +1 -1
  245. package/dist/utils/logger.js +17 -17
  246. package/dist/utils/logger.js.map +1 -1
  247. package/dist/utils/mcp-format.d.ts +8 -5
  248. package/dist/utils/mcp-format.d.ts.map +1 -1
  249. package/dist/utils/mcp-format.js +9 -9
  250. package/dist/utils/mcp-format.js.map +1 -1
  251. package/dist/utils/mdx.d.ts +8 -6
  252. package/dist/utils/mdx.d.ts.map +1 -1
  253. package/dist/utils/mdx.js +22 -22
  254. package/dist/utils/mdx.js.map +1 -1
  255. package/dist/utils/paths.d.ts +9 -6
  256. package/dist/utils/paths.d.ts.map +1 -1
  257. package/dist/utils/paths.js +66 -76
  258. package/dist/utils/paths.js.map +1 -1
  259. package/dist/utils/security.d.ts +4 -1
  260. package/dist/utils/security.d.ts.map +1 -1
  261. package/dist/utils/security.js +19 -40
  262. package/dist/utils/security.js.map +1 -1
  263. package/package.json +5 -5
  264. package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
  265. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
  266. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
  267. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +0 -41
  268. package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -40
  269. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -260
  270. package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -103
  271. package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -254
  272. package/.docs/raw/docs/guides/tool-ui.mdx +0 -858
  273. package/.docs/raw/docs/guides/tools.mdx +0 -675
  274. package/dist/prepare-docs/prepare.d.ts.map +0 -1
  275. package/dist/stdio.d.ts.map +0 -1
  276. /package/.docs/raw/docs/{(reference)/migrations → migrations}/deprecation-policy.mdx +0 -0
  277. /package/.docs/raw/docs/{(reference) → migrations}/react-compatibility.mdx +0 -0
  278. /package/.docs/raw/docs/{(reference)/migrations → migrations}/react-langgraph-v0-7.mdx +0 -0
  279. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-11.mdx +0 -0
  280. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-12.mdx +0 -0
  281. /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-14.mdx +0 -0
@@ -0,0 +1,967 @@
1
+ ---
2
+ title: Tool UI
3
+ description: Render AI tool calls as custom React components — show loading, result, and interactive states for each tool invocation in assistant-ui.
4
+ platforms: ["react"]
5
+ ---
6
+
7
+ import { ToolUISample } from "@/components/docs/samples/tool-ui";
8
+
9
+ Create custom UI components for AI tool calls, providing visual feedback and interactive experiences when tools are executed.
10
+
11
+ <ToolUISample />
12
+
13
+ ## Overview
14
+
15
+ Tool UIs in assistant-ui allow you to create custom interfaces that appear when AI tools are called. These generative UI components enhance the user experience by:
16
+
17
+ - **Visualizing tool execution** with loading states and progress indicators
18
+ - **Displaying results** in rich, formatted layouts
19
+ - **Enabling user interaction** through forms and controls
20
+ - **Providing error feedback** with helpful recovery options
21
+
22
+ This guide demonstrates building tool UIs with the **Vercel AI SDK**.
23
+
24
+ For composing UI from a JSON spec and component allowlist (display-only layouts),
25
+ see the [Generative UI primitive guide](/docs/tools/generative-ui).
26
+
27
+ ## Creating Tool UIs
28
+
29
+ Tool UI is registered on toolkit entries. The same entry can define a browser-executed frontend tool, a human tool that completes through `addResult`, or a render-only backend tool whose schema and execution live on the server.
30
+
31
+ ### 1. Client-Defined Tools
32
+
33
+ If you're creating tools on the client side, register them in a toolkit with `Tools({ toolkit })`.
34
+
35
+ ```tsx title="app/toolkit.tsx"
36
+ "use generative";
37
+
38
+ import { defineToolkit } from "@assistant-ui/react";
39
+ import { z } from "zod";
40
+
41
+ export default defineToolkit({
42
+ getWeather: {
43
+ description: "Get current weather for a location",
44
+ parameters: z.object({
45
+ location: z.string(),
46
+ unit: z.enum(["celsius", "fahrenheit"]),
47
+ }),
48
+ execute: async ({ location, unit }) => {
49
+ "use client";
50
+ return fetchWeatherAPI(location, unit);
51
+ },
52
+ render: ({ args, result, status }) => {
53
+ if (status.type === "running") {
54
+ return <div>Checking weather in {args.location}...</div>;
55
+ }
56
+
57
+ return (
58
+ <div className="weather-card">
59
+ <h3>{args.location}</h3>
60
+ <p>
61
+ {result.temperature}°{args.unit === "celsius" ? "C" : "F"}
62
+ </p>
63
+ <p>{result.description}</p>
64
+ </div>
65
+ );
66
+ },
67
+ },
68
+ });
69
+ ```
70
+
71
+ ```tsx title="app/MyRuntimeProvider.tsx"
72
+ import { AssistantRuntimeProvider, Tools, useAui } from "@assistant-ui/react";
73
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
74
+ import toolkit from "./toolkit";
75
+
76
+ function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
77
+ const runtime = useChatRuntime({ api: "/api/chat" });
78
+ const aui = useAui({ tools: Tools({ toolkit }) });
79
+ return (
80
+ <AssistantRuntimeProvider aui={aui} runtime={runtime}>
81
+ {children}
82
+ </AssistantRuntimeProvider>
83
+ );
84
+ }
85
+ ```
86
+
87
+ <Callout type="tip">
88
+ Frontend toolkit entries can be passed to your backend using the
89
+ `frontendTools` utility.
90
+ </Callout>
91
+
92
+ Learn more about creating tools in the [Tools Guide](/docs/tools/defining-tools).
93
+
94
+ ### 2. UI-Only for Existing Tools
95
+
96
+ If your tool is defined elsewhere (e.g., in your backend API, MCP server, or LangGraph), register a backend toolkit entry with just `render`:
97
+
98
+ ```tsx
99
+ const toolkit = {
100
+ getWeather: {
101
+ type: "backend",
102
+ render: ({ args, result, status }) => {
103
+ // UI rendering logic only
104
+ },
105
+ },
106
+ } satisfies Toolkit;
107
+ ```
108
+
109
+ ## Quick Start Example
110
+
111
+ This example shows how to implement the UI-only approach with a backend toolkit entry:
112
+
113
+ <Steps>
114
+ <Step>
115
+
116
+ ### Create a Tool UI Renderer
117
+
118
+ ```tsx
119
+ import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
120
+ import { z } from "zod";
121
+
122
+ type WeatherArgs = {
123
+ location: string;
124
+ unit: "celsius" | "fahrenheit";
125
+ };
126
+
127
+ type WeatherResult = {
128
+ temperature: number;
129
+ description: string;
130
+ humidity: number;
131
+ windSpeed: number;
132
+ };
133
+
134
+ const WeatherToolUI: ToolCallMessagePartComponent<
135
+ WeatherArgs,
136
+ WeatherResult
137
+ > = ({ args, status, result }) => {
138
+ if (status.type === "running") {
139
+ return (
140
+ <div className="flex items-center gap-2">
141
+ <Spinner />
142
+ <span>Checking weather in {args.location}...</span>
143
+ </div>
144
+ );
145
+ }
146
+
147
+ if (status.type === "incomplete" && status.reason === "error") {
148
+ return (
149
+ <div className="text-red-500">
150
+ Failed to get weather for {args.location}
151
+ </div>
152
+ );
153
+ }
154
+
155
+ return (
156
+ <div className="weather-card rounded-lg bg-blue-50 p-4">
157
+ <h3 className="text-lg font-bold">{args.location}</h3>
158
+ <div className="mt-2 grid grid-cols-2 gap-4">
159
+ <div>
160
+ <p className="text-2xl">
161
+ {result.temperature}°{args.unit === "celsius" ? "C" : "F"}
162
+ </p>
163
+ <p className="text-gray-600">{result.description}</p>
164
+ </div>
165
+ <div className="text-sm">
166
+ <p>Humidity: {result.humidity}%</p>
167
+ <p>Wind: {result.windSpeed} km/h</p>
168
+ </div>
169
+ </div>
170
+ </div>
171
+ );
172
+ };
173
+ ```
174
+
175
+ </Step>
176
+ <Step>
177
+
178
+ ### Register the Tool UI
179
+
180
+ Put the renderer on the matching backend toolkit entry:
181
+
182
+ ```tsx
183
+ const toolkit = {
184
+ getWeather: {
185
+ type: "backend",
186
+ render: WeatherToolUI,
187
+ },
188
+ } satisfies Toolkit;
189
+
190
+ function App({ runtime }: { runtime: AssistantRuntime }) {
191
+ const aui = useAui({ tools: Tools({ toolkit }) });
192
+
193
+ return (
194
+ <AssistantRuntimeProvider aui={aui} runtime={runtime}>
195
+ <Thread />
196
+ </AssistantRuntimeProvider>
197
+ );
198
+ }
199
+ ```
200
+
201
+ </Step>
202
+ <Step>
203
+
204
+ ### Define the Backend Tool (Vercel AI SDK)
205
+
206
+ When using the Vercel AI SDK, define the corresponding tool in your API route:
207
+
208
+ ```tsx title="/app/api/chat/route.ts"
209
+ import { streamText, tool, zodSchema } from "ai";
210
+ import { z } from "zod";
211
+
212
+ export async function POST(req: Request) {
213
+ const { messages } = await req.json();
214
+
215
+ const result = streamText({
216
+ model: openai("gpt-5.4-nano"),
217
+ messages: await convertToModelMessages(messages),
218
+ tools: {
219
+ getWeather: tool({
220
+ description: "Get current weather for a location",
221
+ inputSchema: zodSchema(
222
+ z.object({
223
+ location: z.string(),
224
+ unit: z.enum(["celsius", "fahrenheit"]),
225
+ }),
226
+ ),
227
+ execute: async ({ location, unit }) => {
228
+ const weather = await fetchWeatherAPI(location);
229
+ return {
230
+ temperature: weather.temp,
231
+ description: weather.condition,
232
+ humidity: weather.humidity,
233
+ windSpeed: weather.wind,
234
+ };
235
+ },
236
+ }),
237
+ },
238
+ });
239
+
240
+ return result.toUIMessageStreamResponse();
241
+ }
242
+ ```
243
+
244
+ </Step>
245
+ </Steps>
246
+
247
+ ## Tool UI Patterns
248
+
249
+ ### Component Pattern
250
+
251
+ Create standalone tool UI components:
252
+
253
+ ```tsx
254
+ import type { ToolCallMessagePartComponent } from "@assistant-ui/react";
255
+
256
+ export const WebSearchToolUI: ToolCallMessagePartComponent<
257
+ { query: string },
258
+ { results: SearchResult[] }
259
+ > = ({ args, status, result }) => {
260
+ return (
261
+ <div className="search-container">
262
+ <div className="mb-3 flex items-center gap-2">
263
+ <SearchIcon />
264
+ <span>Search results for: "{args.query}"</span>
265
+ </div>
266
+
267
+ {status.type === "running" && <LoadingSpinner />}
268
+
269
+ {result && (
270
+ <div className="space-y-2">
271
+ {result.results.map((item, index) => (
272
+ <div key={index} className="rounded border p-3">
273
+ <a href={item.url} className="font-medium text-blue-600">
274
+ {item.title}
275
+ </a>
276
+ <p className="text-sm text-gray-600">{item.snippet}</p>
277
+ </div>
278
+ ))}
279
+ </div>
280
+ )}
281
+ </div>
282
+ );
283
+ };
284
+ ```
285
+
286
+ Register it on the toolkit:
287
+
288
+ ```tsx
289
+ const toolkit = {
290
+ webSearch: {
291
+ type: "backend",
292
+ render: WebSearchToolUI,
293
+ },
294
+ } satisfies Toolkit;
295
+ ```
296
+
297
+ ### Dynamic Toolkit Pattern
298
+
299
+ Use a toolkit hook in its own file when the renderer needs component state:
300
+
301
+ ```tsx title="analyze-data-toolkit.tsx"
302
+ "use client";
303
+
304
+ import { type Toolkit, useInlineRender } from "@assistant-ui/react";
305
+ import { useMemo } from "react";
306
+
307
+ export function useAnalyzeDataToolkit(theme: "light" | "dark") {
308
+ const renderAnalyzeData = useInlineRender(({ result, status }) => {
309
+ return (
310
+ <DataVisualization
311
+ data={result}
312
+ theme={theme}
313
+ loading={status.type === "running"}
314
+ />
315
+ );
316
+ });
317
+
318
+ return useMemo(
319
+ () =>
320
+ ({
321
+ analyzeData: {
322
+ type: "backend",
323
+ render: renderAnalyzeData,
324
+ },
325
+ }) satisfies Toolkit,
326
+ [renderAnalyzeData],
327
+ );
328
+ }
329
+ ```
330
+
331
+ ```tsx title="DynamicToolUI.tsx"
332
+ import { AuiProvider, Tools, useAui } from "@assistant-ui/react";
333
+ import { useState } from "react";
334
+ import { useAnalyzeDataToolkit } from "./analyze-data-toolkit";
335
+
336
+ function DynamicToolUI({ children }: { children: React.ReactNode }) {
337
+ const [theme] = useState<"light" | "dark">("light");
338
+ const toolkit = useAnalyzeDataToolkit(theme);
339
+
340
+ const aui = useAui({
341
+ tools: Tools({ toolkit }),
342
+ });
343
+
344
+ return <AuiProvider value={aui}>{children}</AuiProvider>;
345
+ }
346
+ ```
347
+
348
+ ### Inline Pattern
349
+
350
+ For tools that need access to parent component props:
351
+
352
+ <Callout type="tip">
353
+ **Why `useInlineRender`?** By default, a tool UI's `render` function is
354
+ static. Use `useInlineRender` when your UI needs access to dynamic component
355
+ props (for example, to pass in an `id` or other contextual data).
356
+ </Callout>
357
+
358
+ ```tsx title="inventory-toolkit.tsx"
359
+ "use client";
360
+
361
+ import { type Toolkit, useInlineRender } from "@assistant-ui/react";
362
+ import { useMemo } from "react";
363
+
364
+ export function useInventoryToolkit(productId: string, productName: string) {
365
+ const renderInventory = useInlineRender(({ result }) => {
366
+ return (
367
+ <div className="inventory-status">
368
+ <h4>{productName} Inventory</h4>
369
+ <p>
370
+ Stock for {productId}: {result.quantity} units
371
+ </p>
372
+ <p>Location: {result.warehouse}</p>
373
+ </div>
374
+ );
375
+ });
376
+
377
+ return useMemo(
378
+ () =>
379
+ ({
380
+ checkInventory: {
381
+ type: "backend",
382
+ render: renderInventory,
383
+ },
384
+ }) satisfies Toolkit,
385
+ [renderInventory],
386
+ );
387
+ }
388
+ ```
389
+
390
+ ```tsx title="ProductPage.tsx"
391
+ import { AuiProvider, Tools, useAui } from "@assistant-ui/react";
392
+ import { useInventoryToolkit } from "./inventory-toolkit";
393
+
394
+ function ProductPage({ productId, productName }) {
395
+ const toolkit = useInventoryToolkit(productId, productName);
396
+
397
+ const aui = useAui({
398
+ tools: Tools({ toolkit }),
399
+ });
400
+
401
+ return (
402
+ <AuiProvider value={aui}>
403
+ <div>Product details...</div>
404
+ </AuiProvider>
405
+ );
406
+ }
407
+ ```
408
+
409
+ ## Interactive Tool UIs
410
+
411
+ ### User Input Collection
412
+
413
+ Create tools that collect user input during execution:
414
+
415
+ <Callout type="tip">
416
+ **Pro tip:** Call `addResult(...)` exactly once to complete the tool call.
417
+ After it's invoked, the assistant will resume the conversation with your
418
+ provided data.
419
+ </Callout>
420
+
421
+ ```tsx
422
+ const toolkit = {
423
+ selectDate: {
424
+ type: "human",
425
+ description: "Ask the user to select a date.",
426
+ parameters: z.object({ prompt: z.string() }),
427
+ render: ({ args, result, addResult }) => {
428
+ if (result) {
429
+ return (
430
+ <div className="rounded bg-green-50 p-3">
431
+ ✅ Selected date: {new Date(result.date).toLocaleDateString()}
432
+ </div>
433
+ );
434
+ }
435
+
436
+ return (
437
+ <div className="rounded border p-4">
438
+ <p className="mb-3">{args.prompt}</p>
439
+ <DatePicker
440
+ onChange={(date) => {
441
+ addResult({ date: date.toISOString() });
442
+ }}
443
+ />
444
+ </div>
445
+ );
446
+ },
447
+ },
448
+ } satisfies Toolkit;
449
+ ```
450
+
451
+ ### Multi-Step Interactions
452
+
453
+ Build complex workflows with human-in-the-loop patterns for multi-step user interactions:
454
+
455
+ ```tsx title="app/approval-toolkit.tsx"
456
+ "use generative";
457
+
458
+ import { defineToolkit } from "@assistant-ui/react";
459
+ import { z } from "zod";
460
+
461
+ export default defineToolkit({
462
+ requestApproval: {
463
+ description: "Request user approval for an action",
464
+ parameters: z.object({
465
+ action: z.string(),
466
+ details: z.any(),
467
+ }),
468
+ execute: async ({ action, details }, { human }) => {
469
+ "use client";
470
+ // Request approval from user
471
+ const response = await human({ action, details });
472
+
473
+ return {
474
+ approved: response.approved,
475
+ reason: response.reason,
476
+ };
477
+ },
478
+ render: ({ args, result, interrupt, resume }) => {
479
+ const [reason, setReason] = useState("");
480
+
481
+ // Show result after approval/rejection
482
+ if (result) {
483
+ return (
484
+ <div className={result.approved ? "text-green-600" : "text-red-600"}>
485
+ {result.approved ? "✅ Approved" : `❌ Rejected: ${result.reason}`}
486
+ </div>
487
+ );
488
+ }
489
+
490
+ // Show approval UI when waiting for user input
491
+ if (interrupt) {
492
+ return (
493
+ <div className="rounded border-2 border-yellow-400 p-4">
494
+ <h4 className="font-bold">Approval Required</h4>
495
+ <p className="my-2">{interrupt.payload.action}</p>
496
+ <pre className="rounded bg-gray-100 p-2 text-sm">
497
+ {JSON.stringify(interrupt.payload.details, null, 2)}
498
+ </pre>
499
+
500
+ <div className="mt-4 flex gap-2">
501
+ <button
502
+ onClick={() => resume({ approved: true })}
503
+ className="rounded bg-green-500 px-4 py-2 text-white"
504
+ >
505
+ Approve
506
+ </button>
507
+ <button
508
+ onClick={() => resume({ approved: false, reason })}
509
+ className="rounded bg-red-500 px-4 py-2 text-white"
510
+ >
511
+ Reject
512
+ </button>
513
+ <input
514
+ type="text"
515
+ placeholder="Rejection reason..."
516
+ value={reason}
517
+ onChange={(e) => setReason(e.target.value)}
518
+ className="flex-1 rounded border px-2"
519
+ />
520
+ </div>
521
+ </div>
522
+ );
523
+ }
524
+
525
+ return <div>Processing...</div>;
526
+ },
527
+ },
528
+ });
529
+ ```
530
+
531
+ <Callout type="tip">
532
+ Use tool human input (`human()` / `resume()`) for workflows that need to
533
+ pause tool execution and wait for user input. Use `addResult()` for "human
534
+ tools" where the AI requests a tool call but the entire execution happens
535
+ through user interaction.
536
+ </Callout>
537
+
538
+ ### Server-side approval gates
539
+
540
+ Some runtimes (notably AI SDK v6's `needsApproval` tools) pause on the server and emit an approval request that the client must acknowledge before the tool runs. assistant-ui surfaces this on the tool part as `approval` and exposes `respondToApproval({ approved, reason? })` on the renderer:
541
+
542
+ ```tsx
543
+ const toolkit = {
544
+ deploy: {
545
+ type: "backend",
546
+ render: ({ args, approval, respondToApproval, result }) => {
547
+ if (approval?.approved === undefined) {
548
+ return (
549
+ <div>
550
+ <p>Approve deploy to {args.target}?</p>
551
+ <button onClick={() => respondToApproval({ approved: true })}>
552
+ Approve
553
+ </button>
554
+ <button
555
+ onClick={() =>
556
+ respondToApproval({ approved: false, reason: "user denied" })
557
+ }
558
+ >
559
+ Deny
560
+ </button>
561
+ </div>
562
+ );
563
+ }
564
+
565
+ if (approval?.approved === false) {
566
+ return <p>Denied{approval.reason ? `: ${approval.reason}` : ""}</p>;
567
+ }
568
+
569
+ if (result === undefined) return <p>Approved, running…</p>;
570
+ return <p>Deployed</p>;
571
+ },
572
+ },
573
+ } satisfies Toolkit;
574
+ ```
575
+
576
+ `approval.approved` is a three-state signal:
577
+
578
+ - `undefined`: gate is open, the renderer should ask the user. This is the only state in which `respondToApproval` is legal.
579
+ - `true`: decision recorded as allow. The server is producing the result (or has produced one, available on `result`).
580
+ - `false`: decision recorded as deny. `output-denied` from the runtime sets `isError` and exposes `approval.reason`.
581
+
582
+ `approval.isAutomatic` is `true` when the runtime granted the decision from a server-side policy rather than the user; render a "auto-approved" badge instead of buttons in that case.
583
+
584
+ For the wire-side setup (`needsApproval`, `sendAutomaticallyWhen`), see [AI SDK v6 server-side tool approval](/docs/runtimes/ai-sdk/v6#server-side-tool-approval).
585
+
586
+ ## Advanced Features
587
+
588
+ ### Tool Status Handling
589
+
590
+ The `status` prop provides detailed execution state:
591
+
592
+ ```tsx
593
+ render: ({ status, args }) => {
594
+ switch (status.type) {
595
+ case "running":
596
+ return <LoadingState />;
597
+
598
+ case "requires-action":
599
+ return <UserInputRequired reason={status.reason} />;
600
+
601
+ case "incomplete":
602
+ if (status.reason === "cancelled") {
603
+ return <div>Operation cancelled</div>;
604
+ }
605
+ if (status.reason === "error") {
606
+ return <ErrorDisplay error={status.error} />;
607
+ }
608
+ return <div>Failed: {status.reason}</div>;
609
+
610
+ case "complete":
611
+ return <SuccessDisplay />;
612
+ }
613
+ };
614
+ ```
615
+
616
+ ### Deferred Rendering
617
+
618
+ <Callout type="info">
619
+ This section applies when the model **drives** the component through a tool call (args arrive incrementally and you want to wait for the final shape). If your backend or orchestrator pushes the component instead, prefer [Data-Part Generative UI](#data-part-generative-ui) with `makeAssistantDataUI`. Data parts arrive as terminal events, so the renderer only fires once with the final data, no deferred rendering needed.
620
+ </Callout>
621
+
622
+ Sometimes you want to capture a tool call's streaming arguments but only render the final UI once the call completes. This is useful when partial args would render misleading or jarring intermediate states (a chart that flashes through half-populated data), when the component is expensive to mount (heavy visualizations, embedded iframes, third-party widgets), or when the model controls *whether* the component appears at all.
623
+
624
+ #### Inline at the end of streaming
625
+
626
+ Return `null` from the tool UI's `render` until `status.type === "complete"`. The streaming args still arrive in `args` as the model emits them, you just ignore them until the call is done:
627
+
628
+ ```tsx
629
+ const toolkit = {
630
+ renderChart: {
631
+ type: "backend",
632
+ render: ({ args, status }) => {
633
+ if (status.type !== "complete") return null;
634
+ return <Chart title={args.title} data={args.series} />;
635
+ },
636
+ },
637
+ } satisfies Toolkit;
638
+ ```
639
+
640
+ The chart mounts once, with the final args, after streaming finishes. No re-renders during the stream.
641
+
642
+ The same `render` shape works inside the [`Tools()`](/docs/tools/defining-tools) toolkit's `render` field and with `MessagePrimitive.Parts`'s inline `tools.by_name` overrides.
643
+
644
+ #### Below the message body
645
+
646
+ If the component should sit *outside* the message parts (for example, a card attached under the avatar block rather than inline with text), gate at the message level with [`AuiIf`](/docs/api-reference/primitives/assistant-if) and read `s.message.status`:
647
+
648
+ ```tsx
649
+ import { MessagePrimitive, AuiIf, useAuiState } from "@assistant-ui/react";
650
+
651
+ function PostMessageCard() {
652
+ const parts = useAuiState((s) => s.message.parts);
653
+ const chartCall = parts.find(
654
+ (p) => p.type === "tool-call" && p.toolName === "renderChart",
655
+ );
656
+ if (!chartCall) return null;
657
+ return <Chart {...chartCall.args} />;
658
+ }
659
+
660
+ <MessagePrimitive.Root>
661
+ <MessagePrimitive.Parts />
662
+
663
+ <AuiIf
664
+ condition={(s) =>
665
+ s.message.role === "assistant" &&
666
+ s.message.status?.type === "complete"
667
+ }
668
+ >
669
+ <PostMessageCard />
670
+ </AuiIf>
671
+ </MessagePrimitive.Root>;
672
+ ```
673
+
674
+ The `AuiIf` predicate fires whenever the assistant state changes; children mount only when both checks pass. `PostMessageCard` then reads the captured tool-call part from `s.message.parts` and renders from its args.
675
+
676
+ For the opposite pattern (showing partial data as it streams in), see [Field-Level Streaming State](#field-level-streaming-state) and [Partial Results & Streaming](#partial-results--streaming) below.
677
+
678
+ ### Field-Level Streaming State
679
+
680
+ Use `useToolArgsStatus` to react to per-field streaming state. The hook returns a `propStatus` map where each top-level key in the args object resolves from `"streaming"` to `"complete"` as the partial JSON arrives. Call it inside a tool-call message part context:
681
+
682
+ ```tsx
683
+ import { useToolArgsStatus } from "@assistant-ui/react";
684
+
685
+ const toolkit = {
686
+ submitForm: {
687
+ type: "backend",
688
+ render: ({ args }) => {
689
+ const { propStatus } = useToolArgsStatus<{
690
+ email: string;
691
+ phone: string;
692
+ }>();
693
+
694
+ return (
695
+ <form className="space-y-4">
696
+ <div>
697
+ <input
698
+ type="email"
699
+ value={args.email ?? ""}
700
+ className={propStatus.email === "streaming" ? "loading" : ""}
701
+ disabled
702
+ />
703
+ </div>
704
+
705
+ <div>
706
+ <input
707
+ type="tel"
708
+ value={args.phone ?? ""}
709
+ className={propStatus.phone === "streaming" ? "loading" : ""}
710
+ disabled
711
+ />
712
+ </div>
713
+ </form>
714
+ );
715
+ },
716
+ },
717
+ } satisfies Toolkit;
718
+ ```
719
+
720
+ ### Partial Results & Streaming
721
+
722
+ Display results as they stream in:
723
+
724
+ ```tsx
725
+ const toolkit = {
726
+ analyzeData: {
727
+ type: "backend",
728
+ render: ({ result, status }) => {
729
+ const progress = result?.progress || 0;
730
+ const insights = result?.insights || [];
731
+
732
+ return (
733
+ <div className="analysis-container">
734
+ {status.type === "running" && (
735
+ <div className="mb-4">
736
+ <div className="mb-1 flex justify-between">
737
+ <span>Analyzing...</span>
738
+ <span>{progress}%</span>
739
+ </div>
740
+ <div className="w-full rounded bg-gray-200">
741
+ <div
742
+ className="h-2 rounded bg-blue-500"
743
+ style={{ width: `${progress}%` }}
744
+ />
745
+ </div>
746
+ </div>
747
+ )}
748
+
749
+ <div className="space-y-2">
750
+ {insights.map((insight, i) => (
751
+ <div key={i} className="rounded bg-gray-50 p-2">
752
+ {insight}
753
+ </div>
754
+ ))}
755
+ </div>
756
+ </div>
757
+ );
758
+ },
759
+ },
760
+ } satisfies Toolkit;
761
+ ```
762
+
763
+ ### Custom Tool Fallback
764
+
765
+ For tools that have no dedicated UI, add the `ToolFallback` shadcn component to your project. See the [ToolFallback install guide](/docs/ui/tool-fallback) for setup instructions and the [ToolGroup guide](/docs/ui/tool-group) for grouping consecutive tool calls into a collapsible container.
766
+
767
+ ## Execution Context
768
+
769
+ Generative UI components have access to execution context through props:
770
+
771
+ ```tsx
772
+ type ToolCallMessagePartProps<TArgs, TResult> = {
773
+ // Tool arguments
774
+ args: TArgs;
775
+ argsText: string; // JSON stringified args
776
+
777
+ // Execution status
778
+ status: ToolCallMessagePartStatus;
779
+ isError?: boolean;
780
+
781
+ // Tool result (may be partial during streaming)
782
+ result?: TResult;
783
+
784
+ // Tool metadata
785
+ toolName: string;
786
+ toolCallId: string;
787
+
788
+ // Interactive callbacks
789
+ addResult: (result: TResult | ToolResponse<TResult>) => void;
790
+ resume: (payload: unknown) => void;
791
+
792
+ // Interrupt state
793
+ interrupt?: { type: "human"; payload: unknown }; // Payload from context.human()
794
+
795
+ // Optional artifact data
796
+ artifact?: unknown;
797
+ };
798
+ ```
799
+
800
+ ### Human Input Handling
801
+
802
+ When a tool calls `human()` during execution, the payload becomes available in the render function as `interrupt.payload`:
803
+
804
+ ```tsx
805
+ const toolkit = {
806
+ confirmAction: {
807
+ type: "backend",
808
+ render: ({ args, result, interrupt, resume }) => {
809
+ // Tool is waiting for user input
810
+ if (interrupt) {
811
+ return (
812
+ <div className="confirmation-dialog">
813
+ <p>Confirm: {interrupt.payload.message}</p>
814
+ <button onClick={() => resume(true)}>Yes</button>
815
+ <button onClick={() => resume(false)}>No</button>
816
+ </div>
817
+ );
818
+ }
819
+
820
+ // Tool completed
821
+ if (result) {
822
+ return <div>Action {result.confirmed ? "confirmed" : "cancelled"}</div>;
823
+ }
824
+
825
+ return <div>Processing...</div>;
826
+ },
827
+ },
828
+ } satisfies Toolkit;
829
+ ```
830
+
831
+ Learn more about tool human input in the [Tools Guide](/docs/tools/defining-tools#human-tools).
832
+
833
+ ## Best Practices
834
+
835
+ ### 1. Handle All Status States
836
+
837
+ Always handle loading, error, and success states:
838
+
839
+ ```tsx
840
+ render: ({ status, result, args }) => {
841
+ if (status.type === "running") return <Skeleton />;
842
+ if (status.type === "incomplete") return <ErrorState />;
843
+ if (!result) return null;
844
+ return <ResultDisplay result={result} />;
845
+ };
846
+ ```
847
+
848
+ ### 2. Provide Visual Feedback
849
+
850
+ Use animations and transitions for better UX:
851
+
852
+ ```tsx
853
+ <div
854
+ className={cn(
855
+ "transition-all duration-300",
856
+ status.type === "running" && "opacity-50",
857
+ status.type === "complete" && "opacity-100",
858
+ )}
859
+ >
860
+ {/* Tool UI content */}
861
+ </div>
862
+ ```
863
+
864
+ ### 3. Make UIs Accessible
865
+
866
+ Ensure keyboard navigation and screen reader support:
867
+
868
+ ```tsx
869
+ <button
870
+ onClick={() => addResult(value)}
871
+ aria-label="Confirm selection"
872
+ className="focus:outline-none focus:ring-2"
873
+ >
874
+ Confirm
875
+ </button>
876
+ ```
877
+
878
+ ### 4. Optimize Performance
879
+
880
+ Use `useInlineRender` to prevent unnecessary re-renders:
881
+
882
+ ```tsx title="heavy-computation-toolkit.tsx"
883
+ "use client";
884
+
885
+ import { type Toolkit, useInlineRender } from "@assistant-ui/react";
886
+ import { useMemo } from "react";
887
+
888
+ export function useHeavyComputationToolkit() {
889
+ const renderHeavyComputation = useInlineRender(({ result }) => {
890
+ return <ComplexVisualization data={result} />;
891
+ });
892
+
893
+ return useMemo(
894
+ () =>
895
+ ({
896
+ heavyComputation: {
897
+ type: "backend",
898
+ render: renderHeavyComputation,
899
+ },
900
+ }) satisfies Toolkit,
901
+ [renderHeavyComputation],
902
+ );
903
+ }
904
+ ```
905
+
906
+ ```tsx title="HeavyComputationToolProvider.tsx"
907
+ import { AuiProvider, Tools, useAui } from "@assistant-ui/react";
908
+ import type { ReactNode } from "react";
909
+ import { useHeavyComputationToolkit } from "./heavy-computation-toolkit";
910
+
911
+ function HeavyComputationToolProvider({ children }: { children: ReactNode }) {
912
+ const toolkit = useHeavyComputationToolkit();
913
+ const aui = useAui({ tools: Tools({ toolkit }) });
914
+
915
+ return <AuiProvider value={aui}>{children}</AuiProvider>;
916
+ }
917
+ ```
918
+
919
+ <Callout>
920
+ Generative UI components are only displayed in the chat interface. The actual
921
+ tool execution happens on the backend. This separation allows you to create
922
+ rich, interactive experiences while keeping sensitive logic secure on the
923
+ server.
924
+ </Callout>
925
+
926
+ ## Data-Part Generative UI
927
+
928
+ Alongside tool-call rendering, assistant-ui supports a second generative UI mechanism based on `DataMessagePart`. Instead of attaching UI to a tool invocation, the backend (or the LangGraph graph) emits named data events that are appended as `{ type: "data", name, data }` parts on the parent assistant message.
929
+
930
+ **When to choose which:**
931
+
932
+ - **Tool UI**: the **model** decides what to render by calling a tool whose args become the component's data. Register the renderer via the [`Tools()`](/docs/tools/defining-tools) toolkit's `render` field. Args stream incrementally, so you observe partial state via `status` / `useToolArgsStatus` and may need [Deferred Rendering](#deferred-rendering) for components that should only mount with final data.
933
+ - **Data UI** (`makeAssistantDataUI`): the **backend or orchestrator** decides what to render and pushes a named data event onto the assistant message. Data parts arrive as terminal events with no streaming partials, so the renderer naturally fires once with the final data.
934
+
935
+ If you want a component to appear only after the message is complete and you control the backend, Data UI is usually the more direct fit; reach for Tool UI's deferred pattern when the model itself must drive the choice.
936
+
937
+ Use `makeAssistantDataUI` to register a renderer for a named data part:
938
+
939
+ ```tsx
940
+ import { makeAssistantDataUI } from "@assistant-ui/react";
941
+
942
+ type ChartProps = { series: number[]; title: string };
943
+
944
+ export const ChartUI = makeAssistantDataUI<ChartProps>({
945
+ name: "chart",
946
+ render: ({ data }) => (
947
+ <div>
948
+ <h3>{data.title}</h3>
949
+ <Chart series={data.series} />
950
+ </div>
951
+ ),
952
+ });
953
+ ```
954
+
955
+ Mount `<ChartUI />` once inside the `AssistantRuntimeProvider` tree; it renders nothing itself and only registers the renderer.
956
+
957
+ For LangGraph-specific patterns (emitting UI from a Python/TypeScript graph node via `push_ui_message` / `typedUi`, dynamic loading with `LoadExternalComponent`, and the `useLangGraphUIMessages` escape hatch), see [LangGraph Generative UI](/docs/runtimes/langgraph/generative-ui).
958
+
959
+ A fallback renderer for unmatched data parts is available internally but `setFallbackDataUI` is not yet a public API.
960
+
961
+ ## Related Guides
962
+
963
+ - [Tools Guide](/docs/tools/defining-tools) - Learn how to create and use tools with AI models
964
+ - [Multi-Agent](/docs/tools/multi-agent) - Render sub-agent conversations inside tool call UIs
965
+ - [Tool Fallback](/docs/ui/tool-fallback) - Default UI for tools without custom components
966
+ - [API Reference](/docs/api-reference/primitives/message-part) - Detailed type definitions and component APIs
967
+ - [Message Primitive](/docs/api-reference/primitives/message) - Complete Message component documentation