Home / AI Architecture & System Design / AI System Design

AI System DesignSeniorQuestion 20 of 20

Design a real-time voice agent that handles customer-support phone calls.

30-second answer

Target ~1 s from the caller stopping to hearing a reply. Cascaded streaming pipeline: telephony and a media server, a per-call session with VAD, streaming ASR and an end-of-turn model, a fast LLM with cached instructions and tools, and streaming TTS that starts on the first clause. Budget: ~250 ms end of turn, 50 ms ASR final, 250 ms LLM first token, 180 ms first clause, 120 ms TTS, 100 ms network. Barge-in stops playback within ~200 ms and truncates the transcript to words actually played. Identity checks gate tools in code; filler speech covers slow tools; any failure transfers to a human. Compare with speech-to-speech models on latency vs control.

Try answering out loud before reading on. The walkthrough below is paced for a 40-minute interview round.

New to these terms? 11 terms on this page are explained in the glossary

0–5 min Functional requirements

Voice changes the problem from throughput to conversation timing. People expect a reply within about a second of stopping, and they interrupt. The design is mostly a latency budget plus turn-taking.

You Is this a phone agent for customer support, or a voice assistant in an app?

Interviewer Phone support for an internet provider: callers dial a number and talk to the agent.

You What can it do besides talk? Look up accounts, run line tests, book technicians?

Interviewer Yes, through internal APIs. And hand off to a human when needed.

You How many simultaneous calls?

Interviewer Up to 5,000 at peak.

# Functional requirement Why it matters
F1 Answer phone calls and hold a natural spoken conversation The product
F2 Handle interruptions (barge-in): stop speaking when the caller talks Feels broken without it
F3 Call tools: verify identity, look up the account, run a line test, book a technician Resolves problems, not just chats
F4 Hand off to a human with a summary when it can't help or the caller asks Required for support
F5 Transcripts and recordings for quality review and compliance Operations and legal

Out of scope: outbound calling campaigns, video, languages beyond English and Spanish initially.

5–10 min Non-functional requirements and estimates

You The key number is response latency: from the caller finishing a sentence to hearing the agent. I'll target ~1 s at p50 and ≤ 1.6 s at p95. Human conversation gaps are usually a few hundred milliseconds; beyond ~1.5 s it feels like a bad line.

Requirement Target What it forces
Response latency ≤ 1 s p50, ≤ 1.6 s p95 after the caller stops Streaming at every stage; small, fast models; co-located services
Barge-in Agent stops within ~200 ms of the caller starting to speak Voice activity detection on the input while playing; cancellable TTS
Transcription accuracy Low word error rate on names, numbers and addresses Domain vocabulary, spelling confirmation
Availability 99.95% for answering calls If the AI stack fails, route calls to the human queue
Concurrency 5,000 calls Streaming ASR and TTS capacity, media servers
Compliance Recording consent, PII redaction in transcripts, identity checks before account data Policy in the orchestration layer

Back-of-envelope estimates:

  • LLM requests: a caller speaks about every 15 s → 5,000 / 15 ≈ 330 LLM requests/s at peak. Each has ~3,500 input tokens (instructions, tools, transcript so far) and ~40 output tokens (spoken replies are short).
  • Streams: 5,000 concurrent streaming ASR sessions; TTS speaks ~40% of the time → ~2,000 concurrent TTS streams.
  • Audio bandwidth: phone audio (G.711, 8 kHz) is 64 kbps per direction → 5,000 × 64 kbps = 320 Mbps each way.
  • Recordings: 300k calls/day × 4 min × 2 channels at 64 kbps (16 KB/s together) ≈ 3.8 MB per call ≈ 1.2 TB/day before compression.
  • Latency budget (p50):
end-of-turn detection (silence + model)        250 ms
ASR final transcript                            50 ms
LLM time to first token (cached prefix)        250 ms
first clause (~12 tokens × 15 ms)              180 ms
TTS time to first audio                        120 ms
network and jitter buffers                     100 ms
total                                         ~950 ms

10–18 min High-level design

You A cascaded pipeline: telephony into a media server, streaming speech recognition with turn detection, an orchestrator running the LLM with tools, and streaming text-to-speech back. Everything streams, and the orchestrator can cancel any stage when the caller interrupts.

