Skip to content

fix(voice-call): avoid audio pacing slowdowns on long replies - #117162

Merged
vincentkoc merged 6 commits into
mainfrom
fix/voice-call-pacer-dequeue
Aug 1, 2026
Merged

vincentkoc merged 6 commits into
mainfrom
fix/voice-call-pacer-dequeue

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Related: #116201

What Problem This Solves

Fixes an issue where long realtime voice-call replies could create increasing event-loop work while audio was being paced to the telephony stream. The default two-minute queue can hold 6,000 frames, and removing each frame from the front of the array repeatedly copied the remaining backlog.

Why This Change Was Made

The voice-call audio pacer now advances a head index and periodically compacts consumed storage instead of shifting the array for every 20 ms frame. This stays inside the telephony pacing owner and preserves frame/mark order, queued-byte accounting, clear, close, send-failure, and backpressure behavior.

No provider, barge-in, config, environment-variable, SDK, or public API surface changes.

User Impact

Long realtime replies keep the same audio cadence and interruption behavior with bounded queue-maintenance work. Normal and short replies behave exactly as before.

Evidence

  • Current main source proof: the default 960,000-byte queue can contain 6,000 160-byte frames, and each paced send used Array.shift().
  • Focused exact-head proof: 6/6 audio-pacer tests passed.
  • Regression coverage drains the full 6,000-frame default backlog in order and verifies the final mark and queue reset.
  • Compaction coverage drains 501 of 800 frames, verifies bounded backing storage, then proves clearAudio() returns the exact remaining 47,840 bytes and cancels later sends.
  • Final exact head: cd1e3b4c9794813d4195425a7603e58e2dea19d1, including signed main refresh 7fba71eb7aeb73f6a3b146389e251625efb4fd07.
  • Full extensions/voice-call Blacksmith Testbox suite on the final head: 57 files / 582 tests passed (run).
  • Final exact-head autoreview: clean, correctness confidence 0.98.
  • Credentialed carrier/provider live testing is not applicable to this owner: the queue sits after provider audio generation and before the carrier serializer. Deterministic pacing with real Twilio/Telnyx envelope serializers exercises the changed contract directly.

Provenance

The front-array dequeue was introduced in #77064 on May 4, 2026. Code author: @scoootscooob. Landed by @steipete.

Best-Fix Review

Best fix: keep the bounded head-index queue inside RealtimeAudioPacer, where byte limits, ordering, timers, clear, close, and backpressure are owned.

Alternatives rejected:

  • A cross-plugin deque utility would create public/shared surface for two unrelated internal owners.
  • Reducing the queue bound would change long-reply behavior instead of removing the quadratic work.
  • Provider-specific fixes would duplicate policy below the shared voice-call pacing boundary.

Scope

  • extensions/voice-call/src/webhook/realtime-audio-pacer.ts
  • extensions/voice-call/src/webhook/realtime-audio-pacer.test.ts

