ToolFallback

Default UI component for tools without dedicated custom renderers.

Getting Started

Add tool-fallback

npx shadcn@latest add @assistant-ui/tool-fallback

The @assistant-uinamespace resolves the Radix or Base UI flavor from your project's style through the style-aware registry entry in components.json. Without that entry, add by direct URL instead:

npx shadcn@latest add https://r.assistant-ui.com/base/tool-fallback.json

This adds a /components/assistant-ui/tool-fallback.tsx file to your project, which you can adjust as needed.

Use it in your application

Pass the ToolFallback component to the MessagePrimitive.Parts component

/components/assistant-ui/thread.tsx
import { ToolFallback } from "@/components/assistant-ui/tool-fallback";

const AssistantMessage = () => {
  return (
    <MessagePrimitive.Root>
      <MessagePrimitive.Parts>
        {({ part }) => {
          if (part.type === "tool-call") return <ToolFallback {...part} />;
          return null;
        }}
      </MessagePrimitive.Parts>
    </MessagePrimitive.Root>
  );
};

Examples

Streaming Demo

Interactive demo showing the full tool call lifecycle: running → complete.

Running State

Shows a loading spinner and shimmer animation while the tool is executing.

Cancelled State

Shows a muted appearance when a tool call was cancelled.

Approval State

Shows the default Allow / Deny buttons rendered when a tool call enters requires-action. A tool call whose approval gate is already decided renders no buttons. The block auto-expands so the decision is visible without a click. Edit your project's copy of tool-fallback.tsx to add trust escalation, edit-args, custom labels, or analytics hooks — the shadcn philosophy is you own the file.

{
  "path": "/tmp/work-in-progress.txt"
}

Composable API

All sub-components are exported for custom layouts:

ComponentDescription
ToolFallback.RootCollapsible container with scroll lock
ToolFallback.TriggerHeader with tool name, status icon, and shimmer
ToolFallback.ContentAnimated collapsible content wrapper
ToolFallback.ArgsDisplays tool arguments
ToolFallback.ResultDisplays tool execution result
ToolFallback.ErrorDisplays error or cancellation messages
ToolFallback.ApprovalRenders Allow / Deny buttons for requires-action tools until a decision is recorded; wires resume / addResult / respondToApproval
import {
  ToolFallback,
  ToolFallbackRoot,
  ToolFallbackTrigger,
  ToolFallbackContent,
  ToolFallbackArgs,
  ToolFallbackResult,
  ToolFallbackError,
  ToolFallbackApproval,
} from "@/components/assistant-ui/tool-fallback";

// Compound component syntax
<ToolFallback.Root>
  <ToolFallback.Trigger toolName="get_weather" status={status} />
  <ToolFallback.Content>
    <ToolFallback.Error status={status} />
    <ToolFallback.Args argsText={argsText} />
    <ToolFallback.Approval
      addResult={addResult}
      resume={resume}
      interrupt={interrupt}
      approval={approval}
      respondToApproval={respondToApproval}
    />
    <ToolFallback.Result result={result} />
  </ToolFallback.Content>
</ToolFallback.Root>
  • ToolGroup - Group consecutive tool calls together