esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

Design a Voice Agent

How to design a voice agent: the call loop, the wait before the first word, letting callers interrupt, and safe tools, explained simply for your AI interview.

In short

A voice agent is an AI that talks with a caller in real time. It needs a sound link, a turn detector that spots when the caller stops, a model with tools, and speech out, with a code check before any action. The hard parts are the wait before the first word and letting callers interrupt.

14 min readAdvancedOccasional · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

A voice agent is an AI that talks on a phone line or in an app. I build it as a loop: a link that carries the sound, a turn detector that spots when the caller has finished, a model that asks my systems for facts, and speech back out. The hard part is timing. I budget the wait before the first word, let callers cut in, and check every money action in code before it runs.

What is a voice agent, in plain words?

A voice agent is an AI that talks with a person on a phone line or in an app, while the conversation happens. It hears, decides what to do, and speaks back. Getting the words right is the simple part. Timing is where it gets hard, because a pause that feels normal to a person can feel broken to a caller.

Picture a bank's call-centre agent on the card line at two in the morning. They listen, check the account on screen, and answer. A voice agent runs the same loop, but it has to keep pace with the caller.

A real case: a customer reports a lost card late at night. The agent must check who they are, freeze the card, read back the last four digits, and hand any fraud claim to a person.

Key words

Turn
One thing the caller says, then the agent's reply.
Turn detector
The part that decides the caller has finished speaking.
Barge-in
The caller talks over the agent, and the agent should stop.
Time to first word
How long the caller sits in silence before the agent starts talking.
Latency
The delay the caller feels between their last word and the agent's first word.

How does one caller turn flow through the system?

Five parts work as a loop: a link, a turn detector, a model, its tools, and speech out. The link carries the sound. Phone calls can come in through a SIP trunk (a phone connection that runs over the internet), as OpenAI's phone guide describes. An app uses a browser connection. The turn detector watches for the end of speech. The model decides what to say, and its tools fetch facts. Speech out turns the reply into sound.

  • “The key design choice is how speech connects to reasoning and tools: a continuous conversation with a separate backend, a single voice model, or a pipeline you control stage by stage.”

    OpenAI

The first choice is how the sound reaches the model. A speech-to-speech model hears sound and speaks sound back in one step. A pipeline chains separate steps: speech to text, a text model, then text to speech. Either way the loop stays the same: the model asks for facts and proposes actions, and your code runs them after its checks.

One caller turn, end to end

Caller

speaks on the phone or in an app

Hear the turn

Phone or app link

SIP for phones, browser audio for apps

Turn detector

decides the caller has finished

Model

decides what to say and look up

Your systems

Card and account data

code checks each request first

Speech out

turns the reply into sound

Caller hears

and can cut in at any point

  1. 1The caller speaks into the phone line or the app.
  2. 2The link passes the sound on to a turn detector.
  3. 3When the caller stops, the model takes the turn.
  4. 4The model asks your system for the facts it needs.
  5. 5The result comes back, and the model uses it.
  6. 6The reply goes to speech, which starts playing.
  7. 7The caller hears it, and can cut in at any time.
One caller turn. The link carries the sound in, a turn detector decides the caller has finished, and the model asks your systems for facts. The result loops back to the model before the reply is spoken.

On a phone line, the telephone provider carries the call audio, and your backend handles the session settings, the call controls and the business logic. OpenAI's guide for phone calls describes the same split.

Where does the wait before the first word come from?

Callers feel silence on a call, so the wait before the first word matters. Four things add up before the first word plays: the turn detector waiting for quiet, speech to text, the model's first words, and speech out. The bank's own lookup adds time too.

OpenAI's latency guide calls the model's start-up time "time to first token", and says it "measures how long an API request takes to start returning content". Each step in a row adds its own wait. The guide is blunt: "Each sequential model or tool call adds another wait." The fix is to run independent work at the same time: "Run independent work concurrently."