Scroll sideways to see the whole diagram.

Real-time voice agent for phone supportComponents: Streaming ASR (partials + finals); Fast LLM (cached instructions); Caller (phone); Telephony (numbers · SIP trunk); Media server (jitter · echo cancel); Call session (VAD · turns · barge-in); Orchestrator (LLM loop · policy); Streaming TTS (first clause first); Human agents (transfer + summary); Recordings (transcripts · redacted); Account tools (verify · test · book). Flow: Caller to Telephony; Telephony to Media server; Media server to Call session; Call session to Orchestrator; Call session to Streaming ASR (audio → text); Orchestrator to Fast LLM; Orchestrator to Streaming TTS (text); Orchestrator to Account tools; Streaming TTS to Media server (audio); Media server to Recordings; Telephony to Human agents (transfer).Streaming ASRpartials + finalsFast LLMcached instructionsCallerphoneTelephonynumbers · SIP trunkMedia serverjitter · echo cancelCall sessionVAD · turns · barge-inOrchestratorLLM loop · policyStreaming TTSfirst clause firstHuman agentstransfer + summaryRecordingstranscripts · redactedAccount toolsverify · test · bookaudio → texttextaudiotransfer
Real-time voice agent for phone support. Audio arrives over the phone network into a media server and a per-call session. Streaming ASR and an end-of-turn model decide when the caller has finished; the orchestrator runs a fast LLM with tools and streams the first clause to TTS, so the caller hears a reply in about a second. The session stops playback on barge-in. Any failure transfers the call to a human.

Components:

  • Telephony provider: phone numbers and the public phone network, connected by SIP trunk (or WebRTC for app calls).
  • Media server: terminates audio, handles jitter buffers, echo cancellation and recording, and streams 20 ms audio frames to the session.
  • Session (one per call): a stateful process that runs the pipeline for that call: voice activity detection (VAD), turn detection, conversation state and barge-in.
  • Streaming ASR: turns audio into partial and final transcripts in real time, with a custom vocabulary (plan names, street names).
  • Turn detector: decides when the caller has finished: silence length plus a small model that reads the partial transcript ("my account number is…" isn't finished; "it's been down since this morning." is).
  • Orchestrator + LLM: builds the prompt from the transcript, calls a fast LLM with tools, streams text out; enforces policy (identity verification before account tools).
  • Streaming TTS: turns text into audio sentence by sentence, starting with the first clause.
  • Tool services: account lookup, line test, booking; human handoff through the contact-centre platform.
  • Post-call pipeline: transcripts, summaries, quality scoring, PII redaction, analytics.

One turn, including an interruption:

Scroll sideways to see the whole diagram.

One voice turn, then a barge-inCaller → Session: audio, 20 ms frames; Session → ASR: stream audio; ASR → Session: partials, then final; Session: end of turn · 250 ms; Session → LLM: transcript + tools; LLM → Session: first clause · ~240 ms; Session → TTS: clause text; TTS → Caller: audio · ~120 ms; Caller → Session: speaks over agent; Session: barge-in after 180 ms; Session → TTS: stop + flush audio; Session → LLM: cancel; truncate history.CallerSessionASRLLMTTSaudio, 20 ms framesstream audiopartials, then finalend of turn · 250 mstranscript + toolsfirst clause · ~240 msclause textaudio · ~120 msspeaks over agentbarge-in after 180 msstop + flush audiocancel; truncate history
One voice turn, then a barge-in. Every stage streams: ASR partials feed the end-of-turn decision, the LLM's first clause goes to TTS before the rest is generated. When the caller talks over the agent, the session stops playback, cancels generation and cuts the agent's message to the words actually played.

How it works: a worked example

A study aid: one call traced turn by turn, with timings. The company is fictional.

The call. A caller dials Northwind Internet support. The media server answers; a session is created and the greeting (pre-generated audio, so no delay) plays: "Hi, this is Northwind's virtual assistant. How can I help?"

Turn 1. The caller says: "Hi, my internet's been down since this morning."

t=0 ms       caller stops speaking
t=0–250      VAD sees silence; turn detector reads "…down since this morning." → end of turn (0.94)
t=300        ASR final transcript
t=300        orchestrator sends the prompt (3,100 tokens, 2,900 cached): instructions, tools, transcript
t=540        first LLM tokens: "I'm sorry about that. Let me check your connection —"
t=700        first clause complete → TTS
t=820        first audio frame leaves TTS
t=900        caller hears "I'm sorry about that."

Meanwhile the LLM's output continues with a tool call: it needs the account first, so it asks: "Can I have the phone number on the account?" (Identity verification is required by policy before any account tool is allowed.)

Turn 2. The caller reads out the number. The turn detector waits longer here because digit sequences often contain pauses (it knows from the partial transcript that the caller is mid-number). ASR returns "five five five, zero one nine, two two four seven"; the orchestrator normalizes it to 5550192247, and the LLM calls verify_caller(phone="5550192247"), which sends a one-time code by SMS and asks for it. After verification, it calls run_line_test(account_id="A-77812").

A slow tool. The line test takes ~6 s. The orchestrator doesn't leave silence: the LLM's first clause was "I'm running a test on your line now, it takes a few seconds," which plays while the tool runs. If a tool exceeds ~700 ms and nothing is being said, a short filler plays.

Turn 3. Barge-in. The agent starts explaining: "The test shows your modem is offline. First, could you check that the power light on the modem is—" The caller interrupts: "Yeah it's off, I already unplugged it."

t=0     caller's voice detected while agent audio is playing (echo cancellation removes the agent's own voice)
t=180   speech continues past 180 ms → barge-in confirmed
t=190   TTS playback stopped, queued audio flushed, LLM generation cancelled
t=190   agent's last message in the transcript truncated to what was actually played:
        "The test shows your modem is offline. First, could you check that the power light on the modem is"

