cloudflare / cloudflare/agents
`@cloudflare/voice-twilio`: outbound agent audio dropped when messages arrive as `Blob`
- 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
Even after the agent WebSocket is connected, callers often hear nothing (or only silence) from the agent.
The voice agent sends binary audio as `Blob` over the WebSocket. The Twilio adapter's outbound handler only forwards `ArrayBuffer`:
```ts
else if (event.data instanceof ArrayBuffer) {
// convert / send to Twilio
}
```
`Blob` frames are ignored, so TTS audio never reaches Twilio.
### Expected
Any binary audio from the agent (`ArrayBuffer` or `Blob`) is forwarded to Twilio as Media Streams `media` events.
### Actual
`Blob` audio is dropped → silent call after connect / greeting never plays.
### Workaround
Before accepting the agent socket:
```ts
agent.binaryType = "arraybuffer";
agent.accept();
```
Or handle both:
```ts
if (event.data instanceof ArrayBuffer) { /* ... */ }
else if (event.data instanceof Blob) {
const buf = await event.data.arrayBuffer();
/* ... */
}
```
### Notes
This is independent of TTS codec choice. Even with ElevenLabs `ulaw_8000` / PCM16, frames never leave the adapter if they arrive as `Blob`.
Contributor guide
Assessment
This issue has not been assessed yet.