A read-only lookup (one that reads data and changes nothing) can start earlier still, as soon as the words so far point to it. The guide's advice for an uncertain branch is to "consider starting a read-only lookup early and discarding it if it's unnecessary".

Where the first word comes from

Caller stops

the wait starts here

Hear the caller

Silence rule

500 ms of quiet, made up

Speech to text

250 ms for the final text

At the same time

Model's first words

300 ms to the first token

Card lookup

350 ms in your system

Speech out

200 ms to the first sound

Caller hears

1450 ms, incl. 150 ms network

  1. 1The clock starts when the caller stops talking.
  2. 2The silence rule waits for quiet, then speech to text runs.
  3. 3The model starts its first words as soon as the text is ready.
  4. 4A read-only lookup can start from the words, in your system.
  5. 5Speech out begins once the model's words arrive.
  6. 6Speech out also waits for the lookup, if that is slower.
  7. 7The caller hears the first word after 1450 ms, made-up timings.
Where the first word comes from, with made-up timings. The silence rule waits for quiet (500 ms here, cut to 250 ms later). The model and the card lookup start together, but a reply that needs the lookup still waits for it.

Here is the budget as a simple program. It is a simplified sum, not a measurement. In a real system I time each stage on real calls.

Python
# One caller turn on a bank's card line (simulated, made-up timings in milliseconds).
BUDGET_MS = 1200  # target: the caller hears the first word within 1.2 seconds

def first_word_ms(silence, speech_to_text, model_first, lookup, speak, network, parallel):
    # Parallel only when the first words do not need the lookup result.
    wait = max(model_first, lookup) if parallel else model_first + lookup
    return silence + speech_to_text + wait + speak + network

def barge_in(agent_talking, caller_ms):
    # The caller talking over the agent for 200 ms or more counts as a cut-in.
    if agent_talking and caller_ms >= 200:
        return "stop audio, keep what was already said"
    return "keep talking"

for parallel in (False, True):
    total = first_word_ms(500, 250, 300, 350, 200, 150, parallel)
    label = "parallel" if parallel else "one after another"
    print(label + ": first word at " + str(total) + " ms")
    print("  over budget by " + str(total - BUDGET_MS) + " ms" if total > BUDGET_MS else "  within budget")
total = first_word_ms(250, 250, 300, 350, 200, 150, True)
print("parallel, 250 ms silence rule: first word at " + str(total) + " ms")
print("  within budget" if total <= BUDGET_MS else "  over budget")
print("Caller cuts in:", barge_in(True, 260))
print("Caller only breathes:", barge_in(True, 80))

Output

one after another: first word at 1750 ms
  over budget by 550 ms
parallel: first word at 1450 ms
  over budget by 250 ms
parallel, 250 ms silence rule: first word at 1200 ms
  within budget
Caller cuts in: stop audio, keep what was already said
Caller only breathes: keep talking

With the made-up timings, the 250 ms silence rule brings the wait to the 1200 ms target. It has a cost: callers who pause to think get cut off. Test it with real pauses before you ship it, and check the cut-offs too.

How do you let the caller interrupt the agent?

A caller who talks over the agent is normal. People cut in when they hear the answer they need, or when they hear a wrong one. The system has to notice the caller's voice while the agent is still speaking, stop the audio at once, and listen.

  1. 1

    Keep listening while the agent speaks

    Keep the turn detector running during speech, so a cut-in can be heard.

  2. 2

    Stop the audio at once

    Cut the playing audio, so the caller does not hear the agent repeat itself.

  3. 3

    Log what was actually heard

    Keep the part of the reply the caller heard, so the next turn starts from the right place.

  4. 4

    Treat the new words as the next turn

    The caller's cut-in is simply the next thing to answer.

Two settings matter most. OpenAI's guide says: "A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments." That helps on a busy street, but it can miss a quiet cut-in. The guide also says: "With shorter values turns will be detected more quickly." That is the silence rule again.

