Tool Approval
Human-in-the-loop prompt that asks the user to approve or reject a tool call.
ToolApproval ships with a full API table, a copyable example, and accessibility notes.
Approve tool call: send_email?
Review the requested arguments before allowing this action.
{
"to": "[email protected]",
"subject": "Weekly summary"
}Installation
Install the package once, then import ToolApproval from its direct entry point or from the root.
pnpm add @agent-ui/reactimport { ToolApproval } from "@agent-ui/react";Tailwind CSS v4 users: add @source "../node_modules/@agent-ui/react/src" to the global stylesheet so the library utilities are generated.
Usage
The example below is the same code that renders the preview. Copy it, swap in your own handlers, and ship.
import { ToolApproval } from "@agent-ui/react"; <ToolApproval toolName="send_email" args={{ to: "[email protected]" }} onApprove={approve} onReject={reject}/>API reference
Every prop ToolApproval accepts, its type, default, and behaviour.
| Name | Type | Default | Description |
|---|---|---|---|
| toolName | string | — | Tool awaiting approval. |
| args | Record<string, unknown> | — | Arguments rendered as JSON. |
| onApprove | () => void | — | Approve handler. |
| onReject | () => void | — | Reject handler. |
| className | string | — | Merged onto the panel. |
ToolApproval composes with MessageList, ChatShell, useChat, and the provider compose blocks. Browse the full reference or see all components in the gallery.
8 lines · copy-ready