Skip to content

fix(google): avoid duplicate turn completion after voice interruption - #133365

Merged
steipete merged 1 commit into
mainfrom
codex/voice-google-interruption
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/voice-google-interruption

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #133351

What Problem This Solves

Fixes an issue where Google Live Browser Talk would create an extra ended turn, or prematurely end the next input turn, when Google completed an already-interrupted response.

Why This Change Was Made

Google sends an interruption followed by completion of that same model turn. Input transcription is independently ordered and may arrive between those messages. The Google browser producer now retains the interruption fact until the matching completion and consumes that completion without emitting a second terminal event. Immediate cancellation, audio clearing, and transcript finalization are unchanged.

This belongs in the Google producer: a generic no-active-turn guard would still incorrectly end an intervening input turn. Gateway relay uses a different event producer and does not emit this duplicate pair. No auth, configuration, protocol, persistence, or provider deadline changes. Provenance: introducing commit unknown; the previous interruption test omitted the separate completion frame.

User Impact

Interrupted Google browser calls preserve Talk turn correlation. The evidence does not show lost saved transcripts or an audible defect, and this change makes no claim to improve speech recognition accuracy. No rendered UI changes.

Evidence

Two regression cases failed before the fix: completion before the next input, and completion after an independently ordered input. The same-frame control already passed. After the fix, all 59 Google browser tests passed across transcript finality, transport, control, video, and setup timeout coverage.

node scripts/run-vitest.mjs ui/src/pages/chat/realtime-talk-google-live-transcripts.test.ts --reporter=verbose
# Before: 2 failed, 4 passed; extra terminal event and wrong subsequent turn IDs.

node scripts/run-vitest.mjs ui/src/pages/chat/realtime-talk-google-live-transcripts.test.ts ui/src/pages/chat/realtime-talk-google-live.test.ts ui/src/pages/chat/realtime-talk-google-live-control.test.ts ui/src/pages/chat/realtime-talk-google-live-timeout.test.ts ui/src/pages/chat/realtime-talk-google-live-video.test.ts
# After: 59 passed.

A live Google v1beta call using gemini-3.1-flash-live-preview and SDK 2.18.0 reproduced the separate-frame sequence with synthetic speech. The provider emitted interruption at 4047 ms, completion at 4142 ms, the next input transcript at 5726 ms, then “Crystal” and a normal completion. Zero errors; clean close. Input-before-completion is supported by the specification and tested deterministically, but was not observed in that call. The live probe establishes the provider sequence; the actual browser producer and shared emitter are exercised by the regression tests.

Contract checked directly: https://ai.google.dev/api/live#bidigeneratecontentservercontent and installed SDK types. Fresh pinned Codex review found no actionable P0-P2 findings. Scoped formatting and whitespace checks passed.

Production: +9/-1 (net +8), recording a provider-owned fact not previously retained. Tests: +59/-31, replacing the incomplete test with three ordering cases. The shared emitter, relay, and OpenAI paths are unchanged.

Provider contract confirmation

Maintainer verification addresses the review's unavailable-network limitation and rank-up request. Google’s current Live API reference, checked on August 30, states the interrupted generation sequence as interrupted > turn_complete; the installed @google/genai 2.18.0 declarations repeat: “in interrupted turn, it will go through interrupted > turn_complete.” The same reference says input transcription has no guaranteed ordering, which is why the marker remains through intervening input. The retained live trace independently confirms one interruption and its separate completion, 95 ms apart.

Maintainer decision: retain the producer-local marker. Its eight net production lines record the required cross-frame fact; a shared-emitter guard would not protect an intervening input turn. Exact-head CI passed: https://github.com/openclaw/openclaw/actions/runs/33321485000

@steipete steipete self-assigned this Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: S maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 16:05
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 12:13 PM ET / 16:13 UTC.

ClawSweeper review

What this changes