A newer mode, semantic detection, decides the caller has finished from the words they have said, with a timeout behind it. OpenAI's guide says: "With this mode, the model is less likely to interrupt the user during a speech-to-speech conversation, or chunk a transcript before the user is done speaking." It suits callers who pause mid-thought, but it is a setting to test on your own calls.

Tip

Watch for the agent hearing itself. Its own voice can come back into the microphone and look like a cut-in. Use echo cancellation (the part that removes the agent's own voice from the microphone) on the audio link, and test with the speaker on.

What must the agent never get wrong, and how do you test it?

Voice makes mistakes feel personal. The agent must not read out an account to someone who has not proved who they are, and it must not freeze or move money on a guess.

  • Identity

    Check before facts

    Verify the caller in code before any balance or card detail is read out.

  • Money or card

    Code says yes

    A freeze, transfer or refund runs only after code checks the card and the caller, and the caller confirms it aloud.

  • Unclear case

    Hand to a person

    When the request is outside the rules, or the model is unsure, the call moves to a human with a short summary.

  • “Route privileged calls through a deterministic policy engine that re-validates intent and arguments at execution time.”

    OWASP 2026

  • “Wait for required checks before displaying a result or taking an action such as issuing a refund.”

    OpenAI

The checks in code are the part that holds. Treat the model as one layer, with code checks behind it. OpenAI's voice agents guide says its session "handles audio turns, tools, interruptions, and handoffs", so the design must decide in advance what the session may do alone and what it must pass to a person.

Testing needs scripted callers, because each live call is a new conversation. OpenAI's guide puts it plainly: "Repeat scenarios and compare task completion, audible response latency, interruptions, and unwanted silence." So I write callers who pause for two seconds, cut in mid-sentence, mumble a card number, or come through a bad line.

  • Task done

    Did the card get frozen once, and only once, after the check?

  • Speed

    The typical wait (the median), and the 95th percentile: the wait that 19 calls in 20 beat. Measure both on the scripted calls and on representative traffic.

  • Cut-ins

    Did the agent stop quickly, and did the log match what the caller heard?

  • Silence

    How often did the caller sit in silence for too long?

Tip

Run each scenario many times, with a few voices and noise levels. The 95th percentile shows the slow calls that the average hides.

What does the interviewer want to hear?

A strong answer covers

  • A loop with its parts named: link, turn detector, model, tools, speech out.
  • A first-word budget, with the slowest stage named.
  • The lookup runs beside the model when the reply does not need it, and a read-only lookup can start early.
  • Interruptions handled: listen during speech, stop the audio, log what was heard.
  • Every money or account action checked in code, with a person for unclear cases.
  • Testing with scripted callers and percentiles, not one good demo call.

Common traps

  • Trap"The model is the whole system."

    BetterThe model is one part. The link, turn detector, code checks, logs and human handoff carry much of the risk.

  • Trap"We make the silence rule as short as possible."

    BetterA short rule cuts people off. Choose it with real pauses, then measure the cut-offs too.

  • Trap"One good demo call proves it works."

    BetterOne call proves little. Run the scenario set many times and track the wait at the 95th percentile.

Can you spot the problem?

Spot the cut-in bug

A caller on the card line talks over the agent. Which snippet lets them cut in?

Quick check

A bank's voice agent answers in about 2.4 seconds, mostly while the silence rule waits. What is the first change to try?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q445ASR + LLM + TTS pipeline vs speech-to-speech models?11 min
  2. Q369How do you design for low latency?13 min
  3. Q366Design human approval for risky agent actions.13 min
  4. Q344What is a p95/p99 latency budget?11 min
  5. Q172When and how do you add a human in the loop?12 min

Learn it in depth

Last updated on 27 November 2026

Building a voice agent for a phone line or an app?

I design and build AI agents, including the voice layer: the call flow, interruptions, checks on every tool call and tests with scripted callers. Book a short call and tell me what your callers need.