Vision Agents requires a Stream account for real-time transport.
Automatic Handling
When you configure turn detection, the Agent class automatically:- Detects when the user starts speaking (via
TurnStartedEvent) - Interrupts the active TTS or Realtime LLM, incrementing its epoch counter
- Discards stale audio — any audio events from before the interruption are dropped based on epoch matching
- Flushes the audio track to clear buffered audio
- Listens to the user’s new input
- Responds appropriately
Epoch-based stale event tracking
Both TTS and Realtime LLMs maintain a monotonicepoch counter. When interrupt() is called, the epoch increments. Each audio event (TTSAudioEvent, RealtimeAudioOutputEvent) carries the epoch at which it was produced. The Agent automatically compares the event’s epoch against the current component epoch and drops any events that don’t match, preventing stale audio from playing after an interruption.
Realtime APIs
If you’re using OpenAI Realtime, Gemini Live, AWS Bedrock, or Qwen, interruption handling is built-in at the model level. No turn detection plugin needed.Traditional Pipeline Setup
For theSTT → LLM → TTS pipeline, you need turn detection. Some STT plugins include it automatically:
If you provide both an STT with built-in turn detection and a separate
turn_detection plugin, the Agent automatically ignores the external plugin to prevent conflicts.Custom Behavior
Add custom logic for logging, analytics, or special responses:You don’t need to call
tts.interrupt() or llm.interrupt() in your handlers — the Agent class does this automatically for both TTS and Realtime LLM pipelines.Tuning Sensitivity
Adjust turn detection parameters to control interruption response:More Sensitive (Faster Response)
Less Sensitive (More Deliberate)
Recommended Defaults
Best Practices
Keep responses concise — Shorter responses mean fewer interruptions:Troubleshooting
| Issue | Solution |
|---|---|
| Agent doesn’t stop when interrupted | Verify turn_detection is configured; lower confidence_threshold |
| Agent stops too easily (false positives) | Increase confidence_threshold to 0.7; increase buffer_in_seconds to 2.0 |
| Delay before responding to interruption | Decrease buffer_in_seconds to 0.5; consider Realtime API |
| Not working at all | Don’t use turn detection with Realtime LLMs (they handle it internally) |
Next Steps
Turn Detection
VAD vs Turn Detection concepts
Smart Turn
Full parameter reference