Truncating to what was heard matters: otherwise the LLM believes it said things the caller never heard.

Turn 4. Booking and handoff option. The LLM decides a technician is needed, calls find_slots(area="94110", days=3), offers two times, and calls book_technician(slot="2026-11-18T09:00") when the caller picks one. It confirms by reading the date back.

After the call. The recording and transcript go to the post-call pipeline: PII (the phone number, the one-time code) is redacted from the stored transcript, a summary is attached to the account, and a quality model scores the call for review sampling.

Where each piece runs:

Component Runs as Example technology If it fails
Telephony Provider + SIP trunks Twilio, Telnyx, a carrier Calls fail over to a second provider
Media server Regional media servers WebRTC/SIP media servers; LiveKit-style infrastructure Calls go to the human queue
Session + orchestrator Stateful process per call Python/Go; frameworks like Pipecat Restart the session with the transcript; apologize
ASR Streaming GPU service Hosted streaming ASR or self-hosted Whisper-class models Second ASR vendor; else human queue
Turn detector Small model in the session VAD (e.g. Silero) + end-of-turn classifier Fall back to a fixed silence threshold
LLM Low-latency hosted or self-hosted model Fast model with prompt caching Fallback model; else human handoff
TTS Streaming GPU service Hosted streaming TTS Second voice vendor
Tools Internal APIs REST/gRPC with timeouts The agent says it can't check right now and offers a human

18–32 min Deep dive

You I'd go deeper on the latency budget, turn-taking and interruptions, cascaded versus speech-to-speech models, and reliability.

Deep dive 1 · Winning back milliseconds

  • Stream everything. ASR emits partial transcripts; the LLM streams tokens; TTS starts on the first clause, not the full reply.
  • Start early (speculative turn handling). Run the LLM on the partial transcript as soon as the turn detector is fairly confident; if the caller keeps talking, cancel and discard. Wastes some LLM calls; saves ~200 ms.
  • Keep the prompt cacheable. Instructions and tool definitions first and unchanged; the transcript only appends.
  • Co-locate. ASR, LLM and TTS in the same region as the media server; every cross-region hop adds 50–100 ms.
  • Short first sentences. Instruct the model to lead with a short clause ("Sure, one moment.") so TTS can start immediately.