The PR retains a Google Live interruption marker until its later completion event, preventing that completion from ending a newer browser Talk turn.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. The source path supports this focused producer-bound repair and I found no actionable defect introduced by the patch; it remains paired with the open linked issue and has a protected maintainer label. Independent Google contract inspection was unavailable because network DNS failed and this worktree has no installed dependency tree.

Priority: P1
Reviewed head: 168397b39afc1c4ddc0a0238b4206811da0ecd09
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with useful ordering coverage and supplied live trace evidence; direct provider-contract inspection remains unavailable to this reviewer.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The repository-state author association is MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a live Google sequence and focused transport regression evidence, which maps to the changed producer path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository-state author association is MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a live Google sequence and focused transport regression evidence, which maps to the changed producer path.
Evidence reviewed 6 items Current-main failure path: The base transport emits turn.cancelled for interrupted content and then emits turn.ended for any later turnComplete; the shared emitter clears the active ID on cancellation and allocates one for the intervening transcript, so the later completion can close the newer turn.
Introduced repair: The PR records interruption at the Google transport owner, suppresses only the subsequent completion terminal event, then clears the marker after consuming that completion.
Behavioral regression coverage: The table-driven test covers completion before input, input before completion, and same-frame interruption/completion, asserting both final transcripts and exact turn IDs rather than transport internals.
Findings None None.
Security None None.

How this fits together

Google Live Browser Talk translates provider WebSocket frames into transcript and terminal events for the shared browser turn emitter. The emitter assigns a turn identity to each event and releases it at terminal events.

flowchart LR
  A[Google Live API] --> B[Browser WebSocket transport]
  B --> C[Interruption and transcript handling]
  C --> D[Terminal event decision]
  D --> E[Shared Talk event emitter]
  E --> F[Browser Talk turns]
Loading

Decision needed

Question Recommendation
Can the responsible maintainer confirm that Google Live interruption has one matching completion event before this stateful suppression is merged? Confirm the provider sequence: Verify the documented or captured Google Live sequence, then retain the producer-local marker and merge after exact-head checks complete.

Why: The implementation is localized and covered, but direct provider-contract inspection was blocked in the review environment.

Before merge

  • Resolve merge risk (P1) - The interruption marker assumes each interrupted provider turn has one subsequent completion; direct Google documentation and installed SDK-type verification were unavailable in this review environment.
  • Resolve merge risk (P1) - Production code grows by eight net lines; retaining this provider-owned cross-frame fact appears necessary, and no smaller owner-boundary refactor was found.
  • Complete next step (P2) - The protected maintainer label and unavailable direct provider-contract lookup require explicit maintainer confirmation before merge; no mechanical repair is indicated.
Agent review details

Security

None.

PR surface

Source +8, Tests +28. Total +36 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 9 1 +8
Tests 1 59 31 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 68 32 +36

Review metrics

Metric Value Why it matters
Production versus test LOC production +8 net; tests +28 net The production growth is limited to recording and consuming a cross-frame provider fact; the test increase replaces one incomplete scenario with three ordering cases.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #133351
Summary: This PR explicitly supplies the candidate repair for the linked Google Live interruption report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Verify the completion pairing before merge (recommended)
    Confirm that an interruption has exactly one matching completion event through Google’s current contract or a retained provider trace, then keep the suppression local to this transport.
  2. Accept the trace-only evidence
    Merge based on the supplied live trace and focused ordering tests, accepting residual risk if provider completion semantics differ.

Technical review

Best possible solution:

Keep the guard in the Google browser producer, after confirming the provider’s interrupted-to-completion pairing from its contract or retained live trace; do not add a generic shared-emitter workaround.

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

Yes, from source: send interrupted, an independently ordered finalized input transcript, then turnComplete on current main; the shared emitter will assign the input a new turn ID before that completion. I did not execute the scenario in this read-only review.

Is this the best way to solve the issue?

