Skip to content

fix: end failed voice calls and preserve Gemini Live transcripts - #133157

Merged
steipete merged 2 commits into
mainfrom
codex/voice-stress-lifecycle
Aug 30, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/voice-stress-lifecycle

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #133116
Closes #133117
Closes #133118

What Problem This Solves

Fixes an issue where browser voice calls could remain logically open after their microphone stopped, GPT-Live control-socket failures looked like normal hangups, and successful Gemini Live conversations did not save complete utterances during the call.

Why This Change Was Made

Microphone acquisition, cancellation, and track lifetime now have one owner shared by WebRTC, Google Live, Gateway relay, and composer dictation. The existing terminal Talk event retires the client-owned logical session while accepted transcript writes drain; the actionable error remains visible. GPT-Live carries errors through its existing lease disposer and reports one terminal outcome after cleanup, preserving GA bridge ownership and normal stop behavior.

Google's browser and Gateway producers follow current Live transcription boundaries: Gemini 3.1 input arrives as a complete utterance without finished; output fragments finalize at explicit transcription or generation completion/interruption. Older input fragments retain their explicit finality contract, including finish-only events. The browser uses bounded per-role buffers and the canonical transcription stream instead of a second model-text path.

No provider switch, automatic reconnect, configuration option, schema/protocol version change, dependency, or credential-storage change.

User Impact

A lost microphone or GPT-Live control connection produces a visible failure and releases the call. Complete Gemini utterances are saved during a conversation rather than waiting until hangup or saving only a final fragment. Already-accepted transcript writes remain ordered before logical close, and stale callbacks cannot close a replacement call.

Evidence

Every repaired defect has a failing pre-fix reproduction. The initial stress baseline passed 784 tests across 44 files; the new fault cases exposed gaps in that coverage.

  • Live GPT-Live broker, saved ChatGPT OAuth, real HTTP 200 SDP exchange: terminating the actual test sideband reported only close:completed before the patch; the same probe now reports error then close:error exactly once. Normal stop remains close:completed. Pending/in-flight/active/reservation counts return to zero in both paths.
  • Live GPT-Live speech: repeated two-turn calls passed with Cove, Spruce, and Vale; startup cancellation at 0/50/250 ms released all connections, with no audio after close. One initial Spruce synthetic utterance was misrecognized; four subsequent Spruce utterances passed. This is retained as a recognition limitation, not hidden as a clean run.
  • Live Gemini 3.1: two spoken turns returned complete input/output transcriptions and audio without any finished flag, followed by generationComplete and turnComplete. Replaying that trace failed in both pre-fix producers. Older fragmented/finish-only browser transcripts also failed pre-fix.
  • Browser lifecycle proof uses native browser media and a local WebRTC pair, with fault injection at the track-ended boundary. It verifies visible failure, media/peer release, and logical close before error dismissal. It does not claim physical USB removal.

External contracts personally inspected at OSS Codex dde85b435b16994f956bce08e5fb796ed94c27fd: call transport, terminal WebSocket handling, and sideband ownership/recovery; Google Live events; Google ADK Gemini 3.x input finality; W3C capture lifetime.

Known limits and follow-ups: actual signed-in Chrome speech could not complete because microphone acquisition remained pending; page start/cancel worked, but this is not microphone roundtrip proof. Codex's resumable sideband recovery remains a separate ownership-sensitive improvement. Google's explicit manual-VAD setting needs activity boundaries (an isolated live call without them produced no turn); separate interruption/completion frames can also create an empty diagnostic turn. GA sub-250 ms provider-VAD interruption, dictation append backpressure, and exceptional camera/meter consumer cleanup remain separate follow-up investigations.

Production LOC: +433/-303 (net +130); discounting 57 unchanged lines moved into the private HTTP helper gives +376/-246. Tests/test support: +975/-85; docs: +9/-0. Growth adds bounded canonical Google transcript accumulation (+63), one broker terminal-outcome owner (+45 including extraction overhead), logical-session retirement with shared retry policy (+16), and shared microphone ownership (+6). Removed duplicate media acquisition/cancellation cleanup, duplicate write/close retry loops, and the browser model-text transcript path. No config/default or persistence surface was added.

Provenance: the unconditional GPT-Live completed callback and separate startup error callback were added by #133019, verified against raw parent ff6634b of e41c5b8. The earlier generic socket-close behavior, microphone lifetime gap, and Google finality gap predate this repair; exact introducing commits are not established here.

