Loading component…
Loading component…
How an agent finds out why a run failed, as a fault tree – it checks one hypothesis after another, rules some out, confirms the cause, and the way up to the failure lights up
To reuse this local React demo, copy all files from the Code tab into the same folder, then import RootCauseTree from ./root-cause-tree.
import { RootCauseTree, type Cause } from "@/components/ui/root-cause-tree";
const failure: Cause & { detail?: string } = {
id: "failure",
title: "Checkout tests failing",
detail: "4 of 12",
children: [
{ id: "stripe", title: "Stripe API errors", status: "ruled-out", verdict: "Every call came back 200." },
{
id: "coupon",
title: "Coupon not applied",
gate: "and",
status: "confirmed",
children: [
{ id: "percent", title: "Discount sent as amount", status: "confirmed", evidence: { kind: "Diff", content: "- amount_off\n+ percent_off" } },
{ id: "recompute", title: "Total recomputed after", status: "checking" },
],
},
],
};
export function Investigation() {
return <RootCauseTree failure={failure} onAction={(cause, action) => agent.run(action, cause.id)} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| failure | Cause & { detail?: string } | The failure on top – its children are the first hypotheses; detail is a short line next to its badge, e.g. "4 of 12" | |
| children | Cause[] | Per cause: { id, title, icon?, files?, gate?, status?, verdict?, evidence?, at?, children? } – the hypotheses under it, as deep as you need | |
| icon | ReactNode | Per cause: a small mark before the title, e.g. the logo of the tool or service it's about – it turns gray when ruled out | |
| files | string[] | Per cause: the files it touches – the first shows as a chip on the card, the rest as "+2"; the evidence card lists them all with their full path | |
| gate | "or" \| "and" | "or" | Per cause, for its children: or – one of them is enough; and – they only cause it together |
| status | "open" \| "checking" \| "ruled-out" \| "confirmed" | "open" | Per cause – a confirmed one without children is a root cause and lights the way up |
| verdict | string | Per cause: why it was ruled out or confirmed, in a sentence – shown with its evidence | |
| evidence | { kind, source?, content } | Per cause: the proof – kind is its label ("Log", "Diff", "Tool call"), content the lines, shown as code | |
| onAction | (cause, action: "fix" \| "retry") => void | Fix it or Retry from here was pressed on a root cause – without it, the evidence is read only | |
| formatTime | (ms: number) => string | 0:42 | Formats when a cause was checked (at) |
| title | string | "Root cause" | Heading of the bar |
| className | string | Extra class on the root |
Every card has a fixed height, so nothing moves when a hypothesis is checked, ruled out or confirmed; the failure's card fits its own title, the hypotheses all share one width – as wide as their longest title needs, growing into spare room – and a title too long for the room ends in “…”, shown whole in the evidence
The tree lays itself out from its own width; when even the narrowest cards don't fit it becomes an indented list – two rows a card, the gates as chips on the cards
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"