Skip to main content
HS
HiSETSuccess
LeetCode Prep

AI & FDE Interview Room

Role paths, mocks, cost studio, chapters, cases, and staff-level depth.

Case study · Architect · 35 min

Low-Latency Voice Agent

Design a phone/voice agent that keeps conversational latency under ~800ms turn-taking while calling tools.

voicelatencystreaming

Interview opener

Voice agent with tight latency budget end-to-end.

  1. 1.Where do you spend the latency budget first?
  2. 2.Streaming vs waiting for full tool results?
  3. 3.What do you cut when p95 blows the SLO?

Strong signals

Hit 0/3

Weak signals (avoid)

  • Only 'use a faster model'
  • No budget allocation

Requirements

  • Channels: PSTN + webRTC; barge-in supported
  • Latency: user stop-talk → agent first audio < 800ms p95
  • Quality: WER < 8% English; task completion ≥ 70%
  • Scale: 200 concurrent calls; avg 4 min

Back-of-envelope Estimation

MetricCalculationResult
Concurrent calls200200
Audio streams200 × 2400
ASR cost200 × 4 min × $0.006/min~$4.80 / 4min burst
LLM tokens/call~8K1.6M tokens / 200 calls
Budget splitASR 150ms + LLM 400ms + TTS 200ms750ms
Tool callstimeout 300ms or speak fillerUX critical

API Design

EndpointMethodDescription
WS /v1/voice/sessionWSBidirectional audio + events
POST /v1/voice/tools/resultPOSTAsync tool completion callback
POST /v1/voice/hangupPOSTEnd + store transcript

Data Model

EntityKey fieldsNotes
callscall_id, from, started_at, outcomeCDR
utterancescall_id, role, text, t_msTimed transcript
latency_spanscall_id, stage, msASR/LLM/TTS/tool

High-level Design

Streaming pipeline
Mic → VAD → streaming ASR (partials)
          → endpointing → LLM stream (token→TTS early)
          → streaming TTS → jitter buffer → speaker
Parallel: speculative tool prefetch on intent
Barge-in: cancel TTS + LLM on user speech
Edge colocated ASR/TTS with LLM region affinity

Deep Dive: Beating the 800ms Budget

  • Start TTS on first sentence tokens; don't wait for full answer
  • Use small specialized LLM for dialog; escalate hard tasks async
  • Filler audio ("one moment") only when tool > 400ms — measure annoyance
  • Colocate ASR→LLM→TTS in one region; avoid multi-hop oceans

Bottlenecks at Scale

  • Endpointing errors cause interruptions — tune VAD per accent
  • TTS GPU pool saturation — precompute common phrases
  • PSTN jitter — adaptive buffer 20–60ms

Failure Modes & Monitoring

SLOTargetAlert
First audio p95< 800msPage if > 1.2s
Barge-in success> 95%Warn
Call completion≥ 70%Weekly
Silent calls< 0.5%Page

Attempt the case aloud first. Then unlock a staff model answer outline.