Native browser fault proof on the repaired code (synthetic test account; before/after injected track-ended event, not pre-fix or physical-device screenshots):

Active browser voice call before microphone loss

Actionable error after microphone loss

Validation on the final frozen patch: 533 passed — OpenAI 70 tests/5 files, Google 80/3, UI 372/21, and native browser E2E 11/2. The new microphone scenario passed four subsequent runs. Its first run failed before Listening with no captured setup state; diagnostic capture was added, with no timeout or SDP change. That first failure remains unclassified. Fresh independent Codex review found no actionable P0–P2 findings after all production/test refactors. The real GPT-Live broker normal-stop and socket-loss probes passed again after helper extraction.

Local check:changed found and prompted repair of the dead export and stale composer mock. It also cannot complete type checking against this worktree’s shared stale dependencies: the UI declares pako 3.0.1 (bundled declarations), but the shared tree resolves pako 1.0.11 without types. The unrelated checkout was not reconciled. Clean hosted CI on the exact PR head is required before merge.

Final static proof: all scoped lint/styles/format, max-lines/assertion ratchets, unused exports, and plugin production/test types pass. The final test-only spy-handle cleanup separately passed 25 input tests plus lint/format; it did not change the reviewed production bytes.

CI integration repair: the first hosted run failed build/types/lint because main’s #132932 moved getPluginToolSideEffectOwnerKey but left Code Mode recovery importing the former module. This branch refresh also updates that one import to the canonical src/plugins/tool-metadata.ts owner, with no policy change. The existing recovery test reproduced three failures before correction; all 16 focused recovery/integration tests pass afterward. Voice implementation bytes are unchanged by the refresh.

@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 docs Improvements or additions to documentation app: web-ui App: web-ui extensions: openai extensions: google size: XL maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete steipete self-assigned this Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 07:21
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 30, 2026
@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, 3:40 AM ET / 07:40 UTC.

ClawSweeper review

What this changes

This PR ends failed browser voice calls, preserves finalized Google Live utterances during calls, and updates Code Mode recovery to the current tool-metadata owner.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this maintainer-labeled PR open for normal review. The introduced repairs align with the affected lifecycle owners and regression coverage; exact-head CI is still running and the Google provider contract could not be independently rechecked in this environment.

Priority: P1
Reviewed head: 5c267586f494479754a1cacb0a876e07a42467ce

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong focused coverage and coherent owner-boundary changes, with remaining CI and independently inaccessible vendor-contract verification.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to the contributor-proof gate because Repository State identifies the author as a MEMBER; the supplied body nevertheless records live GPT-Live, Google Live, and browser fault evidence tied to the changed owners.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to the contributor-proof gate because Repository State identifies the author as a MEMBER; the supplied body nevertheless records live GPT-Live, Google Live, and browser fault evidence tied to the changed owners.
Evidence reviewed 6 items Shared microphone lifecycle: The introduced controller fences retired tracks, removes listeners before stopping tracks, and reports unexpected microphone termination only after resource release.
Google transcript owner: Separate role buffers finalize Gemini 3.1 input at its own boundary and assistant output at generation/interruption/turn boundaries; the session harness persists only finalized entries.
GPT-Live terminal outcome: Sideband error and abnormal close now pass an error into the active-session disposer, whose once-only terminal reporter emits error before error closure.
Findings None None.
Security None None.

How this fits together

Browser Talk acquires microphone tracks and routes a call through WebRTC, Google Live, or the Gateway relay. Terminal events retire the client session after accepted transcript writes drain, leaving an actionable status for the chat UI.

flowchart LR
  A[Browser microphone] --> B[Talk transport]
  B --> C{Provider event}
  C --> D[Google Live transcript handling]
  C --> E[OpenAI control sideband]
  D --> F[Talk session owner]
  E --> F
  F --> G[Gateway session history]
  F --> H[Visible chat status]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI is still in progress, so merge readiness is not established.
  • Resolve merge risk (P1) - Google Live transcript finality is a provider-dependent session-history change; vendor documentation/types could not be fetched because DNS was unavailable, so retain the supplied live trace and exact-head checks as the merge evidence.
  • Resolve merge risk (P1) - After separating test support and docs, production code is net +19 lines across shared call lifecycle owners; cross-transport lifecycle coverage should remain required.
  • Complete next step (P2) - This maintainer-authored, maintainer-labeled PR is not eligible for automated repair routing; it needs ordinary exact-head CI completion and maintainer review.
