{"slug":"voice-agent-relay","category":"voice","job":"oversee","added":"2026-11-08T16:23Z","title":"Voice Agent Relay","description":"A realtime voice call with a voice agent that hands work to a working agent, answers questions about its progress and speaks short updates and a summary while it runs.","url":"https://ai-patterns.app/patterns/voice/voice-agent-relay","markdown":"https://ai-patterns.app/patterns/voice/voice-agent-relay.md","json":"https://ai-patterns.app/api/patterns/voice/voice-agent-relay","seenIn":[{"team":"Cursor","source":"https://cursor.com/changelog/voice-chat"}],"spec":"# Voice Agent Relay\n\n## Summary\nA realtime voice call with a front-line voice agent that hands work to a separate working agent and keeps the person posted while it runs. The person describes a change out loud, can ask what the agent is doing at any point, and hears short progress notes and a spoken summary at the end — without reading the full written output. A run strip shows the working agent's status, and the transcript marks hand-offs, progress notes and the summary apart from conversation.\n\n## When to use\n- A working agent runs tasks that take minutes, and people want to delegate and follow them hands-free or away from the screen (walking, cooking, on a phone).\n- The product already has an agent that edits code, documents or projects; voice is a way in, not a separate assistant.\n- People want to ask \"how's it going?\" or \"what changed?\" without opening the run's trace or diff.\n\n## When not to use\n- The voice conversation is the work itself (a voice assistant answering questions). Use **Voice Orb** or **Listening State** for that.\n- Speech is only an input method. Dictation that turns speech into text in the composer is simpler and keeps the person in control of what is sent.\n- Runs that need careful review before anything is applied. Speak the summary, but route approvals to the screen — don't ask people to approve diffs by ear.\n- Shared or noisy spaces where speaking or playback is impractical; always keep the text chat as an equal path.\n\n## Anatomy\n- Start voice chat: the composer's Send slot becomes a waveform button when the agent is idle and the input is empty, so starting a call costs no extra space.\n- Run strip: the working agent's task title, its current step in a few words, and a status (Agent working / Done).\n- Transcript: the last few lines of the call — what the person said, what the voice agent said back, and three marked kinds of relay lines: **Handed to agent** (the request as passed on), progress notes, and the **Summary**.\n- Call bar: who is talking (Listening / Speaking / Muted), elapsed time, a live waveform, Mute and End.\n- Outside the app: the same mute and end controls on the lock screen or system call UI, where the platform allows.\n\n## Behavior\n- The voice agent restates the request before handing it off (\"Got it — I'll ask the agent to…\"), so a misheard instruction is caught before work starts. The hand-off line shows the exact request passed on.\n- The person can keep talking while the working agent runs. Questions about progress are answered from the run's live state, not guessed.\n- New requests mid-run are added to the run as further hand-offs; they don't start a parallel run unless the person asks.\n- Progress notes are short and sparse — one when the work moves to something new, not one per tool call.\n- When the run ends, the voice agent speaks a brief summary (what changed, how many files, anything that needs a look) and points to where the full reply and diff are. The written reply still lands in the chat.\n- Mute stops listening but leaves the call and the run going. End stops the call only — it never cancels the working agent's run.\n- If the working agent needs approval or hits an error, say so out loud and show it on screen; don't wait for the person to ask.\n\n## Content guidelines\n- Spoken lines are one or two short sentences. Lead with the outcome: \"Done. Three files changed…\", not \"So I've been looking into…\".\n- Hand-off lines are imperative and specific, as the working agent received them: \"Add a Monthly / Annual toggle to pricing, annual at 20% off\".\n- Progress notes name the thing, not the tool: \"It's editing pricing.tsx\", not \"Running apply_patch\".\n- Say numbers and file names plainly; leave paths, code and diffs to the screen.\n\n## Accessibility\n- The start button, Mute and End are real buttons with accessible names; Mute uses `aria-pressed`.\n- What the voice agent says is mirrored as text and announced through a polite live region, so the call works with a screen reader and for people who can't hear the audio. The person's own transcript isn't announced back to them.\n- Relay lines carry text labels (\"Handed to agent\", \"Progress\", \"Summary\"), not only icons.\n- Never make voice the only way to do something — every request and every result is also available in the text chat.\n- The waveform is decorative; call state is given in text. Under `prefers-reduced-motion`, new lines fade in without sliding.\n\n## Related patterns\n- **Voice Orb** — Use it instead when the voice conversation is the work, not a channel to another agent.\n- **Listening State** — Use it for the moment of capture when voice only fills the composer.\n- **Background Tasks Drawer** — Use it as well to show the same run on screen, with stop controls.\n- **Diff Summary Card** — Use it as well for the written result the spoken summary points to.\n","code":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { ArrowRightLeft, CircleCheck, LoaderCircle, Mic, MicOff, PhoneOff, Volume2 } from \"lucide-react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { VoiceWaveform } from \"../voice-waveform/component\";\n\n/** Who is talking on the call right now. */\nexport type RelayCallState = \"listening\" | \"speaking\" | \"muted\";\n\nexport type RelayItem =\n  /** What the person said, as a short transcript line. */\n  | { id: string; kind: \"you\"; text: string }\n  /** What the voice agent said back. */\n  | { id: string; kind: \"voice\"; text: string }\n  /** The voice agent passed a request to the working agent. */\n  | { id: string; kind: \"handoff\"; text: string }\n  /** A short progress note the voice agent read out while the work ran. */\n  | { id: string; kind: \"update\"; text: string }\n  /** The spoken summary when the run finished. */\n  | { id: string; kind: \"summary\"; text: string };\n\nexport interface RelayRun {\n  /** The working agent's task, as the voice agent handed it over. */\n  title: string;\n  status: \"running\" | \"done\";\n  /** What it is doing now, in a few words (\"Editing pricing.tsx\"). */\n  step?: string;\n}\n\nexport interface VoiceAgentRelayProps {\n  state: RelayCallState;\n  /** The call so far, oldest first. Only the last few lines are shown. */\n  items: RelayItem[];\n  /** The run the voice agent is relaying, once something has been handed off. */\n  run?: RelayRun | null;\n  /** Elapsed call time, already formatted (\"1:24\"). */\n  elapsed?: string;\n  onToggleMute: () => void;\n  onEnd: () => void;\n  /** How many recent lines to keep on screen. */\n  visibleItems?: number;\n  className?: string;\n}\n\nconst STATE_LABEL: Record<RelayCallState, string> = {\n  listening: \"Listening\",\n  speaking: \"Speaking\",\n  muted: \"Muted\",\n};\n\n/**\n * A realtime voice call with a front-line voice agent that relays work to a\n * separate working agent. The call bar shows who is talking; the run strip\n * shows what the working agent is doing; the feed keeps the last few spoken\n * lines, with hand-offs, progress notes and the final summary marked apart\n * from conversation, so a glance tells what was asked and what came back.\n */\nexport function VoiceAgentRelay({\n  state,\n  items,\n  run,\n  elapsed,\n  onToggleMute,\n  onEnd,\n  visibleItems = 4,\n  className,\n}: VoiceAgentRelayProps) {\n  const reduce = useReducedMotion();\n  const recent = items.slice(-visibleItems);\n  const last = items[items.length - 1];\n  const muted = state === \"muted\";\n\n  return (\n    <section\n      aria-label=\"Voice chat with agent\"\n      className={cn(\"flex flex-col overflow-hidden rounded-2xl bg-card border\", className)}\n    >\n      {run && <RunStrip run={run} />}\n\n      <ol className=\"flex min-h-28 flex-col justify-end gap-1.5 px-4 py-3\" aria-label=\"Call transcript\">\n        <AnimatePresence initial={false}>\n          {recent.map((item) => (\n            <motion.li\n              key={item.id}\n              layout={!reduce}\n              initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6 }}\n              animate={{ opacity: 1, y: 0 }}\n              transition={{ duration: 0.2, ease: \"easeOut\" }}\n            >\n              <RelayLine item={item} />\n            </motion.li>\n          ))}\n        </AnimatePresence>\n      </ol>\n\n      {/* Announce only what the voice agent says, not every transcript tick. */}\n      <p className=\"sr-only\" aria-live=\"polite\">\n        {last && last.kind !== \"you\" ? last.text : \"\"}\n      </p>\n\n      <div className=\"flex items-center gap-3 border-t bg-muted/30 px-3 py-2\">\n        <span className=\"flex min-w-16 flex-col\">\n          <span className=\"text-xs font-medium\">{STATE_LABEL[state]}</span>\n          {elapsed && <span className=\"text-[11px] tabular-nums text-muted-foreground\">{elapsed}</span>}\n        </span>\n        <VoiceWaveform\n          state={muted ? \"idle\" : state}\n          barCount={21}\n          className={cn(\"h-8 flex-1\", state === \"speaking\" ? \"text-foreground\" : \"text-muted-foreground\")}\n        />\n        <button\n          type=\"button\"\n          onClick={onToggleMute}\n          aria-pressed={muted}\n          className={cn(\n            \"flex size-8 items-center justify-center rounded-full transition-colors hover:bg-foreground/10 bg-muted\",\n            muted && \"bg-foreground text-background hover:bg-foreground/90\"\n          )}\n        >\n          {muted ? <MicOff className=\"size-4\" aria-hidden /> : <Mic className=\"size-4\" aria-hidden />}\n          <span className=\"sr-only\">{muted ? \"Unmute\" : \"Mute\"}</span>\n        </button>\n        <button\n          type=\"button\"\n          onClick={onEnd}\n          className=\"flex h-8 items-center gap-1.5 rounded-full bg-destructive px-3 text-xs font-medium text-white transition-colors hover:bg-destructive/90\"\n        >\n          <PhoneOff className=\"size-3.5\" aria-hidden />\n          End\n        </button>\n      </div>\n    </section>\n  );\n}\n\nfunction RunStrip({ run }: { run: RelayRun }) {\n  const done = run.status === \"done\";\n  return (\n    <div className=\"flex items-center gap-2 border-b bg-muted/30 px-4 py-2 text-xs\">\n      {done ? (\n        <CircleCheck className=\"size-3.5 shrink-0 text-muted-foreground\" aria-hidden />\n      ) : (\n        <LoaderCircle className=\"size-3.5 shrink-0 animate-spin text-muted-foreground motion-reduce:animate-none\" aria-hidden />\n      )}\n      <span className=\"min-w-0 flex-1 truncate\">\n        <span className=\"font-medium\">{run.title}</span>\n        {run.step && !done && <span className=\"text-muted-foreground\"> · {run.step}</span>}\n      </span>\n      <span className=\"shrink-0 text-muted-foreground\">{done ? \"Done\" : \"Agent working\"}</span>\n    </div>\n  );\n}\n\nfunction RelayLine({ item }: { item: RelayItem }) {\n  switch (item.kind) {\n    case \"you\":\n      return (\n        <p className=\"text-sm\">\n          <span className=\"sr-only\">You: </span>\n          {item.text}\n        </p>\n      );\n    case \"voice\":\n      return (\n        <p className=\"text-sm text-muted-foreground\">\n          <span className=\"sr-only\">Voice agent: </span>\n          {item.text}\n        </p>\n      );\n    case \"handoff\":\n      return (\n        <p className=\"flex items-center gap-1.5 text-[11px] text-muted-foreground\">\n          <ArrowRightLeft className=\"size-3 shrink-0\" aria-hidden />\n          <span>\n            Handed to agent: <span className=\"text-foreground\">{item.text}</span>\n          </span>\n        </p>\n      );\n    case \"update\":\n      return (\n        <p className=\"flex items-center gap-1.5 text-[11px] text-muted-foreground\">\n          <Volume2 className=\"size-3 shrink-0\" aria-hidden />\n          <span>\n            <span className=\"sr-only\">Progress: </span>\n            {item.text}\n          </span>\n        </p>\n      );\n    case \"summary\":\n      return (\n        <p className=\"rounded-lg bg-muted/60 px-2.5 py-1.5 text-sm\">\n          <span className=\"mb-0.5 block text-[11px] font-medium text-muted-foreground\">Summary</span>\n          {item.text}\n        </p>\n      );\n  }\n}\n","dependencies":["lucide-react","motion"],"localImports":["@/lib/utils"]}