Tool Call
A collapsible card for an AI tool call, with its state, arguments and result.
ToolCall is new in v0.4.0. It shows one tool call from an AI agent: the tool's name and a pending, running, done or error badge. Clicking it opens the arguments, the result or the error.
Installation
bash
shellui add tool-call
Usage
States
State is pending, running (with a spinner), done or error; any other value shows as pending.
Arguments
{ "city": "Harare" }Result
{ "temperature": 27, "conditions": "sunny" }<div class="w-full max-w-xl space-y-3">
<ToolCall Name="list_files" State="pending" Arguments="@("{ \"path\": \"src\" }")" />
<ToolCall Name="search_docs" State="running" Arguments="@("{ \"query\": \"dialog focus trap\" }")" />
<ToolCall Name="get_weather" State="done" DefaultOpen="true"
Arguments="@("{ \"city\": \"Harare\" }")"
Result="@("{ \"temperature\": 27, \"conditions\": \"sunny\" }")" />
<ToolCall Name="send_email" State="error"
Arguments="@("{ \"to\": \"team@example.com\" }")"
Error="SMTP server refused the connection." />
</div>
With reasoning
Update State and Result as the call progresses. Here a Reasoning block streams first, then the tool runs.
<div class="w-full max-w-xl space-y-3">
<Button Variant="ButtonVariant.Outline" OnClick="RunAsync" Disabled="running">@(running ? "Running…" : "Run")</Button>
<Reasoning Text="@reasoning" IsStreaming="thinking" Duration="thought" />
<ToolCall Name="search_docs" State="@state" Arguments="@Arguments" Result="@result" />
</div>
@code {
private const string Arguments = "{ \"query\": \"dialog focus trap\", \"limit\": 3 }";
private string? reasoning = "Press Run: the reasoning streams, then the tool runs.";
private bool thinking;
private TimeSpan? thought;
private string state = "pending";
private string? result;
private bool running;
private async Task RunAsync()
{
running = true;
reasoning = "";
thought = null;
state = "pending";
result = null;
thinking = true;
var started = DateTime.UtcNow;
foreach (var word in "I need the pages about the focus trap. Searching the docs.".Split(' '))
{
reasoning += word + " ";
StateHasChanged();
await Task.Delay(90);
}
thinking = false;
thought = DateTime.UtcNow - started;
state = "running";
StateHasChanged();
await Task.Delay(1500);
result = "[\n \"layout/dialog#accessibility\",\n \"layout/sheet#accessibility\"\n]";
state = "done";
running = false;
}
}
Arguments, Result and Error are shown as preformatted text, so pass JSON already indented. For anything else, such as a table of results, use child content: it is rendered below them in the open card.
API Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
Name |
string |
"" |
The tool's name, in a monospace font |
State |
string |
"pending" |
pending, running, done or error (case doesn't matter) |
Arguments |
string? |
null |
Shown under "Arguments" when set |
Result |
string? |
null |
Shown under "Result" when set |
Error |
string? |
null |
Shown under "Error", in the destructive colour, when set |
ChildContent |
RenderFragment? |
null |
Extra content below the arguments, result and error |
DefaultOpen |
bool |
false |
Opens the card on first render |
Class |
string? |
null |
Additional CSS classes |
Accessibility
- The header is a
<button>witharia-expanded - The state is written as text in the badge ("Running", "Done"), not shown by colour alone