Agent review details

Security

None.

PR surface

Source +244, Tests +776, Docs +9. Total +1029 across 32 files.

View PR surface stats
Area Files Added Removed Net
Source 14 550 306 +244
Tests 17 858 82 +776
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 32 1417 388 +1029

Review metrics

Metric Value Why it matters
Production versus test delta production +320/-301 (net +19); tests +975/-85; test support +113/-2; docs +9/-0 The small production increase consolidates shared lifecycle and transcript ownership, while most added coverage is regression and browser-fixture proof.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/openai/realtime-quicksilver-offer-http.ts, vector/embedding metadata: src/agents/embedded-agent-runner/run/code-mode-reconciliation.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Confirm the provider finality evidence (recommended)
    Before merge, retain a redacted current Gemini 3.1 event trace or equivalent vendor-contract evidence showing that input utterances arrive complete without a finished flag.
  2. Accept the documented model behavior
    Merge with maintainer acceptance that the supplied live trace, focused regressions, and provider documentation are sufficient for the model-specific transcript boundary.

Technical review

Best possible solution:

Merge only after exact-head CI completes and the recorded Gemini 3.1 event trace is retained as evidence for the model-specific finality rule.

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

Yes—source and focused regressions establish controlled failure paths for microphone termination, sideband failure, and missing Google finality flags. The reviewer did not execute them because this is a read-only checkout and the package-manager host cache is unavailable.

Is this the best way to solve the issue?

Yes. The patch centralizes microphone ownership, terminal outcomes, and per-role transcript finality at their shared owners instead of adding transport-specific cleanup guards.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The PR repairs active browser voice calls that can otherwise remain logically open and lose in-call transcript history.
  • add merge-risk: 🚨 session-state: Model-specific transcript finality changes when browser and Gateway sessions append utterances to the active history.
  • 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: Not applicable to the contributor-proof gate because Repository State identifies the author as a MEMBER; the supplied body nevertheless records live GPT-Live, Google Live, and browser fault evidence tied to the changed owners.

Label justifications:

  • P1: The PR repairs active browser voice calls that can otherwise remain logically open and lose in-call transcript history.
  • merge-risk: 🚨 session-state: Model-specific transcript finality changes when browser and Gateway sessions append utterances to the active history.
  • 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: Not applicable to the contributor-proof gate because Repository State identifies the author as a MEMBER; the supplied body nevertheless records live GPT-Live, Google Live, and browser fault evidence tied to the changed owners.

Evidence

What I checked:

  • Shared microphone lifecycle: The introduced controller fences retired tracks, removes listeners before stopping tracks, and reports unexpected microphone termination only after resource release. (ui/src/pages/chat/realtime-talk-input.ts:264, 4248e95b60df)
  • Google transcript owner: Separate role buffers finalize Gemini 3.1 input at its own boundary and assistant output at generation/interruption/turn boundaries; the session harness persists only finalized entries. (extensions/google/realtime-voice-provider.ts:991, 5c267586f494)
  • GPT-Live terminal outcome: Sideband error and abnormal close now pass an error into the active-session disposer, whose once-only terminal reporter emits error before error closure. (extensions/openai/realtime-quicksilver-session.ts:228, 5c267586f494)
  • Current metadata owner: The refresh changes Code Mode recovery to import the helper from its current dependency-light owner, where the helper is exported and used by adjacent embedded-runner code. (src/plugins/tool-metadata.ts:62, 5c267586f494)
  • Current-main necessity check: The fetched current-main commit and PR head have the recorded base as their merge base; the comparison retains this PR's full introduced surface, so main has not superseded it. (f1d2c5b91f80)
  • Documentation inspection limitation: Relevant Talk and Google-provider documentation was read directly, but the required docs inventory command could not start because Corepack attempted a cache write on the read-only reviewer host. Public docs: docs/nodes/talk.md. (docs/nodes/talk.md:39, 5c267586f494)

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.

  • Let the exact-head required checks complete green.
  • Retain a redacted Gemini 3.1 event trace or stable vendor-contract reference for the missing-finished finality rule.

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

Maintainer review complete on 5c267586f494479754a1cacb0a876e07a42467ce. Both rank-up moves are satisfied: exact-head CI is green, and the Gemini 3.1 event trace is retained below alongside the stable ADK input-finality reference and Live server-content contract.

