Tool call

Shows a tool the agent called, with its arguments, status and result. Use it inside a reply wherever the agent acts.

Loading preview…

Install

  1. 1

    Run this command in your Tailwind CSS project. It adds components/ai/tool-call-card.tsx and installs its dependencies.

    $ npx shadcn@latest add https://gradientdeck.com/ai-components/r/tool-call-card.json

Build an AI agent tool approval flow in React →

Usage & API

Example

tool-call-card.tsx
import { ToolCallCard } from "@/components/ai/tool-call-card"

<ToolCallCard
  name="…"
  summary="…"
  status={status}
  input={input}
/>

Props ToolCallCard

PropType & descriptionRequired
namestringRequired
summarystringShort, human summary of the arguments, e.g. a path or a query.Required
statusToolCallStatusRequired
inputRecord<string, unknown>Required
outputstringOptional
durationnumberSeconds, shown once the call has finished.Optional
serverstringThe server or integration the tool belongs to, e.g. "postgres".Optional
iconComponentType<{ className?: string }>Optional
defaultOpenbooleanOptional

Dependencies

  • React
  • Tailwind CSS
  • motion
  • lucide-react
Implementation notes

The header button shows an icon, then server and the tool name when server is set, then summary in a truncated monospace span, then the status. pending reads Waiting. running shows a spinner and the word Running. error reads Failed. done shows duration to one decimal place, or the word Done when duration is omitted. Opening the header reveals Request, which pretty-prints input, and Response. output is shown only when status is done or error. A running call says it is waiting for a response, and a pending call says it has not been sent yet. defaultOpen starts the body expanded. The icon defaults to a search mark.

Choosing a layout

Place it in the reply at the moment the agent acts, not in a side panel the message then has to point at. A person scanning the thread should see what was attempted without expanding anything. Open the card when the exact arguments matter, such as the query sent to a database, because summary is only a human label and input is the object that was actually sent. Leave the card closed, or use the line, when the following sentence already paraphrases the result.

Use a stack when a run of calls would turn the reply into a wall of rows. While any call is running the header reads Working, and total, if you pass it, shows how far through a known set the agent is. Prefer terminal when the action was a shell command with streamed output, file edit when the result is a diff, and web search when the result is a list of pages. Do not use a tool call to ask permission. That pause is tool approval, which offers deny, allow once and always allow.

Does this run the tool, or only draw the call?

It only draws the call. status, input, output, verb, detail and the stack's calls are values you set. Moving a card from Running to a duration means you changed status to done and passed duration. The line shows detail and its hover time only after you take it out of running. There is no fetch, no retry and no clock inside the file.

Why does the response say the call was not sent?

On the card, Response renders output only when status is done or error. pending uses the line Not sent yet, and running uses Waiting for a response. An open card that is still pending shows the request JSON beside that empty response, which is how a queued call looks different from a failure that already has output.