Skip to content
TuffTasks, docs and chat for teams and AI agents

Planning & Execution

Subagent Split

A lead agent forks a goal into subagent lanes with live steps, tokens and questions, then merges their reports — every point marked with the lane it came from.

1 variantMIT

Preview

Subagent split

Lead agent · 4 subagents

0/4 done

Lead agent · split into 4

Find out why trial-to-paid conversion fell 18% in October and propose a fix we can ship this sprint.

  • Researcher · Support tickets and churn interviews

    Queued

    Support tickets and churn interviews

    Waiting to start

  • Analyst · Funnel by step, device and cohort

    Queued

    Funnel by step, device and cohort

    Waiting to start

  • Coder · Onboarding changes shipped in October

    Queued

    Onboarding changes shipped in October

    Waiting to start

  • Reviewer · Cross-check claims, rule out confounders

    Queued

    Cross-check claims, rule out confounders

    Waiting to start

Merged answer

Waiting for 4 of 4 subagents to report back…

0tokens ·0s

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://tuffui.com/r/subagent-split.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { SubagentSplit } from "@/components/ui/subagent-split";
import { ChartLineUp, Code, MagnifyingGlass, ShieldCheck } from "@phosphor-icons/react";

const roles = {
  research: { role: "Researcher", icon: MagnifyingGlass },
  analyst: { role: "Analyst", icon: ChartLineUp },
  coder: { role: "Coder", icon: Code },
  reviewer: { role: "Reviewer", icon: ShieldCheck },
};

export function LeadRun({ run }: { run: LeadAgentRun }) {
  return (
    <SubagentSplit
      goal={run.goal}
      lanes={run.subagents.map((a) => ({
        id: a.id,
        ...roles[a.kind],
        task: a.task,
        status: a.status, // "queued" | "running" | "needs-input" | "done" | "failed"
        step: a.lastStep,
        progress: a.progress,
        tokens: a.usage.totalTokens,
        elapsedMs: a.elapsedMs,
        question: a.pendingQuestion, // { text, options: ["Prod events", "Mirror"] }
      }))}
      // Each point of the lead's answer lists the subagents it came from.
      points={run.merge.points} // [{ id, text, sources: ["coder", "analyst"] }]
      mergeStatus={run.merge.status}
      onAnswer={(laneId, option) => run.answer(laneId, option)}
      onRerunLane={(laneId) => run.rerun(laneId)}
      onOpenLane={(laneId) => openTranscript(laneId)}
      onAccept={() => run.acceptMerge()}
      onDiscard={() => run.discardMerge()}
    />
  );
}

Props

PropTypeDefaultDescription
goal*ReactNode—What the lead agent was asked to do. Sits at the top, above the fork.
leadLabelstring"Lead agent"Label above the goal and in the default subtitle.
lanes*SubagentLane[]—One lane per subagent, in order. The left rail forks into each lane; when a lane is done, its report runs down the right rail into the merge.
pointsMergePoint[][]The merged answer. Each point carries a colored mark per source lane. Hovering or focusing a point lights its lanes and dims the rest; hovering a lane lights its points. New points fade in.
mergeStatus"waiting" | "merging" | "ready" | "accepted""waiting"Accept merge is enabled only when `ready`.
waitingTextReactNode—Shown in the merge block before any point arrives. Defaults to "Waiting for 2 of 4 subagents to report back…".
highlightedLaneIdstring | null—Lane lit from outside, e.g. when a chat message mentions it. Hover takes over.
highlightedPointIdstring | null—Point lit from outside. Its source lanes light up with it.
onAnswer(laneId: string, option: string) => void—Shows the question's options as buttons on a lane in `needs-input`.
onRerunLane(laneId: string) => void—Shows a re-run button on each lane, on hover or focus. Disabled while the lane runs or is queued.
onOpenLane(laneId: string) => void—Shows an open button on each lane, e.g. to its transcript.
onAccept() => void—Shows Accept merge, the primary action.
onDiscard() => void—Shows Discard next to Accept merge.
titleReactNode"Subagent split"Header title.
subtitleReactNode—Line under the title. Defaults to "Lead agent · 4 subagents".
iconIconGitForkPhosphor icon in the header tile.
formatTokens(tokens: number) => string—Formats token counts. Defaults to "12.4k".
formatElapsed(ms: number) => string—Formats durations. Defaults to "38s" and "1m 04s".
classNamestring—Extra classes for the root element.
type SubagentLane = {
  id: string;
  role: string;          // "Researcher"
  task: string;          // the subtask the lead handed over
  icon?: Icon;           // Phosphor icon in the lane tile
  color?: string;        // any CSS color; defaults to the palette
  status: "queued" | "running" | "needs-input" | "done" | "failed";
  step?: string;         // current or last step
  progress?: number;     // 0–1
  tokens?: number;
  elapsedMs?: number;
  question?: { text: ReactNode; options: string[] }; // while needs-input
};

type MergePoint = {
  id: string;
  text: ReactNode;
  sources: string[];     // lane ids this point came from
};