Skip to content

fix(voice-call): terminate carrier calls after realtime startup failures - #118699

Merged
steipete merged 1 commit into
mainfrom
codex/qa0803-voice-startup-carrier-cleanup
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0803-voice-startup-carrier-cleanup

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Hang up the actual carrier call when a realtime voice provider cannot start.
  • Handle synchronous bridge failures, throwing teardown, callback races, and replacement ownership exactly once.

Root cause and actual billing impact

On provider startup rejection, the voice owner emitted its local terminal event and deleted the call/index/max-duration safety timer, but never called the actual Twilio/Telnyx carrier hangup API. The carrier call remained active, billable, invisible, and unrecoverable. Bundled OpenAI voice providers intentionally reject invalid-key/timeout startup without firing onClose, so the existing established-call error callback could not cover this path. Synchronous bridge construction failures and throwing close callbacks also left startup teardown incomplete.

The existing plugin-owned exactly-once terminal finalizer now owns one carrier hangup for every actual error terminal. Synchronous startup and throwing cleanup converge on that same owner; stale/replaced bridges cannot terminate an active successor, and successful/normal terminal events never invoke erroneous hangups.

Real handler/dependency proof

  • Four genuine startup owner regressions failed before repair.
  • Actual registered loopback WebSocket handler + real lifecycle owner: 44/44 passing, including no callback, synchronous completed/error callbacks, close throwing, construction throwing, exact-once races, stale predecessor, replacements, and shutdown/backpressure.
  • Actual Twilio/Telnyx first-party REST owner and installed OpenAI/ws source inspected directly; no real telephone calls or external credentials.
  • Formatter/lint/diff checks clean; full canonical-source type baseline clean.
  • Fresh independent structured Sol/high review: no findings, confidence 0.88.
  • Production delta +18 lines for carrier billing and three terminal owner boundaries.

Exact-head real localhost production-lifecycle proof

One focused execution drove the actual production RealtimeCallHandler through a genuinely registered localhost WebSocket upgrade and a synthetic recording carrier. Four provider-close failure modes each terminated the carrier exactly once and recorded exactly one terminal error; initial bridge construction failure likewise hung up exactly once. A stale predecessor failure never terminated the replacement call: its WebSocket remained open and speech succeeded. Carrier/network transport was deliberately synthetic; no real Twilio/Telnyx operation or external request occurred.

{"result":"PASS","pullRequest":118699,"head":"19a1369d7be141015bd634e7c85b1e50d7def50a","proof":"actual production RealtimeCallHandler through registered localhost WebSocket upgrade and synthetic carrier","passed":6,"failed":0,"startupFailures":[{"providerClose":"no-callback","carrierHangups":1,"managerTerminalErrors":1},{"providerClose":"completed","carrierHangups":1,"managerTerminalErrors":1},{"providerClose":"error","carrierHangups":1,"managerTerminalErrors":1},{"providerClose":"throws","carrierHangups":1,"managerTerminalErrors":1}],"initialBridgeCreationFailure":{"carrierHangups":1,"managerTerminalErrors":1},"stalePredecessorFailure":{"carrierHangups":0,"managerTerminalErrors":0,"replacementSocket":"OPEN","replacementSpeak":"succeeded"},"realCarrierCalls":0,"externalNetworkRequests":0}

Reproduction: node scripts/run-vitest.mjs extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts --reporter=json --silent=true --testNamePattern='hangs up a rejected startup exactly once|hangs up the carrier when its initial realtime bridge cannot be created|does not hang up a replacement when its stale predecessor rejects startup'.

@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 10:12 AM ET / 14:12 UTC.

ClawSweeper review

What this changes

This PR makes realtime voice-call startup failures terminate the underlying carrier call and adds lifecycle regression coverage for construction failures, teardown exceptions, races, and bridge replacement.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep this maintainer-labeled PR open. The patch appears to repair a real lifecycle gap by moving carrier termination into the exactly-once error finalizer, but the supplied evidence is still a mocked loopback harness rather than independently inspectable after-fix runtime proof.

