JoinInDocs
Baton
v2 (beta)
Get a key
Baton v2 Guides BetaMarkdown

Barge-in

Tell a real interruption from a backchannel while your agent is speaking, and keep your agent's own voice from interrupting it.

When a user speaks over your agent, you need to know quickly whether to stop. "Wait, no" is a claim on the floor; "mm-hmm" is a backchannel and your agent should keep going.

Barge-in works on every /v2 endpoint. In a room it reacts to anyone in the room speaking over your agent.

  1. Subscribe

    Add bargein to signals in session.start. If session.started.models.bargein is null, barge-in is unavailable for this session and no barge-in events will arrive.
    {
      "type": "session.start",
      "api_key": "baton_...",
      "eot": {"profile": "cutoff_5pct"},
      "signals": ["bargein"]
    }
    
  2. Tell Baton what your agent says

    Send agent.speech when your agent starts and stops talking, with what it says:
    {"type": "agent.speech", "phase": "start", "utterance_id": "sp_1",
     "text": "Take a deep breath...", "duration_s": 4.2}
    {"type": "agent.speech", "phase": "end", "utterance_id": "sp_1"}
    
    See Tell Baton what your agent says for why the text matters.
  3. Act on the classification

    {"type": "bargein.onset", "seq": 7, "t": 12.1,
     "agent_speaking": true, "utterance_id": "sp_1"}
    {"type": "bargein.class", "seq": 8, "t": 12.4,
     "class": "claim", "p_claim": 0.9, "decided_after_ms": 300,
     "utterance_id": "sp_1"}
    
    On claim, stop speaking and listen. On backchannel, keep going. A spoken stop word decides at once, and says which word it was:
    {"type": "bargein.class", "seq": 9, "t": 15.2,
     "class": "claim", "text": "stop", "intent": "stop",
     "p_claim": null, "decided_after_ms": 100, "utterance_id": "sp_2"}
    

Tell Baton what your agent says

Telling Baton what your agent is saying makes its predictions better exactly where they are hardest: quiet users, noisy rooms, speakerphones, and short one-word answers.

  • Your agent's own voice is ignored. On a speakerphone, or a laptop without headphones, the microphone hears your agent again. If Baton knows what your agent is saying, that sound never stops your agent and never opens a turn. An echoed "stop" from your agent does nothing; a "stop" from the user still stops it.

If your audio never carries your agent's voice (headphones, or your own echo cancellation), send "echo": "off" in session.start. Speech over your agent is then the user's at once: it opens a turn and counts as barge-in, with no wait to rule out an echo. session.started says which is in force. - The user is still heard over it. A stop word, one of your answer words, or the user's own speech still gets through while your agent talks. - Answers you expect are recognised. Add expect to a question and Baton tells you which answer the user gave, with a confidence, so your agent can act on it at once (Expected answers).

What to send on agent.speech:

  • phase: start when your agent starts talking, end when it stops. Send start before the first of your agent's audio can reach the user's speaker; on a phone that can be within 50 ms of playback, so send it just before you start playing.
  • text and duration_s: what your agent says, and how long it plays. duration_s can come on start or, if you only know it later, on end.
  • Or words, if your text-to-speech gives word times: [{"w": "Take", "t0": 0.00, "t1": 0.18}, ...], in seconds from start.
  • expect on a question: the answers you expect.
  • utterance_id: your id for the utterance, echoed on barge-in events (null if you send none).
{"type": "agent.speech", "phase": "start", "utterance_id": "sp_1",
 "words": [{"w": "Take", "t0": 0.00, "t1": 0.18},
           {"w": "a", "t0": 0.18, "t1": 0.25}]}
{"type": "agent.speech", "phase": "end", "utterance_id": "sp_1", "duration_s": 4.2}

Every field but phase is optional. start and end alone are enough for barge-in over headphones; without text or words, Baton cannot tell your agent's echo from the user. If playback stops early, send end with the duration_s that actually played. Over headphones or with your own echo cancellation, "echo": "off" in session.start skips echo handling altogether (Your agent's echo). phase: "end" drops an interruption that has not been classified yet. phase values other than start and end are ignored. duration_s is at most 3600.

How it decides

  • bargein.onset is the start of user speech while your agent is speaking.
  • Baton classifies the interruption as soon as it is confident, typically a few hundred milliseconds in. decided_after_ms reports how long it took.
  • p_claim is the probability, from 0 to 1, that the user is taking the floor: near 1 a clear claim, near 0 a backchannel. It is null when the user stopped too soon to judge (reported as a backchannel) and on a claim decided by a stop or answer word, which needs no probability.
  • A claim decided by a word carries text (the word or phrase, as in the list) and intent: stop or answer.

Stop words and answers

A stop word ("stop", "wait", "hold on", "never mind") or a floor grab ("no", "actually", "sorry") decides a claim with intent: "stop" the moment Baton hears it, with no minimum duration. A stop said later in a longer interruption still counts. "Go on", "yeah" and "mm-hmm" decide nothing on their own.

A stop word is never overruled, also not by a backchannel already sent for the same interruption: a claim then follows it. The one exception is your agent's own echo. A claim decided by a word brings its own bargein.onset when none was open; that onset can carry a t earlier than the claim's. Baton sends at most one such claim per agent utterance.

Set your own words with keywords in session.start:

{
  "type": "session.start",
  "api_key": "baton_...",
  "signals": ["bargein"],
  "keywords": {
    "stop": ["stop", "wait", "pause", "hold on"],
    "answer": ["yes", "no", "ready", "feel good", "feel bad"]
  }
}
List Default Decides
stop "stop", "wait", "hold on", "pause", "quiet", "enough", "cancel", "never mind", … claim, intent: "stop"
answer none claim, intent: "answer"
  • A list you send replaces that list's defaults; a list you leave out keeps them. That is how you remove a default that misfires for you.
  • Use answer for answers that should cut your agent short, such as "ready" while it explains how to get ready. An expect answer does not interrupt your agent unless you list it here too.
  • Entries are one or two words (answer: up to three); case and punctuation are ignored. Answers match number words and digits alike ("seven" = "7").
  • A bad list or entry closes the session with 1008.
{"type": "bargein.class", "seq": 11, "t": 18.7,
 "class": "claim", "text": "ready", "intent": "answer",
 "p_claim": null, "decided_after_ms": 600, "utterance_id": "sp_2"}

In a room

On /v2/room, anyone in the room can barge in. Two things work better than on a stream:

  • A stop said over your agent's own "stop" is not lost. If someone in the room says "stop" just as your agent's echo does, it is still acted on, marked confirmed_by: "two_speakers":

json {"type": "bargein.class", "seq": 14, "t": 21.0, "class": "claim", "text": "stop", "intent": "stop", "confirmed_by": "two_speakers", "p_claim": null, "decided_after_ms": 0, "utterance_id": "sp_3"}

  • Someone talking over the echo is heard at once, instead of after your agent's echo ends.

Baton computes no voiceprint and keeps no voice identity after the agent utterance.

Stop on bargein.onset if you want the fastest reaction, and resume if bargein.class says backchannel. Stop on bargein.class if you want your agent never to stutter on an "mm-hmm".

Last updated 21 Oct 2026