Epicenter
Local-first, open source apps
Subagent is a line for work the agent hands to a subagent. The run is the title, like "Ran the research agent". Open it for the tool calls the subagent made and what it found.
Subagent is built with Trace with a Trace.Collapsible for the run and a nested Trace for its tool calls.
Installation
Subagent is built with the Trace, Code Block and Badge components.
Usage
<script lang="ts">
import * as Trace from "$lib/components/ui/trace/index.js";
</script> <Trace.Root>
<Trace.Collapsible>
<Trace.CollapsibleTrigger>
<Trace.Line>
<Trace.Icon>
<CircleCheckIcon />
</Trace.Icon>
<Trace.Title>Ran the research agent</Trace.Title>
</Trace.Line>
</Trace.CollapsibleTrigger>
<Trace.CollapsibleContent class="flex flex-col gap-3">
<Trace.Root>
<Trace.Line>
<Trace.Icon>
<CircleCheckIcon />
</Trace.Icon>
<Trace.Title>Ran grep -rn cacheKey scripts</Trace.Title>
</Trace.Line>
</Trace.Root>
<p>The cache is keyed on the commit SHA.</p>
</Trace.CollapsibleContent>
</Trace.Collapsible>
</Trace.Root> Running
While the subagent runs, the line has status="running" and its content shows the tool calls so far. Add the result when the subagent finishes.
Details
Put the task the subagent was given at the top of the content, with its model and tools as Badge items. Show how long it ran in a Trace.Description after the title.
Find out why image optimization reruns on every deploy.
The cache is keyed on the commit SHA.
AI SDK
With the AI SDK, a subagent is a tool whose execute yields the subagent's UIMessage as it streams. Render the tool part as the line and part.output.parts as the nested Trace. Map each nested tool part as in Tool.
Each yield is a preliminary output: the part is output-available with preliminary: true. The final output replaces it, so check preliminary before you show "Ran".
API Reference
See Trace.