Xzero UI
Pro library

Agent loopPro

An illustration of the agent loop: gather context, take action, verify, repeat, with a bright head circling three stations around the model.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/agent-loop
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/agent-loop

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { AgentLoop } from "@/components/xzero/agent-loop/agent-loop";
import { GithubMark, SlackColorMark } from "@/components/xzero/agent-loop/agent-loop-marks";

export function DeployLoop() {
  return (
    <AgentLoop
      task="Fix the failing deploy on main and tell #releases."
      summary="The build cache was stale. Cleared it, the deploy passed and #releases knows."
      onDone={() => console.log("loop finished")}
      iterations={[
        {
          gather: { label: "Build log", detail: "Step 4 of 9 failed", tokens: 3200 },
          calls: [{ tool: "GitHub", mark: <GithubMark aria-hidden />, action: "Read workflow run", result: "Cache key mismatch" }],
          verify: { passed: false, note: "Fix not applied yet" },
        },
        {
          gather: { label: "Workflow file", detail: "deploy.yml, 84 lines", tokens: 1900, mark: <GithubMark aria-hidden /> },
          calls: [
            { tool: "GitHub", mark: <GithubMark aria-hidden />, action: "Clear cache and rerun", result: "Deploy passed in 3m 12s" },
            { tool: "Slack", mark: <SlackColorMark aria-hidden />, action: "Post update", result: "Posted in #releases" },
          ],
          verify: { passed: true, note: "Deploy green, team told" },
        },
      ]}
    />
  );
}

API reference

AgentLoop

An illustration of the agent loop: gather context, take action, verify, repeat. A bright head with a soft gradient trail runs clockwise round a ring past three stations, with the model at the center. At Gather context a block joins the context stack beside the ring and the token count rolls up; at Take action a tool call with its real mark drops out of the ring on a short pin and resolves with a result (or an error); at Verify a check passes or leaves a retry note that sends the loop round again. A counter rolls with each loop, and the last one ends in a done state with the ring drawn in, a check at the center and the summary as the caption, or a stopped state when the last check fails. Play, pause, step, restart and speed drive it. The run, the tool calls and their results are sample data; nothing calls a real service.

PropTypeDefaultDescription
iterationsAgentLoopIteration[]sample triage run (3 loops)The loops, in order. Each is { gather, calls, verify }: gather is the context block { label, detail?, tokens, mark? }, calls are one to three tool calls { tool, mark?, action, result, status? } shown one after another, and verify is { passed, note }. A failed check reads as a retry note; when the last one fails the run ends as stopped. An empty array shows the ring at rest with the controls off.
taskstring"Find out why EU cards are declined at checkout, then update the team."The caption while the loop is ready or running.
summarystring–The caption once the loop ends. Defaults to a count of loops and tool calls, or a stopped note when the last check fails (the sample run has its own summary).
model{ name: string; mark?: ReactNode } | nullClaude Opus 5.5 with the Claude markThe model at the center. Pass null to show only the loop counter.
titlestring"Agent loop"Card title.
stationLabelsPartial<Record<"gather" | "act" | "verify", string>>Gather context, Take action, VerifyStation names. Keep them to about two words; a longer name truncates beside its station.
autoPlaybooleantrueStarts the loop the first time the card is mostly in view. Under reduced motion the card opens on its done state instead.
loopbooleanfalsePlays again about four seconds after the done state.
speednumber–Playback speed, controlled. At 1 the sample run takes about 18 seconds; 0 holds still. Pair it with onSpeedChange.
defaultSpeednumber1Starting speed when uncontrolled. The control offers 0.5, 1 and 2.
onSpeedChange(speed: number) => void–Called when the speed control changes.
controlsbooleantrueShows play and pause, step, restart and the speed control.
onStationChange(station: "gather" | "act" | "verify", iteration: number) => void–Called when the head reaches a station, with the zero based loop. Fires once per beat, never per frame.
onDone() => void–Called each time playback reaches the done state.
classNamestring–Class on the root element.
styleCSSProperties–Inline style on the root. Set --al-accent to recolor the head, trail, pins and active stations (defaults to --series-1).

Keyboard interactions

KeysAction
TabMoves through play or pause, next step, restart and the speed control.
Enter / SpaceOn play, pauses or resumes; on next step, plays to the next beat (a new context block, a tool result, a check or the end) and stops there; on restart, starts over from the ready state.
Arrow left / Arrow rightOn the speed control, moves between 0.5×, 1× and 2×.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in illustrations

Guidance for AI tools

Agent loop: An illustration of the agent loop: gather context, take action, verify, repeat, with a bright head circling three stations around the model. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components