Skip to content

fix(gateway): preserve final speech during transcription shutdown - #118693

Merged
steipete merged 1 commit into
mainfrom
codex/qa0803-talk-final-transcript-drain
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa0803-talk-final-transcript-drain

Conversation

@steipete

@steipete steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Deliver all final and partial provider speech transcripts emitted while a Talk session closes.
  • Preserve strict connection ownership, immediate cancellation/disconnect, resource limits, and bounded teardown.

Root cause and architectural owner

The Talk Gateway removed its exact session owner before calling the transcription provider's graceful close. Deepgram, ElevenLabs, Mistral, and other providers emit their final transcript only during close; the shared websocket owner intentionally retains its socket for five seconds, but the Gateway had already rejected every callback. Users lost their final spoken words without any visible error.

The Gateway now keeps the same authenticated relay owner for the existing bounded five-second provider finalization window. It accepts all final and partial callbacks for already-received audio, including multiple distinct finals; new browser audio and stale ready/foreign-generation callbacks remain rejected. Empty sessions, cancellation, disconnect, provider errors, and expiry retain their immediate terminal behavior.

Actual consumer/owner proof

  • Actual production relay reproduced zero final events before repair despite both synchronous and asynchronous provider flush callbacks.
  • Accepted independent adversarial cases additionally proved and repaired stale ready after close, multiple late final utterances, intervening partial updates required by the real Control UI quiet timer, and prior completed turns with new buffered audio.
  • Actual Gateway owner plus real UI dictation consumer: 35/35 passing.
  • One provider close and one terminal event; no post-cancel transcript; connection/global limits remain enforced throughout the existing bounded interval.
  • Type-aware lint, formatting, and diff checks: clean.
  • Fresh independent structured Sol/high review: no findings, confidence 0.91.
  • Production delta: +34 lines, required to own graceful drain and session identity.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 10:02 AM ET / 14:02 UTC.

ClawSweeper review

What this changes

This PR keeps a Talk transcription relay registered for a bounded five-second provider-finalization window so final speech callbacks emitted by close() reach the originating browser connection.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The branch addresses a current Gateway lifecycle defect and is still necessary; the protected maintainer label keeps the final merge decision with a human reviewer.

Priority: P1
Reviewed head: 77e7027b789200cb91fa0aa4013d909e473bca2d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused root-cause repair with broad lifecycle regression coverage and credible after-fix behavior proof.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.
Evidence reviewed 5 items Current-main root cause: On current main, stopTalkTranscriptionRelaySession closes the relay immediately; closeTranscriptionSession removes it from the active-session map before invoking the provider close, while provider callbacks only resolve through that map. A provider final emitted from close() is therefore discarded.
Proposed owner-boundary repair: The branch retains the exact authenticated relay during a fixed five-second drain, rejects new client requests while draining, ignores late ready/speech-start callbacks, and still immediately tears down cancellation, disconnect, provider-error, and expiry paths.
Provider lifecycle contract: The shared realtime-transcription contract permits providers to invoke transcript and partial callbacks and exposes a synchronous close() method; it does not require callbacks to complete before close returns, so retaining the owner across finalization is the appropriate core lifecycle boundary.
Findings None None.
Security None None.

How this fits together

Talk transcription relays accept browser audio on an authenticated Gateway WebSocket connection, forward it to a realtime speech-to-text provider, and broadcast provider speech events back to that same connection. Session shutdown currently owns both provider teardown and the terminal Talk event, so callback ordering determines whether the final spoken words are visible.

flowchart LR
  A[Browser audio] --> B[Gateway relay]
  B --> C[Realtime transcription provider]
  D[Browser stops session] --> E[Bounded finalization window]
  C --> E
  E --> F[Same authenticated relay owner]
  F --> G[Final and partial Talk events]
  G --> H[Control UI dictation]
Loading

Before merge

  • Complete next step (P2) - Human merge review is required by the protected maintainer label; there is no discrete automated repair remaining.
Agent review details

Security

None.

PR surface

Source +34, Tests +310. Total +344 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 41 7 +34
Tests 1 310 0 +310
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 351 7 +344

Review metrics

Metric Value Why it matters
Production vs. test delta production +34 net; tests +310 The modest production growth establishes one bounded shutdown owner; the larger focused test expansion covers the callback-ordering and teardown invariants that make the lifecycle change safe.

Technical review

Best possible solution:

Merge the bounded owner-retention repair after the protected-label human review and the remaining CI complete, preserving immediate cancellation and disconnect behavior while allowing provider finalization callbacks.

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

Yes, by source: on current main a provider callback emitted synchronously or asynchronously from close() cannot resolve the deleted relay owner; the branch adds direct regression coverage for both orders.

Is this the best way to solve the issue?

Yes. Retaining only the already-authenticated owner for the provider's bounded finalization interval fixes the lifecycle owner rather than adding downstream retry or callback exceptions.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Current main can silently drop final spoken words during a normal Talk transcription shutdown, breaking a live Gateway-to-UI workflow without a visible recovery outcome.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.

Label justifications:

  • P1: Current main can silently drop final spoken words during a normal Talk transcription shutdown, breaking a live Gateway-to-UI workflow without a visible recovery outcome.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix Gateway relay plus real Control UI dictation run with 35/35 cases, and the supplied check context records a successful Real behavior proof check for this head.

Evidence

What I checked:

  • Current-main root cause: On current main, stopTalkTranscriptionRelaySession closes the relay immediately; closeTranscriptionSession removes it from the active-session map before invoking the provider close, while provider callbacks only resolve through that map. A provider final emitted from close() is therefore discarded. (src/gateway/talk-transcription-relay.ts:185, cad499d7ca06)
  • Proposed owner-boundary repair: The branch retains the exact authenticated relay during a fixed five-second drain, rejects new client requests while draining, ignores late ready/speech-start callbacks, and still immediately tears down cancellation, disconnect, provider-error, and expiry paths. (src/gateway/talk-transcription-relay.ts:419, 77e7027b7892)
  • Provider lifecycle contract: The shared realtime-transcription contract permits providers to invoke transcript and partial callbacks and exposes a synchronous close() method; it does not require callbacks to complete before close returns, so retaining the owner across finalization is the appropriate core lifecycle boundary. (src/realtime-transcription/provider-types.ts:20, cad499d7ca06)
  • Regression coverage: The branch adds focused cases for synchronous and asynchronous provider finals, multiple finals, already-ended turns, empty sessions, stale ready callbacks, disconnect, cancellation, errors, limits, and timeout cleanup. (src/gateway/talk-transcription-relay.test.ts:250, 77e7027b7892)
  • Feature-history routing: Blame identifies Peter Steinberger as the recent current-main owner of the existing relay lifecycle and the author of this repair; the branch is one commit atop merge base e99f6dc4c3e24f5f006d3040f9c74a09701293ce. (src/gateway/talk-transcription-relay.ts:185, 77e7027b7892)

Likely related people:

  • steipete: Current-main blame attributes the existing relay lifecycle to Peter Steinberger, and this focused repair continues that ownership boundary. (role: recent area contributor and repair author; confidence: high; commits: f6540b0a1f6c, 77e7027b7892; files: src/gateway/talk-transcription-relay.ts, src/gateway/talk-transcription-relay.test.ts)

Rating scale

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

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

Workflow

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

@steipete
steipete merged commit 6363875 into main Aug 3, 2026
131 of 140 checks passed
@steipete
steipete deleted the codex/qa0803-talk-final-transcript-drain branch August 3, 2026 14:25
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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