Deep dive 2 · Turn-taking and barge-in

  • End of turn: silence alone is a bad signal: too short and you cut people off mid-thought, too long and replies feel slow. Combine ~200–300 ms of silence with a model that reads the partial transcript (and ideally prosody) to judge whether the sentence is complete; wait longer for numbers and addresses.
  • Barge-in: VAD runs on the caller's audio even while the agent is speaking. Echo cancellation keeps the agent's own voice out. Brief sounds ("mm-hm") shouldn't stop the agent; require ~150–200 ms of speech, or classify backchannels.
  • Truncate history to what was heard. TTS reports word timings; when playback stops, cut the agent's message at the last word played.

Deep dive 3 · Cascaded pipeline vs speech-to-speech model

Cascaded (ASR → LLM → TTS) Speech-to-speech model
Latency ~1 s with careful streaming Often lower; no hand-offs between models
Naturalness TTS prosody; can't hear tone of voice Hears tone, emotion, hesitation; more natural
Control Text in the middle: guardrails, logging, deterministic checks Harder to inspect and constrain
Tool calling Mature in text LLMs Improving; check reliability for your tools
Swapping parts Pick the best ASR, LLM and TTS separately One vendor's model

For a support line with identity checks, tool calls and compliance logging, start cascaded; evaluate speech-to-speech models for latency and naturalness, possibly with a text transcript running alongside for policy checks.

Deep dive 4 · Reliability and safety

  • Fail to humans. Any stage failure routes the call to the human queue with the transcript so far. A caller should never hit dead air.
  • Session state (transcript, verified identity, tool results) is checkpointed so a crashed session process can resume the call on another worker.
  • Policy outside the model: account tools refuse to run until verify_caller has succeeded in this session, regardless of what the model asks.
  • Confirm before acting: read back dates, amounts and addresses before booking or changing anything.
  • Evaluation: simulated callers (an LLM playing scripted personas, with TTS and noise) run nightly against each version; measure task completion, latency percentiles, interruptions handled and wrongful handoffs.

32–37 min Trade-offs

Decision Chosen Alternative Why
Architecture Cascaded streaming pipeline Speech-to-speech model Control, tool reliability and compliance; revisit as models improve
End of turn Silence + transcript-based end-of-turn model Fixed silence threshold Fewer interruptions of the caller and faster replies
Early start Speculative LLM call on likely end of turn Wait for final transcript ~200 ms faster at the cost of some wasted calls
Model Fast mid-size LLM Largest model Latency budget; escalate to a human for hard cases
Failure Route to human queue Retry inside the call Dead air is the worst outcome
History after barge-in Truncate to words actually played Keep the full generated reply The model's view must match what the caller heard

Build first: telephony + media server, streaming ASR, LLM, TTS with fixed silence end-of-turn, one tool, human handoff. Then barge-in with truncation, the end-of-turn model, speculative starts, identity policy, simulated-caller evals.

37–40 min Wrap-up and likely follow-ups

Close with: "Audio streams from the phone network through a media server into a per-call session. Streaming ASR and an end-of-turn model decide when the caller is done; a fast LLM with cached instructions streams a reply whose first clause goes straight to streaming TTS, landing around one second. Barge-in stops playback within ~200 ms and truncates the transcript to what was heard. Tools are gated by identity verification in code, slow tools are covered with speech, and every failure routes to a human."

Likely follow-ups:

  • How do you handle accents and noisy lines? Evaluate ASR on real call audio by segment, add custom vocabulary, confirm critical values by reading them back or asking callers to spell them.
  • How would you add a new language? Per-language ASR and TTS voices, translated and re-tested instructions, and language detection on the first utterance.
  • How do you measure success? Containment rate (calls resolved without a human), customer satisfaction, average handle time, and latency percentiles per stage.

Further reading

What interviewers listen for

  • A millisecond latency budget per stage and streaming between every stage.
  • Turn detection beyond a silence timer, and barge-in with transcript truncation.
  • A reasoned choice between cascaded and speech-to-speech.
  • Policy enforced in code, and humans as the fallback.

Red flags

  • Waiting for the full LLM reply before starting TTS.
  • No interruption handling.
  • Letting the model decide on its own when identity is verified.
  • Dead air during slow tool calls.

Discussion

Help us improve our content — give feedback. Spotted an error, have a better explanation, or got asked a follow-up in a real interview? Share it here.