Detect Caller Barge-Ins During Agent Speech Playback

Last updated: November 29, 2026

Quick Overview

Given sorted, non-overlapping intervals when the agent's audio is playing and when the caller is speaking, return for each agent utterance the time playback should be cut, which is the moment cumulative overlapping caller speech reaches min_overlap_ms.

Retell AI
Coding & Algorithms
Software Engineer
Retell AI
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given sorted, non-overlapping intervals when the agent's audio is playing and when the caller is speaking, return for each agent utterance the time playback should be cut, which is the moment cumulative overlapping caller speech reaches min_overlap_ms.

Interruption handling is a core part of making Retell agents feel natural: the agent should stop talking when the caller really interrupts, but not on a cough or a short backchannel. The interviewer checks a two-pointer sweep over two interval lists and precise computation of the cut time.

What the Interviewer Expects
  • Use two pointers instead of comparing every pair
  • Accumulate overlap per agent utterance across multiple caller segments
  • Compute the exact cut timestamp, not only a boolean
  • Avoid re-scanning caller segments already fully in the past
  • State complexity O(a + u) amortized and note where it is not
Key Topics to Cover
two pointers
interval overlap
barge-in
streaming audio
turn-taking
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you ignore backchannels like 'mm-hmm' using transcript text as well as timing?
  • How would you run this online with 20 ms audio frames?
  • What happens to the LLM context when playback is cut mid-sentence?
  • How would you tune min_overlap_ms per language or per customer?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

agent and user are each sorted and non-overlapping lists of (start, end) ms. For each agent utterance, add up overlap with caller speech in time order; when the running total reaches `min_overla...

High-Level Design

Walk agent utterances in order. Keep a pointer j to the first caller segment that has not ended before the current utterance starts. From there scan forward while caller segments start before the ut...


Submit Your Answer
Markdown supported

Related Questions