Loading component…
Loading component…
An agent's tool call in one line
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ToolCallCard from ./tool-call-card.
import { ToolCallCard, ToolCallGroup } from "@/components/ui/tool-call-card";
export function ToolCalls({ calls }: { calls: ToolCall[] }) {
return (
<ToolCallGroup>
{calls.map((call) => (
<ToolCallCard
key={call.id}
name={call.name}
summary={call.summary}
status={call.status}
args={call.args}
result={call.result}
error={call.error}
startedAt={call.startedAt}
duration={call.durationMs}
onRetry={() => retryToolCall(call.id)}
/>
))}
</ToolCallGroup>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| name | string | Tool name as the agent calls it, shown in mono – e.g. "search_web" | |
| status | "running" \| "success" \| "error" | Spinner with a live timer, check with the duration, or a red "Failed" | |
| summary | ReactNode | Short human summary next to the name; truncates with an ellipsis | |
| icon | ReactNode | wrench icon | Icon in the tile on the left – a 16px stroke SVG fits best |
| args | unknown | Arguments – objects are pretty-printed and highlighted, JSON strings are parsed; the section is hidden when undefined | |
| result | unknown | What the tool returned – like args; other strings are shown as plain text. While running without a result, "Waiting for result…" is shown | |
| error | string | Error message, shown in the body when status is "error" | |
| startedAt | number | Start time in ms since epoch – the live timer counts from here instead of from when the card turned running | |
| duration | number | Final duration in ms – otherwise the time measured while the card was running | |
| defaultOpen | boolean | false | Start expanded (uncontrolled) |
| open | boolean | Expanded state (controlled) | |
| onOpenChange | (open: boolean) => void | Called when the header is toggled | |
| openOnError | boolean | true | Opens the card when the call fails and closes it on the next run, unless someone toggled it by hand (uncontrolled only) |
| onRetry | () => void | Shows a Retry button next to the error message | |
| maxCodeHeight | number | 220 | Height in px after which arguments and result are capped with a fade and a "Show all" toggle |
| className | string | Extra class on the root | |
| ToolCallGroup · children | ToolCallCard elements | The cards – the group reads their icon, status and duration props for its header, so pass them as direct children | |
| ToolCallGroup · label | string | "Used N tools" | Header label once nothing is running |
| ToolCallGroup · runningLabel | string | "Using tools…" | Shimmering header label while any card is running |
| ToolCallGroup · duration | number | Total in ms – otherwise the sum of the cards' duration props, or the time measured while any card was running | |
| ToolCallGroup · defaultOpen / open / onOpenChange | boolean / boolean / (open) => void | false | Expanded state, uncontrolled or controlled |
| ToolCallGroup · className | string | Extra class on the root |
Fills its container; name and summary truncate with an ellipsis, the status never wraps – works down to ~320px
Code wraps long lines instead of scrolling sideways
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.