Yes, subject to provider-contract confirmation. The Google transport owns the provider-specific interruption/completion pair, whereas a shared-emitter guard would not know which completion belongs to the interrupted provider turn.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Incorrect terminal-turn correlation affects active Google Live voice conversations.
  • add merge-risk: 🚨 session-state: The new marker controls whether a later provider completion can terminate the current browser Talk turn.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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: The repository-state author association is MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a live Google sequence and focused transport regression evidence, which maps to the changed producer path.

Label justifications:

  • P1: Incorrect terminal-turn correlation affects active Google Live voice conversations.
  • merge-risk: 🚨 session-state: The new marker controls whether a later provider completion can terminate the current browser Talk turn.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository-state author association is MEMBER, so the external-contributor proof gate does not apply; the PR body nevertheless supplies a live Google sequence and focused transport regression evidence, which maps to the changed producer path.

Evidence

What I checked:

  • Current-main failure path: The base transport emits turn.cancelled for interrupted content and then emits turn.ended for any later turnComplete; the shared emitter clears the active ID on cancellation and allocates one for the intervening transcript, so the later completion can close the newer turn. (ui/src/pages/chat/realtime-talk-google-live.ts:418, 279a12cf8b89)
  • Introduced repair: The PR records interruption at the Google transport owner, suppresses only the subsequent completion terminal event, then clears the marker after consuming that completion. (ui/src/pages/chat/realtime-talk-google-live.ts:381, 168397b39afc)
  • Behavioral regression coverage: The table-driven test covers completion before input, input before completion, and same-frame interruption/completion, asserting both final transcripts and exact turn IDs rather than transport internals. (ui/src/pages/chat/realtime-talk-google-live-transcripts.test.ts:68, 168397b39afc)
  • Caller and sibling boundaries: RealtimeTalkSession selects this transport only for provider-websocket sessions; Gateway relay receives server-owned Talk events, while WebRTC derives terminal events from response outcomes, so neither shares this Google frame-pair decision. (ui/src/pages/chat/realtime-talk.ts:100, 168397b39afc)
  • Feature history: Recent history identifies the preceding merged Google Live transcript work as the same area; the exact original regression introduction remains unproven because required promisor objects could not be fetched. (ui/src/pages/chat/realtime-talk-google-live.ts:418, c5c6199bc859)
  • Dependency contract limitation: The Google provider directly imports @google/genai LiveServerContent, establishing the provider-contract dependency signal. The worktree has no node_modules and DNS prevented direct inspection of the linked Google documentation; this is a reviewer limitation, not missing contributor proof. (extensions/google/realtime-voice-provider.ts:20, 168397b39afc)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record a redacted provider documentation or SDK-type excerpt that confirms the interrupted-to-completion pairing used by the new marker.

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

Copy link
Copy Markdown
Contributor Author

Confirmed the provider contract directly and added the requested excerpt to the PR body. Current Google docs and installed SDK 2.18.0 both specify interrupted generation followed by its completion; input transcription remains independently ordered. The live trace confirms the separate pair 95 ms apart. This resolves the review's contract-confirmation/owner decision and completes its rank-up move.

Retaining the Google-owned marker is the best fix: its +8 net lines preserve a fact that a generic emitter cannot infer. The regression first failed in both separate-frame orders; all 59 focused tests pass. The patch is identical after moving onto an independent main baseline, and fresh pinned Codex review has no actionable P0-P2 findings. No audible failure or physical-browser live proof is claimed.

Exact head 168397b is green: https://github.com/openclaw/openclaw/actions/runs/33321485000

Native review artifacts validate. Proceeding through repository-native prepare/merge; no additional GitHub approval rule is enforced.

@steipete
steipete merged commit 725222d into main Aug 30, 2026
218 checks passed
@steipete
steipete deleted the codex/voice-google-interruption branch August 30, 2026 16:28
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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.

[Bug]: Google Live interruption creates an extra terminal Talk turn

1 participant