Repository navigation
fix(voice-call): let Twilio notify messages finish before hangup - #191264
GoatInAHat wants to merge 4 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f98765732c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs real behavior proof before merge. What this changesThe PR prevents Twilio inline notifications from replaying on answer and triggering the manager’s three-second hangup timer. Example: A Twilio notify call speaks a ten-second message with voicemail detection disabled.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open: it addresses a current notification-delivery bug, but records speech before a call is accepted or answered. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe voice-call manager prepares outbound carrier instructions, processes answer callbacks, and persists call history consumed by transcripts and reports. flowchart LR
A[Notification request] --> B[Outbound call manager]
B --> C[Twilio Say and Hangup]
C --> D[Carrier callbacks]
D --> B
B --> E[Persisted call history]
E --> F[Transcripts and reports]
Technical reviewBest possible solution: Keep inline playback ownership in the existing manager, suppress replay before dialing, and record speech only after carrier answer or playback confirmation. Do we have a high-confidence way to reproduce the issue? Current main retains initialMessage after preparing inline TwiML; answer handling dispatches fallback speech and arms the three-second timer, establishing the failure path without executing target code. Is this the best way to solve the issue? Reusing manager playback ownership is the smallest complete approach, but the replay guard must be separated from claims that speech has already occurred. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e8f91361abfe. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +8, Tests +45, Other +2. Total +55 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 2, 2026, 11:41 AM ET / 16:41 UTC. |
f987657 to
cf0c1bb
Compare
|
Addressed the P2 finding in Regressions cover rejected create-call requests; busy, no-answer, and failed calls ending without assistant speech/status; normal and early answered callbacks; no duplicate TTS or three-second hangup; repeated answered callbacks and carrier completion; and Plivo/Telnyx still speaking on answer. All 132 tests in the four requested files passed (104.93s wall). The six strengthened failure/timing cases failed on the previous patch before repair.
The PR body now includes the sanitized production before trace and explicitly keeps live Gateway-plus-Twilio after proof open. Could a maintainer verify using an isolated Twilio setup, or specify the minimal trace they would accept? No production changes or live calls were made for this revision. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf0c1bbb8a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Local-finalization P2 fixed in ce1bec4: playing notifications interrupted by endCall or max-duration timeout now persist failed plus a reason-specific notifyError. Both cases failed on cf0c1bb and now pass, including late-callback terminal-record protection. All 134 requested tests pass (111.78s); narrow strict types, lint, format, test-line ratchet and diff checks pass. PR Evidence updated. Live Gateway/Twilio after proof remains open and no production changes or calls were made. @codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce1bec4902
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Closes #191214
What Problem This Solves
Twilio notify calls restart their message on answer and cut it off after about three seconds when voicemail detection is disabled. The original patch also prematurely recorded speech for calls that were rejected, busy, or never answered; this revision also fixes terminal playback records that otherwise remain marked
playingafter local termination or restart recovery.User Impact
Recipients can hear the complete inline notification before Twilio hangs up. Undelivered notifications are no longer recorded as assistant speech. Call setup, conversation flow, voicemail detection, and providers that ignore inline TwiML keep their existing behavior. Terminal notification and voicemail reports now settle playback instead of displaying
playingforever. No configuration changes are required.Why This Change Was Made
Twilio already receives
<Say>…</Say><Hangup/>as its create-call instructions. Before dialing, the manager moves the pending initial message into a private inline-ownership metadata marker, so no answer/stream trigger can replay it, including an answer callback arriving before the create-call response. This is pending ownership, not evidence of speech: the transcript stays empty andnotifyStatusis unset.Only the carrier's answered event consumes that marker, sets
notifyStatus: "playing", and appends the bot transcript entry in the existing persisted event mutation, before answer effects run. Repeated answered callbacks cannot record the message twice. The sharedmarkCallEndedowner now settles playback and terminal timestamps/state before persistence.finalizeCalluses it for local endings (including max-duration/notification timers and initiation failure) and carriercall.ended/fatalcall.error; restart recovery uses it for both terminal-provider and expired-record branches. Newly rejected inbound records also use it. Runtime stop only drains accepted work and clears timers; it does not create terminal records.Provider-confirmed
completedplayback becomesleft; other provider endings becomefailedwith an error naming the status (or preserving the carrier error). Local notification endings remainfailedwith their existing reason-specific errors. Expired recovery without provider confirmation becomesfailedwith an explicit unconfirmed-after-restart error. The same mapping closes the voicemail gap, while preservingleftfor successful realtime voicemail and the existing carrier-completed voicemail end reason. Already-settled statuses are untouched. Rejected creation and unanswered calls still have no bot speech or playing status; non-inline provider fallback timing is unchanged.Evidence
ce1bec49022before production edits: 6 failed, 11 skipped, 32.65s Vitest / 41.36s runner. Completed, busy, and expired recovery each persistedplayingfor notifications and voicemail. The repaired initial restore suite passed 17 tests, 34.60s Vitest / 42.64s runner, including late-carrier-callback checks; the final expanded suite is included below.pnpm test extensions/voice-call/src/manager.notify.test.ts extensions/voice-call/src/manager/outbound.test.ts extensions/voice-call/src/manager/events.test.ts extensions/voice-call/src/providers/twilio.test.ts extensions/voice-call/src/manager.restore.test.ts --maxWorkers=1: 157 passed in five files, 229.62s runner (104 database-worker tests/207.60s; 53 voice-call tests/12.96s), including cold worker preparation. The changed restore suite passes all 23 cases, including 12 new cases.endCall/max-duration, repeated/early answer, carrier completion, Plivo/Telnyx, AMD, successful realtime voicemail and first-provider-terminal-facts regressions pass unchanged. Six additional persisted carrier-busy/fatal-error/local-timeout cases cover both playback fields. These use real manager/queue/persistence owners with a fake external provider; they do not prove live carrier/audio behavior.git diff --checkpassed (0.17s).pnpm check:changedwas deliberately not rerun: the previous 900s run timed out in the repository-wide SQLite worker scan and is not claimed passing. Hosted CI once1bec49022finished with no failed checks; current-revision CI seconds are not yet available. Fresh hosted Codex review is requested after publication; no local autoreview is claimed.playing; no new runtime manager, public contract, schema or dependency.Production before trace
The following sanitized trace is from a real production call on released voice-call plugin
2026.10.10-beta.5, with voicemail detection off. IDs are placeholders and times are relative to dialing:The message was about 45 words (roughly 15 seconds of speech). The call record shows answer at +20.5 seconds and termination 3.3 seconds later with
endReason: hangup-bot.Open proof item
The before trace is production evidence; the after behavior is currently covered by local manager/provider regression tests, not a live Gateway-plus-Twilio trace. An after trace requires the unmerged build running on a live Twilio deployment. We cannot run that against the production install because local production patches are not permitted, and no live calls, plugin installs/reloads, or Gateway changes were made for this revision. Could a maintainer verify with an isolated Twilio setup, or specify the minimal trace they would accept? This live proof item remains open; the local tests are not a claim of carrier/audio verification.