Priority: P1
Reviewed head: 19a1369d7be141015bd634e7c85b1e50d7def50a

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused owner-boundary patch and regression coverage are solid, but the missing inspectable after-fix behavior evidence caps merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR describes a real WebSocket lifecycle harness, but the supplied review context provides no independently inspectable after-fix runtime artifact; tests and CI remain supplemental proof only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR describes a real WebSocket lifecycle harness, but the supplied review context provides no independently inspectable after-fix runtime artifact; tests and CI remain supplemental proof only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Current failure path: Current main ends the local call state in emitCallEnd, while the carrier hangup is only invoked from the established bridge onClose("error") path; bridge construction and connect() startup failures can therefore bypass that carrier request.
Proposed owner-boundary repair: The branch makes the existing exactly-once terminal finalizer issue the carrier hangup only for error, then routes synchronous bridge construction failure and asynchronous connection rejection through that finalizer while retaining predecessor ownership checks.
Carrier contract: The plugin contract defines hangupCall as the active-call termination operation, and the bundled Twilio and Telnyx providers implement it with their respective carrier REST termination requests.
Findings None None.
Security None None.

How this fits together

The voice-call plugin receives a carrier media WebSocket, creates a realtime provider bridge, and records terminal state through the call manager. When bridge startup fails, the carrier provider must also receive a hangup request so the remote call does not remain active after the local session is removed.

flowchart TD
  A[Carrier call and media stream] --> B[Realtime WebSocket handler]
  B --> C[Realtime provider bridge startup]
  C --> D{Startup succeeds?}
  D -->|Yes| E[Active bridge and audio session]
  D -->|No or error terminal| F[Exactly-once call finalizer]
  F --> G[Call manager terminal event]
  F --> H[Carrier hangup API]
  E --> F
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR describes a real WebSocket lifecycle harness, but the supplied review context provides no independently inspectable after-fix runtime artifact; tests and CI remain supplemental proof only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The PR body describes a passing loopback lifecycle suite, but the review context contains no inspectable terminal output, runtime log, or artifact demonstrating the after-fix carrier-hangup path; this remains the merge gate.
  • Resolve merge risk (P1) - The PR is one commit behind current main, although the latest-main change does not touch either modified voice-call file and a three-way merge scan found no conflict markers.
  • Complete next step (P2) - This maintainer-labeled PR has no identified mechanical repair finding; the remaining merge gate is contributor-supplied real-behavior proof and final branch validation.
Agent review details

Security

None.

PR surface

Source +18, Tests +213. Total +231 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 32 14 +18
Tests 1 214 1 +213
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 246 15 +231

Review metrics

Metric Value Why it matters
Production versus regression coverage production +18 net lines; tests +213 net lines The added production logic is confined to terminal ownership and is accompanied by substantially broader lifecycle regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the canonical exactly-once finalizer approach, then attach a redacted after-fix lifecycle trace or terminal artifact showing that a realtime startup failure calls the carrier hangup exactly once without terminating a replacement bridge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the canonical exactly-once finalizer approach, then attach a redacted after-fix lifecycle trace or terminal artifact showing that a realtime startup failure calls the carrier hangup exactly once without terminating a replacement bridge.

Do we have a high-confidence way to reproduce the issue?

Yes, from source and the added loopback lifecycle harness: an initial createBridge throw or connect() rejection reaches local terminal cleanup without current-main carrier termination. I did not execute the harness because this review is read-only.

Is this the best way to solve the issue?

Yes. Centralizing error hangup in the existing exactly-once terminal finalizer covers both synchronous and asynchronous startup failures while preserving the active-successor ownership guard; duplicating hangup calls at each failure site would reintroduce race risk.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c547f16506e6.

Labels

