VAPI-3985: hold the call open after Connect/Stream with StopStream wait="true" - #26
Merged
mramasubramanian-bw merged 2 commits intoSep 21, 2026
Merged
Conversation
…it="true" Twilio <Connect><Stream> translated to a bare <StartStream> with nothing after it. Bandwidth ends a call when BXML execution runs out of verbs, so every translated AI-voice flow hung up on answer (30 ms after stream start on a real call), and the translator reported hasErrors: false. Per the StartStream docs (Bidirectional streams), emit <StopStream name="..." wait="true"/> immediately after the StartStream. BXML execution blocks there until the bot closes the WebSocket, which also restores Twilio's <Connect> semantics: verbs after <Connect> now run once the stream ends instead of immediately over the bot's first words. - Generate a per-document stream name (connect-stream-N) when the TwiML <Stream> has none, since StopStream must name the stream it stops. - Emit a Connect warning finding explaining the inserted verb. - Start/Stream (unidirectional fork) is unchanged. - Update the Connect matrix note and AGENTS.md; update tests that pinned the bare output and add coverage for the new shape, generated names, and trailing-verb ordering. Verified on real calls 2026-09-17 (account 9900778): the identical StartStream followed by StopStream wait="true" held the call with audio both ways until hangup; bare StartStream dropped in 0.03 s.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
smoghe-bw
approved these changes
Sep 21, 2026
mramasubramanian-bw
deleted the
VAPI-3985/connect-stream-stopstream-wait
branch
September 21, 2026 18:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Twilio
<Connect><Stream>translated to a bare<StartStream>with nothing after it. Bandwidth ends a call when BXML execution runs out of verbs, so every translated AI-voice flow hung up on answer (30 ms after stream start on a real call), and the translator reportedhasErrors: false.The fix emits
<StopStream name="..." wait="true"/>immediately after the<StartStream>, as the StartStream docs recommend for bidirectional streams. BXML execution blocks there until the bot closes the WebSocket. This also restores Twilio's<Connect>semantics: verbs after<Connect>now run once the stream ends instead of immediately over the bot's first words.Changes
src/translator/translate.ts: emitStopStream wait="true"afterStartStreamfor Connect/Stream. Generate a per-document stream name (connect-stream-N) when the TwiML<Stream>has none, sinceStopStreammust name the stream it stops. Add a Connect warning finding explaining the inserted verb.src/matrix/twilio-voice.json,AGENTS.md: update the Connect note.Before / after
Input:
Before:
After:
Verification
npm run typecheck && npx vitest run: 44 files, 309 passed, 6 skipped.StartStreamfollowed byStopStream wait="true"held the call with audio both ways until hangup. BareStartStreamdropped in 0.03 s.