cloudflare / cloudflare/agents
`@cloudflare/voice-twilio`: barge-in never stops Twilio playback (no Media Streams `clear` event)
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 711
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 53
Description
### Package
`@cloudflare/voice-twilio@0.1.0` (`TwilioAdapter`) with `agents@0.23.0`
### Description
When the caller interrupts the agent, generation may stop on the agent side, but **Twilio keeps playing already-buffered audio** for the rest of the utterance (often 1–3+ seconds).
Twilio Media Streams only flushes outbound audio when the server sends:
```json
{ "event": "clear", "streamSid": "" }
```
See: https://www.twilio.com/docs/voice/media-streams/websocket-messages#send-a-clear-message
`TwilioAdapter` does not send `clear` when:
1. the agent emits `playback_interrupt`, or
2. the client sends `{ "type": "interrupt" }`
So barge-in is incomplete for real phone calls.
### Expected
On interrupt / `playback_interrupt`, the adapter sends Twilio `clear` for the active `streamSid`, then resumes listening.
### Actual
Agent pipeline may abort, but the caller still hears the rest of the buffered TTS.
### Related pipeline gap (agents/voice)
With `WorkersAINova3STT`, speech-start / barge-in callbacks that would emit `playback_interrupt` do not appear to fire the same way as Flux STT. Flux is English-oriented, so non-English telephony cannot rely on that path.
Even if the agent correctly emits `playback_interrupt`, the Twilio adapter still needs to translate it into `clear`.
### Workaround
Custom bridge that:
1. detects caller speech over active playback (energy VAD or STT speech-start),
2. sends `{ "type": "interrupt" }` to the agent,
3. sends `{ "event": "clear", "streamSid" }` to Twilio.
This is a well-known Media Streams requirement (same class of bug reported in Pipecat / other Twilio AI bridges).
Contributor guide
Assessment
This issue has not been assessed yet.