Repository navigation
Conversation
Assistant audio leaks back through the phone line, and the local RMS gate treated that echo as caller speech: it fired spurious barge-ins that cancelled the bot's own turn, and at end-of-turn it produced "phantom" user transcripts (including whole sentences the caller never said) that were stored as caller speech. Split input accounting by an assistant-audio window: while the paced telephony queue still holds audio, or within ASSISTANT_SPEECH_TAIL_MS of the last outbound chunk, input energy is recorded as echo and cannot arm the barge-in gate or count as caller speech. Only sustained speech heard on a quiet line sets lastLocalAudioAt and triggers barge-in. Also guard the final-transcript path: a transcript is dropped as phantom only when no caller audio was seen for PHANTOM_GUARD_MAX_AGE_MS and the loudest input since the last transcript was below PHANTOM_GUARD_MIN_RMS - a loud caller is never discarded.
|
🦞👀 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. |
|
Codex review: blocked before merge. Reviewed October 4, 2026, 6:01 PM ET / 22:01 UTC (Revision 11). ClawSweeper reviewWhat this changesThe Voice Call plugin tracks carrier playout duration and suppresses local speech-triggered interruption during assistant playback and a 400 ms tail. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain This PR remains useful and is not implemented on current main. The carrier-backlog blocker is fixed, but the previously reported fallback-interruption regression still lacks explicit Voice Call owner acceptance. Priority: P1 Review scores
Verification
How this fits togetherVoice Call relays caller audio from a carrier WebSocket to a realtime voice provider and paces assistant audio back to the carrier. Its local speech gate supplies interruption when the provider bridge does not own that behavior. flowchart TD
A[Caller audio] --> B[Carrier WebSocket]
B --> C[Local speech gate]
B --> D[Realtime voice provider]
D --> E[Assistant audio pacer]
E --> F[Carrier playback]
E --> G[Playback window]
G --> C
C --> H[Fallback interruption]
Decision needed
Why: The patch measurably removes local echo interruptions but changes shipped caller-interruption behavior; choosing that tradeoff requires owner intent. Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +33, Tests +182. Total +215 across 5 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the measured local echo repair under an explicitly approved and documented fallback-interruption contract, while keeping provider echo and phantom transcripts tracked separately. Do we have a high-confidence way to reproduce the issue? Yes: source establishes the fallback regression when a bridge does not own barge-in and caller speech arrives during assistant playout. The contributor's real Google Live observation corroborates the masking effect; this review did not execute a call. Is this the best way to solve the issue? Unclear: masking is a small, measured fix for local echo, but it also masks genuine callers and does not solve provider-side echo or phantom transcripts. It needs explicit acceptance of that narrower contract or an echo-safe overlap alternative. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a58fe52a98b5. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
The phantom-transcript guard suppressed a final caller turn whenever no quiet-line caller audio had been seen and the loudest input was weak. A caller who talks over the assistant never produces quiet-line audio, so their turn could be dropped as a phantom. Learn the leaked-playback floor from assistant-active input frames and only treat overlap energy that clearly exceeds it (2.5x) as caller speech. The floor is compared against the samples learned before the current frame, so a loud frame cannot raise the threshold it is being judged against. Also decide suppression before emitting transcript.done/input.audio.committed, so a suppressed phantom never reaches the observer as committed caller input.
|
@clawsweeper re-review The findings from the last review have been addressed on the current head; the PR body now carries a "Review response" section with the reworked behaviour and the after-fix regression tests (names + exact command + observed result). passes on the branch. |
|
🦞👀 Re-review progress:
|
…ence The phantom-transcript guard treated missing local caller evidence as echo: lastLocalAudioAt === 0 counted as "stale", so any provider-committed final user transcript without qualifying local RMS energy was dropped. That discarded genuine caller turns (provider-side VAD, no inbound media, quiet callers) and broke 24 realtime-handler tests. - Drop a committed final user transcript only when assistant audio is on the line now, echo was heard under it this turn, no input rose above the learned leak floor or the speech gate, and no quiet-line input was as loud as the echo. Per-turn caller evidence replaces the 15 s age window. - Gate local barge-in on the learned echo floor instead of ignoring all overlap: caller frames clearly above the floor still barge in, echo does not. Learn the floor only from echo-attributed frames so a sustained interruption cannot raise its own threshold; before a floor exists, assume echo may reach the speech-gate threshold. - Restore transcript.delta (with role) for user partials, which the guard refactor had re-labelled output.text.delta. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The echo floor that separates leaked assistant audio from caller speech was call-long and learned only from echo-attributed frames. After a quiet playback segment set a low floor, a louder later segment's bleed cleared floor x 2.5, was classified as caller audio, and armed the false local barge-in this guard exists to prevent. The mirror case also held: a floor learned under loud playback hid a caller talking over later, quieter playback. - Reset the floor whenever assistant audio resumes after the line went quiet (no pending paced audio and past the playback tail), so each segment is judged against its own leak level. The segment's first frames fall back to the existing cold-start assumption (echo may reach the speech gate), and only echo-attributed frames still teach the floor. - Echo-guard tests wait for the bridge to receive each carrier frame, which the handler does only after its input accounting runs, instead of sleeping 80 ms. - Cover a louder echo-only segment after a quiet one with a silent caller: no barge-in and no committed caller turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ambiguous caller turns The echo tail started when the provider handed audio to the pacer, not when that audio finished playing. For a chunk the pacer needed longer than the 400 ms tail to send, the tail expired while playout continued, so once the queue drained the remaining playback and its echo counted as caller speech and armed the false barge-in this guard exists to prevent. The per-segment echo-floor reset used the same signal and could fire mid-playout. - The pacer projects its paced stream clock onto the wall clock each time it sends a frame (getPlayoutEndsAt) and clamps it when playback is cleared. Assistant audio counts as on the line while audio is queued or until that playout end plus the tail. The phantom-transcript guard dropped a committed caller turn whenever no overlap frame cleared the 2.5x barge-in margin, so a caller answering over playback at a moderate level lost a correctly finalized turn. - Overlap input more than 1.25x above the learned segment floor is too weak to barge in but marks the turn ambiguous; the provider's transcript is kept. Suppression now needs echo that never rose above its own floor. Tests: a 4 s chunk paced past the tail yields no barge-in and no echoed turn; a caller at ~1.4x the echo floor over playback keeps their turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Live after-fix observation — negative result (real Google Live session, simulated line echo)I ran the real-call observation ClawSweeper has been asking for. It ran, the transport is real, and the result is negative: on a real provider session the current handler does not stop assistant echo from being taken as caller speech. I'm posting it because the negative result is the evidence, and it drives the change I'm making next (see the note at the end). Head tested: Scope: a real Google Live provider session with real speech audio, through the real Setup:
What this shows
What this does not cover: a phone network or acoustic/hybrid echo path (the echo here is a clean scaled+delayed copy, no line noise or carrier re-encode); the default Google deployment where the provider owns barge-in ( Redacted per-frame traces, handler log lines, raw Next: this result is why I'm replacing the approach rather than adding another revision. I'm cutting the diff down to what the observation actually supports — hold the echo window through paced playout and keep the local barge-in gate closed while assistant audio is draining, dropping the learned-floor and phantom-transcript machinery — and will post a fresh observation against the new head. The phantom-transcript half of the issue is provider-driven (the provider emits the transcription; we cannot reliably separate it at the media frame) and will be stated as such rather than patched at this layer. |
The local RMS gate cannot tell echo of our own paced playout from the caller, so it hears silence while assistant audio is on the line (paced playout plus a 400 ms tail). Inbound audio is still forwarded to the provider throughout. Drop the per-segment echo floor and the phantom-transcript guard: the provider owns barge-in and transcription during playout. The three realtime-handler tests that asserted local barge-in during playout now assert the masking and the local fallback once the window has closed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Decision needed: accept the altered interruption contract, or hold — with the current-head real-call proofThis PR changes a documented behaviour: while assistant audio is playing out (plus a 400 ms tail), the plugin's own RMS gate no longer interrupts. On bridges that do not handle input-audio barge-in, that gate is the only interruption path. Position: accept the contract change. The interruption this removes is the reported bug. Issue #159140 is about the agent's own leaked audio being taken as caller speech and cancelling the agent's turn. The level gate cannot tell echo from a caller — the observation below measures that directly. Removing it during playout is the fix; the cost is that a genuine caller who overlaps playout is not interrupted by the plugin until playout ends. Proof: real Google Live session on the current headHead: Real
Caller in the overlap run was ~12 dB above the echo (voiced RMS 0.169 vs 0.043; 99 mixed frames). Per-frame traces, raw What this shows, and what it does not
Two consequences
Maintainers: accept the altered contract (recommended — the removed behaviour is the reported bug), or hold for a bounded overlap path. We do not have a media-frame signal that reliably separates echo from genuine overlap; that is the measured finding, not an assumption.
|
|
@steipete — flagging this for the Voice Call owner decision, since it changes a documented behaviour in What changed: while paced assistant audio is playing out (plus the 400 ms tail), the plugin's local RMS gate no longer interrupts. That removes the echo-triggered self-cancellation this PR was opened for, but it also defers genuine caller interruption on bridges that rely on the local gate (no provider-owned barge-in). What the current-head real-call evidence shows: local echo detections fall from 12 on the merge base to 0 on this head, genuine caller turns are still delivered, and the post-window gate still fires. The measured cost is 2023 ms of genuine overlap without a local detection. Provider-side (Google VAD) echo interruption and the provider-committed echo transcript remain — both stay open in #159140; this PR is ClawSweeper's current review (Rev 8) recommends accepting the deferred-interruption contract and documenting it. The blocker is that acceptance, not a further code change. Could you confirm whether Voice Call accepts deferred local interruption on fallback bridges, or wants a bounded interruption path before merge? The full trace and trade-off are in the decision comment above. |
…arge-in-guard Resolve the realtime-handler.test.ts conflict on main's test scaffold (bargeInHarness, sendMedia, expectFrame, talkEvents): - Re-express the playout-masking contract on the two barge-in tests main kept: the session-bridge override test now asserts no local barge-in while assistant audio plays out and the fallback once the window closes; the late local barge-in test advances past the playout tail first. - Take main's removal of the continuity-reset mark test and of the provider-without-speech-started fallback test (openclaw#162202). The masking and post-window fallback for that provider shape stay covered by realtime-handler.echo-guard.test.ts; its output.audio.done turn assertion moves into the override test. - Drop the echo-guard test's own teardown: main's connectCarrierStream now registers socket, handler, and server cleanup, so closing again failed with ERR_SERVER_NOT_RUNNING.
…91537) Ignore unconfirmed caller transcripts during carrier playback and its 400 ms echo tail at the existing audio controller. Preserve local RMS and provider barge-in, and keep admitted caller partials eligible through their final transcript. Carrier playout accounting survives a drained local queue. Supersedes #159145, thanks @mnowrot. Provider-owned echo interruptions and late transcripts remain tracked in #159140; the Deepgram UtteranceEnd fix is untouched. Proof: fake carrier media and echoed STT words reproduce call.speech on main 77fadc0; green after the repair. Focused handler/pacer/controller tests passed 53/53, and expanded handler/lifecycle/call-control tests passed 75/75. Touched-file lint/format and independent Codex autoreview P0-P3 passed. PR CI supplies broad proof. The 43-line regression allocation covers playback echo, tail expiry, both interruption owners and renewed playback without additional test scaffolding. Co-authored-by: mnowrot <[email protected]>
|
Thanks @mnowrot for the investigation and carrier playout-accounting work. The credited replacement landed in #191537 (2bbce75), with a playback/tail transcript gate that preserves caller interruption and a regression that fails on main and passes with the fix. Provider-owned echo behavior remains tracked in #159140. |
…enclaw#191537) Ignore unconfirmed caller transcripts during carrier playback and its 400 ms echo tail at the existing audio controller. Preserve local RMS and provider barge-in, and keep admitted caller partials eligible through their final transcript. Carrier playout accounting survives a drained local queue. Supersedes openclaw#159145, thanks @mnowrot. Provider-owned echo interruptions and late transcripts remain tracked in openclaw#159140; the Deepgram UtteranceEnd fix is untouched. Proof: fake carrier media and echoed STT words reproduce call.speech on main 30e2969; green after the repair. Focused handler/pacer/controller tests passed 53/53, and expanded handler/lifecycle/call-control tests passed 75/75. Touched-file lint/format and independent Codex autoreview P0-P3 passed. PR CI supplies broad proof. The 43-line regression allocation covers playback echo, tail expiry, both interruption owners and renewed playback without additional test scaffolding. Co-authored-by: mnowrot <[email protected]>
…enclaw#191537) Ignore unconfirmed caller transcripts during carrier playback and its 400 ms echo tail at the existing audio controller. Preserve local RMS and provider barge-in, and keep admitted caller partials eligible through their final transcript. Carrier playout accounting survives a drained local queue. Supersedes openclaw#159145, thanks @mnowrot. Provider-owned echo interruptions and late transcripts remain tracked in openclaw#159140; the Deepgram UtteranceEnd fix is untouched. Proof: fake carrier media and echoed STT words reproduce call.speech on main 77fadc0; green after the repair. Focused handler/pacer/controller tests passed 53/53, and expanded handler/lifecycle/call-control tests passed 75/75. Touched-file lint/format and independent Codex autoreview P0-P3 passed. PR CI supplies broad proof. The 43-line regression allocation covers playback echo, tail expiry, both interruption owners and renewed playback without additional test scaffolding. Co-authored-by: mnowrot <[email protected]> (cherry picked from commit 2bbce75) Release adaptation: Bounded echo suppression at existing audio controller; preserves local and provider barge-in and caller finals. Later greeting-audibility and late-transcript work remains separate. Co-authored-by: RomneyDa <[email protected]>
Refs #159140 — this PR fixes the plugin-side echo barge-in. The provider-side (Google VAD) echo interruption and the provider-committed echo transcript remain open in the linked issue. The current-head real-call observation is below; the ownership decision is in the decision comment on this PR.
What problem this solves
The realtime handler's local RMS gate counted any inbound energy as caller speech. Assistant audio that leaks back through the line (echo) therefore armed the gate, which cancelled the agent's own turn mid-sentence and could store caller lines the caller never said. Reported in #159140.
What this change does
RealtimeAudioPacer.getPlayoutEndsAt()projects the paced stream clock ontoDate.now(), so the handler knows when the assistant's audio has actually reached the line. While paced audio is queued, or within a 400 ms tail after the last outbound chunk (ASSISTANT_SPEECH_TAIL_MS), the local RMS gate is fedrms 0, so it cannot armhandleBargeIn. Inbound audio is still forwarded to the realtime provider, so provider-owned barge-in is untouched. Once the window closes, the gate behaves exactly as it does on the merge base.Scope — what this change does not do
user:turn, so the phantom caller transcript persists. Both remain open in [Bug]: realtime voice call treats the agent's own leaked audio as caller speech #159140 — this PR does not close it.Evidence
The current-head real-call observation (below) measured the local gate going from 12 echo-driven detections at −12 dB on the merge base to 0 on this head, with genuine caller turns still delivered and the post-window fallback intact. The redacted per-frame traces, the harness and the per-scenario numbers are in the observation section below.
Revision 5: reduced to the change the observation supports
Head:
9b0e825a4bc37ce6c08a361e499737e43906fb8afix(voice-call): mask local barge-in while assistant audio plays out. It is one commit on top ofa6ec34f7, pushed as a fast-forward.Why
The real-call observation on
2181c268showed two things:inputTranscriptionafter the line has gone quiet.Only
b918ba3chad zero echo barge-ins at −12 dB, and that commit fully masked the local gate while assistant audio was active. This revision keeps that masking and drops everything else.What remains
RealtimeAudioPacer.getPlayoutEndsAt()projects the paced stream clock ontoDate.now()and is clamped on clear or close. Together withASSISTANT_SPEECH_TAIL_MS = 400, it defines the window: assistant audio is active whilehasPendingAudio() || now < playoutEndsAt + 400 ms.handleBargeIn. Inbound audio is still forwarded to the provider, so provider-side barge-in is untouched.What was removed and why
These were removed:
ECHO_OVERLAP_MARGIN,ECHO_AMBIGUITY_MARGIN,ECHO_BASELINE_SMOOTHING,ECHO_FLOOR_MIN_SAMPLESandPHANTOM_GUARD_MIN_RMSechoBaselineRms/Samples,maxEchoInputRms,maxRecentInputRmsandcallerAudioSinceTranscriptresetInputAccountingrealtime phantom transcript suppressedbranchThe floor did not stop echo barge-in; it only postponed it. The phantom guard never fired on a real call. Both added complexity with no observed benefit.
The phantom-transcript symptom is not fixed by this PR. The provider drives it: the provider commits the final input transcription after playout has ended. It remains open as a follow-up.
Diff vs merge base
7ff7042d: 4 files, +261/−46. Production code accounts for +33/−1 of that (realtime-handler.ts+16/−1,realtime-audio-pacer.ts+17); the rest is tests. For comparison, the diff was +469/−36 ata6ec34f7. Diff vsa6ec34f7: 3 files, +182/−400.Test-contract change (pending Voice Call owner approval)
Three existing
realtime-handler.test.tscases asserted that the local gate barges in on loud input while assistant audio is still playing out, or within 400 ms of playout ending. Issue #159140 reports exactly that behaviour as the bug: echo of the agent's own audio arms the local barge-in gate and cancels the agent's turn. The level gate cannot tell echo from the caller, so those assertions encoded the defect. Each test keeps its intent under the new contract:keeps local barge-in fallback for providers without speech-started events→masks local barge-in during playout and keeps the fallback for providers without speech-started eventshandleBargeInand noclear. After the window, a second burst asserts the original cancelled turn,clear,handleBargeIn({ audioPlaybackActive: true }), andoutput.audio.doneon the cancelled turn.lets a session bridge override provider-level barge-in capabilities→... once playout endshandlesInputAudioBargeIn: falsehands barge-in to the local gateclear, andhandleBargeIn({ audioPlaybackActive: true }).clears remote playback after local pacing and output state have finished→clears remote playback after paced playout and output state have finishedresponse.doneand playout, the local gate clears remote playbackhandleBargeIn({ audioPlaybackActive: false }), exactly one extraclear, and noturn.cancelled.Only
Dateis faked (vi.useFakeTimers({ toFake: ["Date"] })), so no real sleeps are added. The socket, the pacer timers andvi.waitForall stay on real timers.Trade-off
While a provider's local gate owns barge-in (no speech-started events, or a bridge override), a caller can no longer interrupt through the local gate during assistant playout or its 400 ms tail. The provider still receives every inbound frame. Barge-in by providers that own it (speech-started events) is unaffected. We accept this because a false barge-in on echo cancels the agent's own turn. That is the reported and observed failure, and it happens far more often than a genuine interruption during playout.
Lanes (on
9b0e825a, run vianode --import ./scripts/tsx.mjs scripts/run-vitest.mjs run …)realtime-handler.test.ts+realtime-handler.persistence.test.tsextensions/voice-call/src/webhook/*.test.tsfiles (explicit list)realtime-handler.echo-guard.test.tsnpx oxlint --tsconfig extensions/tsconfig.json extensions/voice-call/src/webhooknpx oxfmt --check(4 touched files)git diff --checkNot run:
pnpm tsgo:extensions:test(it runs out of memory on the 7.7 GB host) andscripts/run-oxlint.mjs(it refuses the external dependency links). No real-call proof was captured on this head.Negative control (current tests, merge-base handler
7ff7042d)realtime-handler.echo-guard.test.ts: 4 of 4 fail. Each failure ishandleBargeIncalled once, which means echo barge-in fires.realtime-handler.test.tscases: both masking cases fail. Theclears remote playbackcase passes, as expected, because it exercises post-window behaviour that the merge base shares.Real-call observation on head
9b0e825a(Revision 6)What this is: This is a real Google Live provider session with real speech audio, running through the real
RealtimeCallHandlerand a real carrier WebSocket. The line echo is simulated at the media-frame level. It is nota PSTN/telephony call.
Setup:
9b0e825a,realtime-handler.tsblob6894b015. Contrast: merge base7ff7042d, bloba8bdb29d.gemini-2.5-flash-native-audio-preview-12-2025overwss://generativelanguage.googleapis.com(TLSv1.3,authorized=true, serversetupComplete), with no mocks. RawinputTranscriptionwire frames matched the providercallbacks 1:1.
supportsBargeIn: true,handlesInputAudioBargeIn: false.ffmpeg … -f mulaw→ 20 ms frames.turn.cancelleduser:)user:)user:)What this shows:
the echo 9–10 times per greeting. Google's transcription of the echo is still committed as a
user:turn whilethe caller is silent. The mask removes only the host's barge-ins on echo.
("Hello.", "the capital.") were merged into the delivered turn.
spoke over the assistant for 2023 ms, and the local gate never fired. Only Google's VAD stopped playback, 2.03 s
after caller onset. A bridge without provider barge-in would have kept playing until the queue and the 400 ms tail
finished. While assistant audio plays, the local gate does not interrupt. Interruption is deferred until playout
ends; it is not removed (C: the gate fired 292 ms after onset once the window closed).
Not exercised: a PSTN or acoustic echo path, a bridge with no provider VAD (the B conclusion for such bridges is
inferred), other providers or models, and repeat runs.