Loading component…
Loading component…
Who started whom – an orchestrator and its sub-agents as a live tree, with status, cost and time on every card, costs rolling up each branch, and branches that fold to one line
To reuse this local React demo, copy all files from the Code tab into the same folder, then import AgentTree from ./agent-tree.
import { AgentTree, type TreeAgent } from "@/components/ui/agent-tree";
const run: TreeAgent = {
id: "lead", name: "Orchestrator", model: "Opus 5.5", task: "Launch the new pricing page",
status: "running", cost: 0.42, started: Date.now() - 80_000,
children: [
{ id: "research", name: "Researcher", task: "Compare five competitors", status: "done", cost: 0.29, started: Date.now() - 70_000, ended: Date.now() - 25_000 },
{ id: "build", name: "Coder", task: "Build the page", status: "running", cost: 0.18, started: Date.now() - 60_000 },
],
};
export function Run() {
return <AgentTree root={run} onSelect={(agent) => openLog(agent.id)} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| root | TreeAgent | { id, name, task, model?, avatar?, tools?, status, ask?, error?, cost?, started?, ended?, children? } – the whole tree, rebuilt as the run goes on; tools are small marks shown as overlapping tiles before the task | |
| status | "queued" \| "running" \| "waiting" \| "done" \| "failed" \| "stopped" | Per agent – "waiting" reads "Needs you"; queued and stopped agents and their connectors are muted | |
| cost | number | Per agent, its own cost – a card with children shows the whole branch | |
| collapsed / defaultCollapsed | string[] | [] | Ids of folded branches, controlled or uncontrolled |
| onCollapsedChange | (collapsed: string[]) => void | A branch was folded or opened | |
| ask / error | string | Per agent – what a waiting agent needs you to decide, and what went wrong for a failed one; shown in the window behind "needs you" and "failed" | |
| onResolve | (agent, action: "approve" \| "reject" \| "retry" \| "dismiss") => void | An answer from that window – update the agent's status in your data | |
| onSelect | (agent: TreeAgent) => void | A click on a card – makes the cards clickable | |
| now | number | Date.now() | The clock for running times – without it the tree ticks every second while an agent runs |
| formatCost | (amount: number) => string | dollars, e.g. "$0.42" | Formats every cost |
| title | string | "Agents" | Heading of the bar |
| className | string | Extra class on the root |
From 560px the first level sits side by side under the root, deeper levels hang below their parent – every card has the same width
Narrower, every level is indented under its parent and the connectors run down the left; the cards shrink together so the deepest level still fits
The connectors are measured from the cards, so any width or zoom works
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"