Tool call
A card for one tool invocation: its name, what it was called with, what it
returned. And tool-call-group, which folds consecutive calls into "Used 4
tools". Host-driven: nothing here calls a tool, approves one or parses a
stream. Native details, composing ds::json-viewer and ds::code-block.
Anatomy
details[data-ds-tool-call=status].group/tool x-data x-ds-keep-toggle
├── summary a row: px-3 py-2
│ ├── mark (aria-hidden) [icon] sr-only "Done: "
│ ├── name font-mono text-meta
│ ├── summary muted, truncated
│ └── time[datetime=PT1.24S] "1.2s" (+ sr-only full) chevron
└── div border-t, p-3, gap-3
├── waiting: "Waiting for your approval" strip + actions slot
├── error: danger wash block, "Error" + message
├── Arguments ds::json-viewer | ds::code-block
├── Result ds::json-viewer | ds::code-block
└── "Result truncated. See the full result"
What draws arguments and results
| Given | Drawn by |
|---|---|
| array, object, JsonSerializable, Arrayable | ds::json-viewer data |
| a string that decodes to a JSON object or array | ds::json-viewer json (most model APIs send arguments as a JSON string) |
| any other string | ds::code-block, wrapped, its filename the section's words |
| null or "" | nothing |
Each viewer is captioned by argumentsLabel / resultLabel, which also
names its scroll region. maxHeight (lines) and maxNodes pass through;
copy (default on, needs Alpine and the script) passes through. With an id
on the card the viewers' ids are {id}-arguments and {id}-result, which
keeps two identical calls on one page from sharing ids; without one they are
hashed from their content, as the viewers do.
Statuses
The shared set (specs/agent-status.md). waiting is approval: the card
renders open, ringed in warning, with the approval strip and the actions
slot at the top of the body, and carries data-ds-open-required so
x-ds-keep-toggle lets it open even if the reader closed it before. The card
dispatches nothing: the host wires Approve and Deny.
error is shown whenever given (a danger wash block, not role="alert": a
trace of failed calls re-rendered every second would shout each time).
truncated: true says "Result truncated."; a URL also links to the whole.
The group
tool-call-group reads the calls rendered in its slot, as checklist reads
its items: how many (Used :count tool|Used :count tools, singular and
plural split by a bar) and the state that matters most: waiting, then
running (or pending), then failed, then all cancelled, else done. Waiting
opens the group too. The summary is quiet and inline, like the reasoning
block's.
Accessibility
| Role | the summary is the native disclosure button; the viewers are named regions |
| Name | the summary's text: "Done: search_docs 3 results 1.2s" |
| Keyboard | Tab to the summary; Enter or Space opens it; Tab on into the viewers and the actions |
| Focus | the summary's ring is inside its box (it sits on the card's edge) |
| Status | in words before the name, visually hidden; the mark is decorative |
Do not
- Do not put the Approve button only in a toast. The card is where the reader sees what they are approving.
- Do not pass a whole result of megabytes. Truncate on the server, set
truncatedto a URL, and letmaxNodescap what is drawn. - Do not leave out
idwhen a run may call the same tool with the same arguments twice.
From the package repo: edit this page on GitHub.