affectUI › Components › Agents

Agent Branches

One agent run that forks into sub-agents and joins back, drawn like a git graph – lanes curve out in their own colour, work runs in parallel, the lead waits at the join.

Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/agent-branches.json · Import from @/components/ui/agent-branches

When to use

  • Showing an agent that splits its work across sub-agents, runs them in parallel and waits for them to come back
  • Making the cost of waiting visible: the lead's dashed line until the slowest sub-agent is back
  • Showing why sub-agents keep the lead's context small – they read the bulk and hand back short summaries

When not to use

  • A fixed set of agents working side by side, each on its own lane – use Agent Lanes
  • A task passed from one agent to the next like a baton – use Handoff Relay
  • Where the time and money of one run go, call by call – use Trace Waterfall

Usage

import { AgentBranches, type BranchAgent, type BranchTask } from "@/components/ui/agent-branches";

const agents: BranchAgent[] = [
  { id: "lead", name: "Report lead" },
  { id: "market", name: "Market research", parent: "lead", start: 6.5, summary: 2400 },
  { id: "rivals", name: "Competitors", parent: "lead", start: 6.5, summary: 3100 },
];

const tasks: BranchTask[] = [
  { id: "t1", agent: "lead", label: "Plan", start: 0, end: 6, tokens: 4000 },
  { id: "t2", agent: "market", label: "Read 12 sources", start: 8, end: 22, tokens: 96000 },
  { id: "t3", agent: "rivals", label: "Compare pricing", start: 8, end: 28, tokens: 54000 },
  { id: "t4", agent: "lead", label: "Write the draft", start: 31, end: 42, tokens: 14000 },
];

export function Run() {
  return <AgentBranches title="Q4 market report" agents={agents} tasks={tasks} duration={44} />;
}

Props

NameTypeDefaultDescription
titlestringThe run's name, in the bar
agentsBranchAgent[]{ id, name, parent?, start?, end?, tone?, base?, summary? } – the one without a parent is the lead
tasksBranchTask[]{ id, agent, label, start, end, failed?, tool?, tokens? } – seconds into the run
durationnumberThe run's length in seconds – the end of the last task when left out
windownumberHow many seconds the card shows – three quarters of the run by default
startAtnumberWhere it opens – halfway into the first fork by default, so the lanes are full from the start
contextLimitnumberEvery agent's context window in tokens – 200k by default
speednumberHow much faster than real time it plays – 4 by default
autoPlaybooleanPlays the run again and again, the window sliding with it – on by default; reduced motion keeps it still
classNamestringAn extra class on the root

Accessibility

  • Every agent's name is a button – focusing it lights its branch like pointing at it, and its label says whether it's working or done
  • Tab goes Pause, the lead, then the sub-agents of the run playing now; those of the run sliding out are left out
  • Each context bar is labelled with its tokens and its window, and says when it's over
  • When all of a fork's sub-agents are back, and when a run is done, it's announced
  • A focus ring shows only for the keyboard

Responsive

  • Fills its container's width; lanes are reused once free, so the card is only as tall as the most agents at once
  • Below 560px only the agents' marks and the coloured blocks stay on the lanes, and the context bars stack in one column
  • Long names and tasks end in …; tokens read 2k, 119k or 1.3M
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Agent Lanes – Where every agent is right now – a live timeline with a lane per agent, tasks growing into “now”, hand-offs drawn between agents and approvals right on the block
  • Handoff Relay – One task passed from agent to agent like a baton, played back live – every agent a tile with its pixel mark that fills in as the baton travels, and a log of the run
  • 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 cost per step and the slowest call marked
  • Agent Metro Map – A multi-agent run drawn as a metro map – every agent a line, every step a station, lines meeting at an interchange where work is handed over, a train riding each one