# Agent Network

> The hierarchy of a multi-agent system as a live graph: the orchestrator at the top, a lead per project or team below it and the agents that do the work under each lead.

Component · AI · Halo kit · [Live page](https://ui.twentyfirst.media/halo/components/AgentNetwork/)

The hierarchy of a multi-agent system as a live graph: the orchestrator at the top, a lead per project or team below it and the agents that do the work under each lead.

- Each node shows name, project, status (the kit's status shapes: idle, running, signal = waiting for approval, warn, danger, ok) and a beacon with the number of open approvals.
- `handoffs` come from your event stream (`{ id, from, to, label }`): every new id sends a small packet along the edges, up to the shared lead and down to the receiver. Screen readers hear "A handed … to B". With reduced motion (or `UIProvider motion="off"`) the receiver is marked for a moment instead.
- Click a node for its details card with `detail`, `renderDetails` and a link (`href`, `linkAs` or `UIProvider linkAs`). `selected`/`onSelect` make the selection controlled.
- Drag to pan, pinch or Ctrl/⌘ + wheel to zoom, the buttons zoom and fit. Narrower than 560px (or `layout="list"`) it is an indented list instead of a graph.

## Example

```tsx
import * as React from "react";
import { AgentNetwork, Button, Panel, useMotion } from "@twentyfirstmedia/halo";
import type { AgentNetworkHandoff } from "@twentyfirstmedia/halo";
import { NETWORK } from "./_coordination";

const ROUTES: [string, string, string][] = [
  ["main", "support", "Refund request"],
  ["support", "shop-lead", "Needs approval"],
  ["main", "release", "Ship 2.4"],
  ["qa", "app-lead", "Tests passed"],
  ["main", "books", "November invoices"],
  ["ads", "main", "Weekly report"],
];

export default function Preview() {
  const motion = useMotion();
  const [handoffs, setHandoffs] = React.useState<AgentNetworkHandoff[]>([]);
  const n = React.useRef(0);
  const send = React.useCallback(() => {
    const [from, to, label] = ROUTES[n.current % ROUTES.length]!;
    n.current += 1;
    setHandoffs((h) => [...h.slice(-10), { id: `h${n.current}`, from, to, label }]);
  }, []);
  // a live stream in a real app; here a handoff every few seconds while motion is on
  React.useEffect(() => {
    if (motion === "off") return;
    const timer = setInterval(send, 2600);
    return () => clearInterval(timer);
  }, [motion, send]);
  return (
    <Panel
      title="Agents"
      action={
        <Button size="sm" variant="secondary" icon="send" onClick={send}>
          Send a handoff
        </Button>
      }
    >
      <AgentNetwork root={NETWORK} handoffs={handoffs} height={400} defaultSelected="shop-lead" />
    </Panel>
  );
}
```

## Props

### AgentNetwork

| Prop | Type | Notes |
| --- | --- | --- |
| `root` | `AgentNetworkNode` | The orchestrator, with its leads and their agents as children. |
| `handoffs?` | `AgentNetworkHandoff[]` | Handoffs from your event stream; each new id animates a packet from `from` to `to`. |
| `animateInitial?` | `boolean` | Also animates the handoffs present at mount (default: only later ones). |
| `layout?` | `"auto" \| "graph" \| "list"` | "auto" (default): the graph, or a list when narrower than 560px. |
| `height?` | `number` | Height of the graph viewport (default 440). |
| `selected?` | `string \| null` | Selected node id (controlled); `null` for none. |
| `defaultSelected?` | `string \| null` |  |
| `onSelect?` | `(node: AgentNetworkNode \| null) => void` |  |
| `renderDetails?` | `(node: AgentNetworkNode) => ReactNode` | More content for the details card of the selected node. |
| `openLabel?` | `string` | Text of the details card's link (default "Open"). |
| `label?` | `string` | Accessible name of the graph (default "Agent network"). |
| `linkAs?` | `ElementType` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Button

| Prop | Type | Notes |
| --- | --- | --- |
| `variant?` | `"primary" \| "secondary" \| "soft" \| "ghost" \| "danger" \| "danger-solid"` |  |
| `size?` | `"md" \| "sm"` |  |
| `icon?` | `IconName` |  |
| `iconRight?` | `IconName` |  |
| `disabled?` | `boolean` |  |
| `type?` | `"button" \| "submit" \| "reset"` |  |
| `onClick?` | `(e: MouseEvent<HTMLButtonElement>) => void` |  |
| `children?` | `ReactNode` |  |
| `asChild?` | `boolean` | Render the single child element (a link, a router Link) with the button's look instead of a <button>. |
| `id?` | `string` |  |
| `name?` | `string` | Form field name and value, sent with the form when this button submits it. |
| `value?` | `string` |  |
| `form?` | `string` | The id of the form this button belongs to, when it sits outside it. |
| `title?` | `string` |  |
| `tabIndex?` | `number` |  |
| `autoFocus?` | `boolean` |  |
| `aria-label?` | `string` |  |
| `aria-labelledby?` | `string` |  |
| `aria-describedby?` | `string` |  |
| `aria-expanded?` | `boolean \| "true" \| "false"` | For disclosure and menu triggers: whether what the button controls is open. |
| `aria-controls?` | `string` |  |
| `aria-haspopup?` | `boolean \| "true" \| "false" \| "menu" \| "listbox" \| "tree" \| "grid" \| "dialog"` |  |
| `aria-pressed?` | `boolean \| "true" \| "false" \| "mixed"` | For toggle buttons. |
| `aria-current?` | `boolean \| "true" \| "false" \| "page" \| "step" \| "location" \| "date" \| "time"` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