This is a sanitized projection of the observed SDK 2.18.0 events from two synthetic spoken turns. Audio payloads and session/auth metadata are omitted; the transcription objects contain no finished field. Both assistant transcriptions precede generation and turn completion.

[
  {
    "milliseconds": 3345,
    "event": "serverContent",
    "inputTranscription": {
      "text": "Please reply with the single word glacier."
    }
  },
  {
    "milliseconds": 3893,
    "event": "serverContent",
    "outputTranscription": {
      "text": "Glacier."
    }
  },
  {
    "milliseconds": 4128,
    "event": "serverContent",
    "generationComplete": true
  },
  {
    "milliseconds": 4733,
    "event": "serverContent",
    "turnComplete": true
  },
  {
    "milliseconds": 7555,
    "event": "serverContent",
    "inputTranscription": {
      "text": "Now reply with the single word crystal."
    }
  },
  {
    "milliseconds": 8076,
    "event": "serverContent",
    "outputTranscription": {
      "text": "Crystal."
    }
  },
  {
    "milliseconds": 8299,
    "event": "serverContent",
    "generationComplete": true
  },
  {
    "milliseconds": 8940,
    "event": "serverContent",
    "turnComplete": true
  }
]

The candidate OpenClaw provider separately emitted all four whole final transcripts while still connected, before close, with 97,952 output audio bytes, zero errors, and one close. Browser/provider regressions cover older finish-only input, independent role buffers, completion/interruption, and callback closure. The final voice run passed 533 tests across unit and native browser lanes; the Code Mode integration repair passed another 16 focused tests. Fresh pinned Codex autoreview found no actionable P0–P2 findings.

No storage migration applies. realtime-quicksilver-offer-http.ts contains only moved CORS, HTTP response, and response-delivery helpers; its cache header is no-store, not a persistent cache schema. The Code Mode change imports existing in-memory tool ownership metadata, not vector/embedding state. No SQLite, schema, persisted format, or config/default change is present.

Audited production LOC is +433/-303 (net +130), or +376/-246 after discounting 57 unchanged moved HTTP lines. Tests/support are +975/-85 and docs +9/-0. The growth supplies bounded Google transcript accumulation and single lifecycle/outcome owners; cross-transport cancellation, microphone loss, stale events, callback failure, and transcript-drain coverage remain in the PR. No review findings remain unaddressed. The signed-in physical-microphone proof limitation remains explicit in the PR body.

@steipete
steipete merged commit c5c6199 into main Aug 30, 2026
196 of 197 checks passed
@steipete
steipete deleted the codex/voice-stress-lifecycle branch August 30, 2026 07:49
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor Author

Post-merge verification on c5c6199: the clean managed build, copied-state canary, unchanged shared/agent schema checks, activation, deep health, and HTTP UI checks passed. The running Gateway reports OpenAI realtime ready, and a fresh browser chat turn completed.

Saved OpenAI OAuth still creates real GPT-Live calls and exchanges audio. Additional post-deployment stress results are mixed; these do not support a blanket reliability claim:

Probe Observed result
Single requested word Input transcript contained “glacier”; output transcript was “leisure.”
Two-turn repeated-word call First turn completed; second final transcript did not arrive within the unchanged 30-second response deadline.
Repeated-word call with bounded event trace Both replies completed, but the second input transcript omitted the requested word, so repeated output alone is insufficient accuracy proof.
Distinct-word call Sent separate PCM fixtures requesting “glacier,” then “crystal.” Two user/assistant final pairs arrived, but the second user and assistant transcripts both said “glacier.”

All four calls connected using the saved OAuth profile. Cleanup reported exactly one close, no provider-error callbacks, no late audio, and no connected peer after close. The distinct-word trace contained fresh input/turn events for the second utterance; the input fixture bytes were independently distinct. No deadline was increased and no failed assertion was relaxed to obtain a pass.

Named follow-up: GPT-Live distinct-turn accuracy and intermittent missing second-turn completion. Investigate provider transcription/turn behavior versus relay media timing with captured wire/media evidence; the current observations do not establish the responsible owner. The landed fixes address microphone termination, terminal socket failure, and Google finalization; they do not claim to resolve this follow-up.

The real signed-in Chrome microphone start also remained at “Connecting voice input…” after refresh, with no visible prompt or error; cancellation worked. Native Chromium fault-injection proof is retained separately and must not be described as a completed physical-microphone roundtrip. The deployment itself remains healthy.

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

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation extensions: google extensions: openai 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: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

1 participant