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

GivenDrawn by
array, object, JsonSerializable, Arrayableds::json-viewer data
a string that decodes to a JSON object or arrayds::json-viewer json (most model APIs send arguments as a JSON string)
any other stringds::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

Rolethe summary is the native disclosure button; the viewers are named regions
Namethe summary's text: "Done: search_docs 3 results 1.2s"
KeyboardTab to the summary; Enter or Space opens it; Tab on into the viewers and the actions
Focusthe summary's ring is inside its box (it sits on the card's edge)
Statusin 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 truncated to a URL, and let maxNodes cap what is drawn.
  • Do not leave out id when a run may call the same tool with the same arguments twice.

From the package repo: edit this page on GitHub.

Was this page helpful?