affectUI › Components › Agents

Agent Router

A router agent sorting incoming requests to the agents that handle them – the request coming in on top, the router under it and the agents side by side at the bottom, each with its task queue below, all as Agent Crew's cards on its soft blue connectors – people sit off to the right, a fading line with a Human tag. A light runs into the router, which reads the request and settles on an agent with a confidence; the light runs on, the agent's card lights up in its color and the request drops into its queue. Unsure, it hands the request to a person. A click opens why it went where it went, with every agent's score and a way to send it elsewhere.

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

When to use

  • A support inbox, a help desk or any queue where an agent decides which agent – or person – takes each request
  • Showing that routing happens and why: the confidence, every agent's score and the reason, one click away
  • Live: requests come in, the router reads them and hands them on while you watch

When not to use

  • A lead splitting one task among sub-agents – use Agent Crew or Agent Tree
  • One run, message by message – use Agent Sequence
  • The requests themselves, to read and answer – use Agent Inbox
  • A task passed on from agent to agent – use Agent Handoff

Usage

import { AgentRouter, type RouterAgent, type RouterRequest } from "@/components/ui/agent-router";

const router: RouterAgent = { id: "router", name: "Router", model: "Claude Haiku", status: "active", activity: "Reading “Refund for order #4821”" };

const agents: RouterAgent[] = [
  { id: "billing", name: "Billing", model: "Claude Sonnet", status: "active", activity: "Refunding order #4821", load: 0.45, queue: 2 },
  { id: "tech", name: "Tech support", model: "Claude Sonnet", status: "idle", load: 0.3, queue: 1 },
  { id: "human", name: "Support lead", model: "Human", human: true },
];

const requests: RouterRequest[] = [
  { id: "r1", title: "Refund for order #4821", from: "maria@northwind.io", channel: "email", preview: "I was charged twice…", status: "routed", to: "billing", confidence: 0.94, scores: { billing: 0.94, tech: 0.12 }, reason: "A double charge – billing." },
];

export function Inbox() {
  return <AgentRouter title="Support inbox" router={router} agents={agents} requests={requests} />;
}

Props

NameTypeDefaultDescription
routerRouterAgentThe router itself, in the middle – { id, name, model?, status?, activity? }; its bar shows how sure it is about the request it reads or last sent on
agentsRouterAgent[]Who it sends requests to – { id, name, model?, status?, activity?, load?, queue?, human?, color?, logo? }. Agents get their pixel mark in a color of the palette, a person (human: true) the full square in ink and an orange glow when a request reaches them
requestsRouterRequest[]Newest first – { id, title, from?, channel?, icon?, preview?, status, to?, confidence?, scores?, reason?, tags? }
tags(string | { label, color? })[]Per request – up to three small tags on its card in a task queue, gray or tinted with their own color
status"new" | "routing" | "routed" | "escalated" | "done"Per request – routing runs the light into the router and shimmers its line; routed or escalated with to runs it on to that agent, whose card lights up in its color
channel / icon"email" | "chat" | "ticket" | "call" | "slack" | ReactNodeWhere the request came in – its icon in the card's tile; icon puts your own there
confidence / scores / reasonnumber / Record<string, number> / stringHow sure the router is (0–1), every agent's score and why – shown on the card and when it is open
layout"lanes" | "columns"lanes (default): the request coming in on top, the router under it, the agents side by side at the bottom, each with its task queue below as in Agent Handoff – a request drops into the queue when the light reaches its agent. People (human: true) get no card: a line out of the router's right side fades out, with a Human tag on it that counts what waits for them. columns: requests, router and agents side by side
modelLogoReactNodePer agent and on the router – the model maker's logo, before the model's name (Claude, OpenAI, Gemini …)
maxnumberHow many requests show on the left in columns – 4 by default
onReroute(request, agentId) => voidWith it, an open request lists every agent as a button to send it there – update the request's to and the light runs to the new agent
onSelect(request) => voidA request was opened
titlestringThe header's name, with how many are routing, need you and are routed
classNamestringExtra class on the root – set the color variables on it

Keyboard

  • Tab: One stop for the whole map
  • ← / → / ↑ / ↓: Walk the cards – the request on top, the router, each agent and its task queue
  • Home / End: First or last card
  • Enter / Space: On a request: opens why it went where it went. On an agent: keeps its requests clear and fades the rest
  • Esc: Closes the open request, or clears the agent you look at

Accessibility

  • Every card reads what it is and where it stands – "Refund for order #4821, from maria@northwind.io: Routed, to Billing, 94% sure"
  • The open request is a dialog; with onReroute its agents are buttons that say which one it went to
  • A polite live region says where each request went
  • The connectors and the light are decoration – everything they show is in the cards' labels
  • Focus rings show for the keyboard only (:focus-visible), in light and dark

Responsive

  • Lanes (wide): the request on top, the router, every agent side by side with its task queue – the queues fade out at the bottom and keep one height
  • Columns (wide): requests, router and agents side by side, joined by connectors with rounded bends
  • Narrow: one column – the requests indented above the router, the agents hanging below it as in Agent Crew; the light runs the same way
  • Every card keeps its rows – a long subject, sender or line ends in … with the full text on hover
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Agent Crew – A lead and its sub-agents as one live tree of cards – every agent stays on screen; each card says what the agent does right now, how full its context is, its tools and the last thing it was handed, and handoffs run as a light along Agent Tree's rounded connectors and light up the card they reach; a click on a card opens its task, model, usage and tools with actions to steer it, and a switcher swaps between projects
  • 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
  • Agent Sequence – One agent run as a sequence diagram – a column for you, every agent and every tool, and each message an arrow from one lifeline to the next: calls solid, replies dashed, every label a tag in its line's color, a bar on the lifeline while a participant works, parallel and retried messages in labelled frames; new messages draw themselves across with a light at the tip, and a click on a participant or a message opens its card
  • Agent Inbox – All your background agent tasks in one calm list – live clocks and status tags, filter tabs with rolling counts, rows that unfold to the last steps with Approve, Reject, Retry or Open, and glide to their new place