Label changes:

  • add P1: A realtime startup error can leave an active carrier call without a usable local session, affecting a live channel workflow and potentially continuing billing.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes a real WebSocket lifecycle harness, but the supplied review context provides no independently inspectable after-fix runtime artifact; tests and CI remain supplemental proof only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: A realtime startup error can leave an active carrier call without a usable local session, affecting a live channel workflow and potentially continuing billing.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes a real WebSocket lifecycle harness, but the supplied review context provides no independently inspectable after-fix runtime artifact; tests and CI remain supplemental proof only. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the terminal finalizer, error close callback, and startup rejection cleanup to Peter Steinberger; the proposed patch touches that same owner boundary. (role: current lifecycle owner and recent area contributor; confidence: high; commits: 96b4258734ee; files: extensions/voice-call/src/webhook/realtime-handler.ts, extensions/voice-call/src/webhook/realtime-handler.lifecycle.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted terminal transcript, log, or linked artifact showing a startup failure causes one carrier-hangup request and leaves a replacement bridge active.
  • Refresh the branch against current main before merge so the full required check set runs on the final merge result.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit eb76bf4 into main Aug 3, 2026
108 of 118 checks passed
@steipete
steipete deleted the codex/qa0803-voice-startup-carrier-cleanup branch August 3, 2026 14:38
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main:
  fix(onboard): keep referenced provider secrets out of plaintext (#118702)
  docs: show canonical agent roster configuration (#118722)
  fix(channels): generate catalog from package manifests (#118097)
  fix(zalouser): distinguish probe timeout from auth failure (#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (#118697)
  fix(cli): publish completion caches atomically (#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (#118699)
  fix(slack): isolate GovSlack media trust and delivery (#118695)
  fix(browser): wrap page-controlled action results (#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (#118698)
  test(qa): prove real yielded-child completion and channel delivery (#118707)
  fix(doctor): honor explicit plugin-only migration authority (#118700)
  fix(security): detect child_process calls through aliases and computed members (#116304)
  test(gateway): avoid async facade mock race (#118708)
  fix(gateway): preserve final speech during transcription shutdown (#118693)
  fix(gateway): resume durable outbound delivery retries (#118694)
  fix(plugins): reject external public-artifact hardlinks (#118689)
vincentkoc added a commit that referenced this pull request Aug 3, 2026
* origin/main: (78 commits)
  fix(parallels): recover Windows poll transport failures (#118479)
  fix(channels): deny unauthorized Discord and Telegram binding access (#118704)
  fix(test): bound shared git inventory lookup (#111171)
  fix(onboard): keep referenced provider secrets out of plaintext (#118702)
  docs: show canonical agent roster configuration (#118722)
  fix(channels): generate catalog from package manifests (#118097)
  fix(zalouser): distinguish probe timeout from auth failure (#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (#118697)
  fix(cli): publish completion caches atomically (#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (#118699)
  fix(slack): isolate GovSlack media trust and delivery (#118695)
  fix(browser): wrap page-controlled action results (#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (#118698)
  test(qa): prove real yielded-child completion and channel delivery (#118707)
  fix(doctor): honor explicit plugin-only migration authority (#118700)
  fix(security): detect child_process calls through aliases and computed members (#116304)
  test(gateway): avoid async facade mock race (#118708)
  fix(gateway): preserve final speech during transcription shutdown (#118693)
  fix(gateway): resume durable outbound delivery retries (#118694)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 4, 2026
* origin/main:
  fix(onboard): keep referenced provider secrets out of plaintext (openclaw#118702)
  docs: show canonical agent roster configuration (openclaw#118722)
  fix(channels): generate catalog from package manifests (openclaw#118097)
  fix(zalouser): distinguish probe timeout from auth failure (openclaw#111336)
  improve(ui): cut E2E shard runtime by reusing the bundle (openclaw#118697)
  fix(cli): publish completion caches atomically (openclaw#118715)
  fix(whatsapp): honor disabled self-chat without widening group access (openclaw#118711)
  fix(voice-call): terminate carrier calls after realtime startup failures (openclaw#118699)
  fix(slack): isolate GovSlack media trust and delivery (openclaw#118695)
  fix(browser): wrap page-controlled action results (openclaw#118691)
  fix(security): sanitize JSON-escaped forged content boundaries (openclaw#118698)
  test(qa): prove real yielded-child completion and channel delivery (openclaw#118707)
  fix(doctor): honor explicit plugin-only migration authority (openclaw#118700)
  fix(security): detect child_process calls through aliases and computed members (openclaw#116304)
  test(gateway): avoid async facade mock race (openclaw#118708)
  fix(gateway): preserve final speech during transcription shutdown (openclaw#118693)
  fix(gateway): resume durable outbound delivery retries (openclaw#118694)
  fix(plugins): reject external public-artifact hardlinks (openclaw#118689)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant