Tool call

One tool an AI agent called: its name, what it was called with and what came back. A card that opens to show the arguments and the result, an error when it failed, and the Approve and Deny buttons when it waits for the reader. With tool-call-group, a run of calls folds into "Used 4 tools".

Tool call

Works with no script: it is a native details. The copy buttons on the arguments and result need Alpine and the package's script, which also keep the reader's open or closed over a re-render. See getting started.

Use it

<x-ds::tool-call name="search_docs" summary="3 results" :duration="1.24"
    :arguments="$call->input" :result="$call->output" />

Arguments and results are drawn by what they are: an array or object, or a JSON string (as most model APIs send them), by the JSON viewer; other text by the code block.

A failure:

<x-ds::tool-call name="fetch_tracking" status="failed" :duration="30" error="The carrier did not answer within 30 seconds." />

Waiting for approval: open, ringed, with your buttons at the top.

<x-ds::tool-call name="send_email" status="waiting" :arguments="$call->input" id="call-{{ $call->id }}">
    <x-slot:actions>
        <x-ds::button size="sm" wire:click="approve('{{ $call->id }}')">Approve</x-ds::button>
        <x-ds::button size="sm" variant="secondary" wire:click="deny('{{ $call->id }}')">Deny</x-ds::button>
    </x-slot:actions>
</x-ds::tool-call>

A group:

<x-ds::tool-call-group>
    @foreach ($step->calls as $call)
        <x-ds::tool-call :name="$call->name" :status="$call->status" :result="$call->output" wire:key="call-{{ $call->id }}" />
    @endforeach
</x-ds::tool-call-group>

Props

tool-call

PropTypeDefaultWhat it does
namestringrequiredThe tool's name, as the agent called it.
statusstringdoneFrom the status set. waiting means it needs approval.
summarystring—What it did, in a few words, beside the name.
durationnumber—Seconds it took: "1.2s".
argumentsarray, object, string—What it was called with.
resultarray, object, string—What it returned.
errorstring—Why it failed, in a danger block.
openboolfalseOpen on first paint. One waiting for approval is always open.
iconstring—A Heroicon beside the name.
maxHeightint—Lines, for the arguments and the result; the rest scrolls.
maxNodesint2000The most JSON nodes drawn, as the JSON viewer's.
truncatedbool or URLfalseThe host cut the result: says so, and links a URL to the whole.
copybooltrueCopy buttons on the arguments and the result.
argumentsLabel resultLabel errorLabelstringArguments Result ErrorThe sections' words.
approvalTextstringWaiting for your approvalAbove the actions, when waiting.
truncatedText fullResultTextstringResult truncated. See the full resultThe truncation note.
statusTextarray—[status => words].

Give an id when a run may call the same tool with the same arguments twice: the viewers' ids are made from it, {id}-arguments and {id}-result.

SlotWhat it does
actionsButtons at the top of the body: under "Waiting for your approval" while it waits, or on their own (a Retry on a failure). Pass them only when there is something to decide.

tool-call-group

PropTypeDefaultWhat it does
labelstringUsed :count tool|Used :count toolsThe fold's words, singular and plural split by a bar.
openboolfalseOpen on first paint. A group holding a call that waits is always open.
statusTextarray—[status => words].

The group counts the calls in it and shows the one status that matters most: waiting, then running, then failed, else done.

Accessibility

  • The summary is the native disclosure button, and says the status in words before the name: "Done: search_docs 3 results 1.2s".
  • The arguments and result are named scroll regions, reachable by Tab.
  • An error is shown, not announced: a trace re-rendered every second would otherwise announce it each time. Say a failure that matters with a toast or agent status.
  • With the script a call never closes while focus is inside it, and one that starts waiting opens even if the reader had closed it.

Don't

  • Don't put Approve only in a toast. The card shows what is being approved.
  • Don't pass megabytes. Cut the result on the server and pass truncated a URL to the whole.
  • Don't build actions that run without the reader inside the actions slot: it is for their decision.

From the package repo: edit this page on GitHub.

Was this page helpful?