affectUI › Components › Agents
Agent Flame Graph
A multi-agent run's call stack as a flame graph – the orchestrator on top, its subagents under it, then their LLM and tool calls, every block as wide as it took. Switch to Tokens or Cost and every block glides to its new width; click one and it slides out to the full width, with a breadcrumb back. Search lights up the matching blocks and says how much of the run they took; a failed call's card offers Retry. Agents carry their pixel mark, LLM and tool calls their maker's logo, and a live run keeps growing at its right edge.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/agent-flame-graph.json · Import from @/components/ui/agent-flame-graph
When to use
- Seeing where a multi-agent run spent its time, tokens or money – the widest blocks are the answer, at every level
- Digging into one part of a run: click a subagent and it fills the width, with a breadcrumb back to the whole run
- Finding every call to one model or tool across the run – search lights them up and says how much of the run they took
- Watching a run while it works – the right edge keeps growing, failed calls can be retried from their card
When not to use
- Reading each call's input and output row by row – use Trace Waterfall
- The critical path through parallel work – use Critical Path
- Which agent called which tool, as a network – use Tool Calls Network
- The hierarchy without numbers – use Agent Tree
Usage
import { AgentFlameGraph, type FlameNode } from "@/components/ui/agent-flame-graph";
const run: FlameNode = {
id: "orchestrator", name: "Orchestrator", kind: "agent", model: "claude-opus-4.5", start: 0, end: 134_000,
children: [
{
id: "coder", name: "Coder", kind: "agent", start: 52_500, end: 123_500,
children: [
{
id: "c-1", name: "claude-sonnet-4.5", kind: "llm", start: 53_000, end: 64_000,
tokens: 30_900, cost: 0.58, icon: <ClaudeLogo />, detail: "Write the patch for 9 files",
children: [{ id: "c-1a", name: "github.get_file", kind: "tool", tool: "GitHub", icon: <GitHubLogo />, start: 55_000, end: 56_400 }],
},
{ id: "t-1", name: "shell.run", kind: "tool", status: "failed", error: "3 tests failed", start: 73_000, end: 80_000 },
],
},
],
};
export function Run() {
return <AgentFlameGraph title="Ship v2.4" root={run} />;
}Props
| Name | Type | Default | Description |
|---|---|---|---|
root | FlameNode | The run – { id, name, kind, start, end?, status?, tokens?, cost?, model?, tool?, detail?, error?, icon?, color?, children? } | |
kind | "agent" | "llm" | "tool" | Agents get a quiet gray block with their pixel mark, LLM calls indigo, tool calls teal; failed blocks are red | |
start / end | number | In ms from the start of the run. Leave end out while it runs; with status "running" an end is how far it reaches for now | |
tokens / cost | number | A block's own – an agent's children are added on top. NaN and negatives count as nothing | |
icon | ReactNode | The model maker's or the tool's logo, 12px – also shown in the breadcrumb and the card | |
now / startedAt | number | The clock in ms from the start, or when the run started (epoch ms) for a clock of its own | |
metric / defaultMetric / onMetricChange | "time" | "tokens" | "cost" | What sizes the blocks – time by default | |
zoomId / defaultZoomId / onZoomChange | string | null | The block that fills the width – null for the whole run | |
query / defaultQuery / onQueryChange | string | The search – matches names, models, tools and details (agents by name) | |
onRetry | (block: FlameNode) => void | Offers Retry on failed blocks – in their card, or R on a focused failed block | |
title / rootLabel | string | The heading, and the first crumb of the breadcrumb ("Run") | |
formatCost | (amount: number) => string | Formats every cost – dollars by default | |
className | string | An extra class on the root |
Accessibility
- The graph is a tree with one block in the tab order; every block reads as its name, kind, status, time, tokens and cost
- ← and → move along a row, ↑ goes to the parent, ↓ to the first child, Home to the zoomed block
- Enter or Space zooms into the focused block (or out of the zoomed one); Esc and Backspace zoom out a level from anywhere but the search
- A focused block shows its card; on a failed block Tab moves into the card's Retry button, Shift Tab and Esc go back, R retries without the card
- The Time / Tokens / Cost switch is a radio group – the arrows change it
- The breadcrumb is a nav with the current level marked; the match count is a live status
- The search field firms up its edge instead of a ring; a focus ring shows only for the keyboard
Responsive
- Fills its container's width and never scrolls sideways; the graph keeps a fixed height of 10 rows, deeper trees scroll inside
- Blocks under 40px show no text, names end in …; the number pill shows from 150px
- Narrow: the title and a search button on top, the switch across the width, the breadcrumb collapses to Run › … › last
- On a touch screen a tap zooms and keeps the block's card open until a tap somewhere else
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
Related
- Trace Waterfall – Where the time and money of an agent run go – every LLM call, tool call and sub-agent as a bar on a live timeline, with tokens and cost per step, the slowest call marked and branches that fold into their parent
- Critical Path – An agent run's spans on a timeline, one lane per agent, with thin arrows from every span to the ones waiting for it. The chain that decides when the run ends is the critical path – its spans in full tint, its arrows solid, the rest fades back, and a quiet line says how much of the run it is. Drag the end of any span to try a what-if: everything that waits for it slides along, the end of the run moves, and the path hops to another chain when that one now ends last; a pill says how much earlier or later the run ends. Drag a span onto another lane to run it on that agent. Click a span for its card – the duration before and after, its slack, and what it waits for and unblocks; Reset brings the run back
- Tool Calls Network – Every LLM and tool call of an agent run as rows, like the Network tab of the browser's developer tools – status, name with the tool's logo, the agent that made it, size and time, and a small waterfall where each call is a bar on the run's timeline, split into queued, waiting for the first token, streaming and tool execution. New calls stream in at the bottom while running bars grow at the "now" edge; drag across the overview strip for a stretch of time, filter by LLM, tools, errors or retries, sort like DevTools, and open a call for its request and response as pretty JSON, its timing phase by phase and every retry
- Agent Tree – 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