# Turn Detection

> The Turn Detection is a technique that decides when a user has finished speaking and the agent should answer.

## How does a voice agent know when to respond?

The technique that decides whether a pause means the user has finished or is just thinking. Simple versions wait for silence, smarter ones also analyze the words. Too fast cuts users off, too slow makes the agent feel sluggish.

- Topic: Voice AI
- Type: technique

## Example

Wrong:

```ts
vad.on('silence', () => {
  setTimeout(respond, 300);
});
```

Right:

```ts
const { endOfTurnMs } = config.turnDetection;
vad.on('silence', (transcript: string) => {
  const wait = endsWithFiller(transcript) ? endOfTurnMs * 2 : endOfTurnMs;
  timer = setTimeout(respond, wait);
});
vad.on('speech', () => clearTimeout(timer));
```

The delay comes from config, waits longer after filler words and is cancelled when the user keeps talking.

## Common mistakes

- Answering after every short pause and interrupting the user.

## Key points

- The end-of-turn delay is a setting, not a hardcoded value.
- The agent waits longer after filler words like 'um' than after a complete sentence.

## Interview questions

### What is semantic turn detection?

It uses a model that looks at the words, not just silence, to judge whether the sentence is complete, so the agent waits during thinking pauses.

### Why does my voice agent interrupt users?

The end-of-turn silence is too short, so a natural pause counts as the end of the turn. Increase the delay or add semantic turn detection.

### Why does my voice agent take so long to reply?

The end-of-turn delay may be too long, or stages after it are slow. Measure the time from end of speech to first audio for each stage.

## Related cards

- [Voice Activity Detection](https://wonderium.dev/ai/voice-activity-detection.md)
- [Barge-In](https://wonderium.dev/ai/barge-in.md)
- [Voice Agent](https://wonderium.dev/ai/voice-agent.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/turn-detection
- Last updated: 2026-11-25