* commit 'd8f229f2e6c39e2dc694730c2efc479e4fb3871e': (59 commits)
  fix(setup): isolate failed channel probes and report doctor diagnostics (#116824)
  fix(telegram): preserve edit previews, message cache, and group history (#116818)
  fix(whatsapp): preserve interactive replies and normalize media MIME (#116816)
  fix(file-transfer): keep fetched media attachable in sandboxed replies (#116400)
  fix(browser): preserve doctor JSON failure status (#116811)
  fix(ollama): stream native tool call lifecycle (#116809)
  fix(matrix): preserve message-tool room thread routing (#116802)
  fix(ui): restore mobile navigation and accessible usage filters (#116751)
  fix(ui): coalesce profile identity refresh (#116764)
  fix(ui): preserve chat attachments and run ownership (#116752)
  fix(plugins): clean up partial service startup once (#116804)
  fix(qa-channel): enforce message and thread lifecycle ownership (#116801)
  fix(qa-lab): support groups and isolate thread timelines (#116803)
  feat(plugins): externalize Voyage embeddings (#116785)
  fix(outbound): strip echoed inbound metadata before delivery (#50520)
  fix(anthropic-vertex): correct multi-region endpoints (#116757)
  fix(ui): scope agent cron jobs and surface model catalog failures (#116771)
  fix(ui): preserve scoped session state across updates (#116772)
  fix(build): fail closed on symlinked build output roots (#116705)
  fix(commands): validate native settings and preserve Telegram ingress outcomes (#116773)
  ...
* commit 'c41f033b87545b658215a9c3bbe03f88fbaa867d': (347 commits)
  refactor(plugins): consolidate descriptor and startup ownership (#117146)
  fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (#116909)
  fix(slack): let durable ingress retry transient thread lookups (#117135)
  refactor(doctor): consolidate shipped state migration ownership (#117142)
  fix(ai): Codex stream shows internal parser text on a malformed frame (#116966)
  fix: guard every migrated session accessor path (#117140)
  fix(terminal): measure unicode display width consistently (#117062)
  fix(openai): clear ChatGPT SSE fallback per session (#117123)
  fix(mistral): reject incomplete streamed tool terminals (#117137)
  fix(ai): preserve structured chat content and refusals (#117136)
  fix(doctor): persist normalized agent roster (#117115)
  fix(signal): avoid replay after ambiguous quote delivery errors (#117134)
  fix(cron): reject disabled delivery accounts when scheduling (#116899)
  fix(gateway): honor HTTP If-Modified-Since media validators (#117133)
  fix(config): delete one array element per config patch delete (#116463)
  fix(plugins): report installed dependency health authoritatively (#117029)
  fix(ui): recover moving sessions across paged gateway rosters (#117016)
  fix(ui): clear hidden session selection before bulk deletion (#117015)
  fix(discord): avoid replaying ambiguous voice deliveries (#117127)
  fix(ui): scope Gateway reconnect lineage to its target (#117125)
  ...
* commit '475ea69f2c356104f4b601f4976788081e79b8b4':
  refactor(agents): consolidate context budgets and compaction recovery (#117149)
  fix(net-policy): redact sig and x-* auth params in URLs and bodies (#116957)
  refactor(agents): remove duplicate generated-media delivery fallbacks (#117150)
  refactor(reply): unify turn lifecycle state ownership (#117145)
  fix(ui): preserve emoji agent avatar initials (#104912)
  refactor(auto-reply): unify command and directive ownership (#117143)
@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: voice-call Channel integration: voice-call size: S maintainer Maintainer-authored PR labels Aug 1, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 1, 2026 02:12
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head ae9f93c39da1204b55ade8ca35d9b04854d53dbc. Scope is limited to the voice-call realtime audio-pacer dequeue path and focused queue-order/compaction tests. Full voice-call Testbox proof is linked in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

* commit '7fba71eb7aeb73f6a3b146389e251625efb4fd07':
  fix(agents): keep subagent status consistent after restart and large fan-outs (#117141)
  refactor(ui): unify filtered session list ownership (#117158)
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added the P2 Normal backlog priority with limited blast radius. label Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:18 PM ET / August 1, 2026, 02:18 UTC.

ClawSweeper review

What this changes

The PR changes the realtime voice-call audio pacer to consume queued audio and marks with a head index plus periodic compaction instead of repeatedly shifting the front of a JavaScript array, and adds long-backlog regression tests.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR fixes a source-proven quadratic dequeue in the voice-call pacing owner, and the head-index/compaction implementation preserves its existing queue, byte-accounting, mark, clear, close, and backpressure boundaries. No discrete correctness or security defect was found; because this is a maintainer-authored, maintainer-labeled PR and GitHub reports it behind current main, it should remain open for explicit maintainer landing after an exact-head refresh.

Priority: P2
Reviewed head: ae9f93c39da1204b55ade8ca35d9b04854d53dbc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-local repair with relevant long-backlog regression coverage and no identified correctness or security finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless supplies focused queue-order/compaction evidence and a linked full voice-call Testbox run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless supplies focused queue-order/compaction evidence and a linked full voice-call Testbox run.
Evidence reviewed 6 items Current-main defect: Current main still dequeues paced work with Array.shift(). Its default 120-second 8 kHz mu-law budget is 960,000 bytes, equivalent to 6,000 160-byte frames, so a long reply repeatedly copies the remaining array backlog.
Owner-boundary repair: The PR keeps queue consumption inside RealtimeAudioPacer: takeNextItem advances a head index, compacts only after substantial consumption, resets on empty/clear/close/send failure, and schedules from the pending count rather than physical storage length.
Caller and serializer contract: The realtime bridge gives the pacer the outbound WebSocket sender and provider serializer, then routes provider audio, marks, barge-in clears, and session shutdown through that same owner. The serializer interface remains unchanged for Twilio and Telnyx envelopes.
Findings None None.
Security None None.

How this fits together

Realtime voice providers send mu-law output into the voice-call bridge, which hands it to the audio pacer before Twilio or Telnyx wire-format serialization and WebSocket delivery. The pacer owns queue ordering, pacing timers, queued-byte limits, clearing, closure, and backpressure outcomes.

flowchart LR
  A[Realtime provider audio] --> B[Voice-call bridge]
  B --> C[Audio pacer]
  C --> D[Queue and pacing decision]
  D --> E[Twilio or Telnyx serializer]
  E --> F[Telephony WebSocket]
  B --> G[Barge-in and clear events]
  G --> C
Loading

Decision needed

Question Recommendation
Should the maintainers land this bounded internal pacing repair after the behind-base refresh confirms the exact head is clean? Refresh and land: Update the branch or merge ref against current main, confirm exact-head checks, then land the local queue repair.

Why: The patch is technically sound, but this is a maintainer-authored and maintainer-labeled PR, which requires explicit maintainer handling rather than automatic closure or routing.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind current main; refresh exact-head mergeability and required checks before landing, even though the current-main comparison shows no conflicting pacer change.
Agent review details

Security

None.

PR surface

Source +31, Tests +74. Total +105 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 36 5 +31
Tests 1 74 0 +74
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 110 5 +105

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the owner-local queue repair after refreshing the branch against current main and confirming its focused voice-call proof remains green; no new shared utility, provider behavior, config surface, or compatibility path is needed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the owner-local queue repair after refreshing the branch against current main and confirming its focused voice-call proof remains green; no new shared utility, provider behavior, config surface, or compatibility path is needed.

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

Yes, from source: current main queues up to 960,000 bytes and removes one 160-byte frame at a time with Array.shift(), making a full long-reply drain a high-confidence quadratic maintenance path. The review remained read-only, so the implementation worker need not treat this as a live-carrier reproduction.

Is this the best way to solve the issue?

Yes. Keeping the head-index dequeue and bounded compaction inside RealtimeAudioPacer is the narrowest maintainable repair because that class owns ordering, timer scheduling, byte limits, clear, close, and send-failure behavior; a provider-specific or shared deque abstraction would widen the boundary unnecessarily.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This fixes degraded pacing on unusually long voice replies with limited blast radius and no evidence of data loss, security exposure, or service unavailability.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless supplies focused queue-order/compaction evidence and a linked full voice-call Testbox run.

Label justifications:

  • P2: This fixes degraded pacing on unusually long voice replies with limited blast radius and no evidence of data loss, security exposure, or service unavailability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless supplies focused queue-order/compaction evidence and a linked full voice-call Testbox run.

Evidence

What I checked:

Likely related people:

  • scoootscooob: The PR’s provenance and related merged voice-parity work identify this person as the author of the original paced-audio behavior now being repaired. (role: feature introducer; confidence: medium; commits: 8d6db59cf75f; files: extensions/voice-call/src/webhook/realtime-audio-pacer.ts, extensions/voice-call/src/webhook/realtime-handler.ts)
  • steipete: The original voice-parity change was merged by Peter Steinberger, and the current-main refresh commit is also authored by Peter Steinberger. (role: merger and adjacent owner; confidence: medium; commits: 8d6db59cf75f, 1e0f62ebfeae; files: extensions/voice-call/src/webhook/realtime-audio-pacer.ts)

Rank-up moves

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

  • Refresh the behind-base branch or merge ref and confirm the required checks on the exact landing head.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review final exact head cd1e3b4c9794813d4195425a7603e58e2dea19d1. Scope is limited to the voice-call realtime audio-pacer dequeue path and focused queue-order/compaction tests. Full exact-head voice-call Testbox proof is linked in the PR body.

@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 42c3139 into main Aug 1, 2026
97 of 99 checks passed
@vincentkoc
vincentkoc deleted the fix/voice-call-pacer-dequeue branch August 1, 2026 02:37
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged without squash.

  • Reviewed head: cd1e3b4c9794813d4195425a7603e58e2dea19d1
  • Signed two-parent merge: 42c313976ef0071b375e74342edbd0f92bad036b
  • Parents: current main 7fba71eb7aeb73f6a3b146389e251625efb4fd07 and the exact reviewed PR head
  • Required CI: green on the exact PR head
  • Focused proof: 6/6 audio-pacer tests
  • Full voice-call proof: 57 files / 582 tests on Blacksmith Testbox
  • Autoreview: clean, correctness confidence 0.98
  • ClawSweeper exact-head artifact: no correctness or security findings; patch tier A

ClawSweeper rank-up moves were satisfied before landing: exact-head required checks completed successfully, and the maintainer explicitly authorized verified landing.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant