Skip to content

fix(talk): bound relay transcript persistence - #117215

Merged
vincentkoc merged 2 commits into
mainfrom
fix/talk-transcript-relay-bound
Aug 1, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/talk-transcript-relay-bound

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Related: #116201

Builds on the landed durable transcript foundation: #117214

What Problem This Solves

Fixes an issue where Gateway relay Talk sessions could retain an unbounded transcript-persistence backlog when durable transcript RPCs stalled.

Why This Change Was Made

Adopts the shared Talk transcript-operation policy in the relay session owner. Overflow produces one terminal persistence failure, blocks later transcript events, and still drains accepted writes before closing the durable voice session.

Terminal relays leave active lookup immediately but remain in a separate draining-owner registry until durable close settles. Existing global and per-connection relay limits count both active and draining owners, so stalled closes cannot be multiplied through replacement sessions.

Current relay construction-terminal, late-callback, disconnect, and close-error semantics remain intact.

User Impact

Gateway-relayed Talk sessions keep transcript persistence bounded while preserving accepted transcript ordering and existing relay teardown behavior.

Evidence

  • 64 focused tests passed: 58 Gateway relay tests, 5 bounded queue tests, and 1 voice transcript registry test.
  • Stalled persistence, overflow, one-terminal-error precedence, accepted-write drain, disconnect, construction terminal, late callback, and close-error paths are covered.
  • Targeted formatting, scoped oxlint, and git diff --check passed.
  • Signed exact head d6f6bcf2916 is a two-commit relay-owner series on the landed foundation.
  • Independent review found and the branch now fixes two P1 lifecycle gaps: orphaned stalled drains no longer free admission capacity, and normalized-empty provider finals no longer consume or evict persistence slots.
  • Exact-head autoreview is in progress.
  • The relay consumes the same VOICE_TRANSCRIPT_QUEUE_POLICY object as the foundation, avoiding a second queue configuration surface.
  • Fresh combined-tree Blacksmith Testbox proof passed 393 tests across 38 files: 231 shared/Talk/Gateway tests and 162 browser Talk tests.
  • The tested synthetic combined head was 97f953addec4, tree 3653c881992993c135139891af5ece90cf25e5c1; the Testbox run is https://github.com/openclaw/openclaw/actions/runs/30686161632.
  • check:changed reached the existing OPENCLAW_* count ratchet (515 below budget 517); this DAG adds no environment variable or config surface.
  • A dist-backed ephemeral child-Gateway proof passed on the same combined tree 3653c881992993c135139891af5ece90cf25e5c1: relay-owned transcripts persisted, the tool-call path remained accepted, and durable close completed with voiceStatus: closed. Run: https://github.com/openclaw/openclaw/actions/runs/30686177943.
  • Live OpenAI Realtime proof on the fresh combined feature tree passed the backend bridge and browser WebRTC/audio path: exact user transcript, assistant reply glacier, 43,200 output-audio bytes, response.done, and zero late audio after close.
  • Exact-head live OpenAI Realtime proof on d6f6bcf2916 passed with gpt-realtime-2.1: backend bridge connected, exact user transcript, assistant reply glacier, 45,600 output-audio bytes, response.done, zero late audio, and connected browser WebRTC with audio in 49.22 seconds.
  • Merge-tree is clean with the sibling browser adoption branch.

AI-assisted implementation; the maintainer reviewed the conflict resolution and current-main lifecycle invariants.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 1, 2026
@vincentkoc vincentkoc added the P1 High-priority user-facing bug, regression, or broken workflow. label Aug 1, 2026
@vincentkoc vincentkoc self-assigned this Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 2:12 AM ET / 06:12 UTC.

ClawSweeper review

What this changes

The PR bounds Gateway Talk relay transcript persistence, closes an overflowed relay after draining accepted writes, and prevents stalled draining sessions from freeing admission capacity.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

This PR remains necessary: current main still serializes every relay transcript append behind one promise with no bounded pending-work budget, while this branch adopts the already-landed Talk queue policy at the relay owner boundary and keeps draining owners within relay admission limits. No discrete correctness or security defect was found in the reviewed patch; it needs normal maintainer approval because overflow now deliberately emits one terminal persistence error and closes the relay after draining accepted writes. Likely related people: vincentkoc (high confidence, shared-policy and relay adoption work) and steipete (medium confidence, original relay persistence path).

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

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong exact-head live behavior evidence and focused lifecycle coverage support a high-quality bounded repair; remaining approval is about the intentional terminal overflow contract, not a demonstrated patch defect.
Proof confidence 🦀 challenger crab (6/6) Sufficient (live_output): The PR body reports exact-head live OpenAI Realtime evidence with a connected backend bridge and browser WebRTC/audio path, persisted transcripts, completed responses, and zero late audio after close; the supplied checks also include successful real-behavior-proof runs.
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 exact-head live OpenAI Realtime evidence with a connected backend bridge and browser WebRTC/audio path, persisted transcripts, completed responses, and zero late audio after close; the supplied checks also include successful real-behavior-proof runs.
Evidence reviewed 6 items Current-main defect remains: Current main appends each final transcript by extending voiceTranscriptWrites; if an append stalls, later finals remain retained in the unbounded promise chain. The close path waits on that same chain before durable close.
Branch uses the canonical bounded policy: The PR normalizes finals, admits them through VOICE_TRANSCRIPT_QUEUE_POLICY, turns queue overflow into one owner-level persistence failure, seals and flushes the accepted prefix, and retains the owner until durable close settles.
Admission accounting covers draining owners: The PR adds a separate draining-owner registry and counts it alongside active relay sessions, preventing a stalled durable close from creating replacement-session capacity.
Findings None None.
Security None None.

How this fits together

Gateway Talk relays receive provider transcript finals and persist them into durable voice-session records. This change replaces an unbounded promise chain in the relay owner with the shared bounded queue, then carries terminal and draining state through relay teardown and admission checks.

flowchart LR
  A[Realtime provider transcript finals] --> B[Gateway Talk relay]
  B --> C[Shared bounded transcript queue]
  C --> D[Durable voice transcript store]
  C --> E{Overflow or close?}
  E -->|Accepted prefix| D
  E -->|Overflow| F[Terminal relay error and close]
  F --> G[Draining relay registry]
  G --> H[Relay admission limits]
Loading

Decision needed

Question Recommendation
Should Gateway Talk relays terminate after a transcript-persistence queue overflow, rather than continuing with an unbounded in-memory backlog? Approve bounded terminal behavior: Merge the PR and make one terminal persistence error plus accepted-prefix drain the canonical behavior for stalled relay transcript persistence.

Why: The implementation is coherent and proven, but it deliberately defines an operator-visible terminal failure contract for a previously unbounded path; the PR is also maintainer-owned and carries the protected maintainer label.

Before merge

  • Resolve merge risk (P1) - Merging intentionally changes the stalled-persistence failure contract: once the bounded queue overflows, the relay emits one terminal error, rejects later transcript finals, and closes after the accepted prefix drains. This is a session-state safety improvement, but requires owner approval of that operator-visible behavior.
  • Complete next step (P2) - No mechanical repair remains; the protected maintainer-owned PR needs owner approval of its intentional terminal overflow behavior and normal final merge review.
Agent review details

Security

None.

PR surface

Source +62, Tests +259. Total +321 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 91 29 +62
Tests 2 260 1 +259
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 351 30 +321

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #116201
Summary: This PR is a bounded, owner-specific candidate fix for the relay transcript-persistence portion of the broader realtime voice retained-state 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. Approve the bounded terminal contract (recommended)
    Merge after the Gateway/Talk owner confirms that one terminal error followed by drain-and-close is the intended outcome when persistence cannot keep up.
  2. Pause for a different recovery policy
    Do not merge if relays must remain usable after transcript persistence overflow; decide the recovery contract before changing the shared owner behavior.

Technical review

Best possible solution:

Land the relay adoption after a responsible owner confirms that terminal close on transcript-persistence overflow is the intended Gateway Talk contract, preserving the shared policy and draining-owner admission accounting.

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

Yes—source establishes a high-confidence path: stall appendRelayVoiceTranscript and emit additional finalized transcripts; current main extends the same unbounded promise chain, while the added focused tests exercise the bounded equivalent. This review did not execute the reproduction locally because the checkout is read-only.

Is this the best way to solve the issue?

Yes—the PR fixes the leak at the relay session owner by reusing the already-merged canonical queue policy rather than creating a second limit or compensating downstream. Retaining draining owners in admission accounting closes the associated replacement-session loophole.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports exact-head live OpenAI Realtime evidence with a connected backend bridge and browser WebRTC/audio path, persisted transcripts, completed responses, and zero late audio after close; the supplied checks also include successful real-behavior-proof runs.

Label justifications:

  • P1: A stalled durable transcript path can retain unbounded relay-session memory during active realtime voice use.
  • merge-risk: 🚨 session-state: The PR changes relay transcript admission, terminal-event precedence, durable-close timing, and capacity accounting for active and draining sessions.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦀 challenger crab 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 exact-head live OpenAI Realtime evidence with a connected backend bridge and browser WebRTC/audio path, persisted transcripts, completed responses, and zero late audio after close; the supplied checks also include successful real-behavior-proof runs.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports exact-head live OpenAI Realtime evidence with a connected backend bridge and browser WebRTC/audio path, persisted transcripts, completed responses, and zero late audio after close; the supplied checks also include successful real-behavior-proof runs.

Evidence

What I checked:

  • Current-main defect remains: Current main appends each final transcript by extending voiceTranscriptWrites; if an append stalls, later finals remain retained in the unbounded promise chain. The close path waits on that same chain before durable close. (src/gateway/talk-realtime-relay-voice.ts:89, 4caff51ff658)
  • Branch uses the canonical bounded policy: The PR normalizes finals, admits them through VOICE_TRANSCRIPT_QUEUE_POLICY, turns queue overflow into one owner-level persistence failure, seals and flushes the accepted prefix, and retains the owner until durable close settles. (src/gateway/talk-realtime-relay-voice.ts:95, d6f6bcf29166)
  • Admission accounting covers draining owners: The PR adds a separate draining-owner registry and counts it alongside active relay sessions, preventing a stalled durable close from creating replacement-session capacity. (src/gateway/talk-realtime-relay-operations.ts:143, d6f6bcf29166)
  • Focused regression coverage: The branch adds direct stalled-queue, accepted-prefix drain, single-close, normalized pre-bind buffer, and relay-overflow terminal-event coverage. (src/gateway/talk-realtime-relay-voice.test.ts:57, d6f6bcf29166)
  • Shared-policy provenance: The queue policy was introduced by the merged durable-transcript foundation, which supplies the canonical queue semantics this relay adoption reuses. (src/talk/voice-transcript.ts:15, fcb73388379a)
  • Feature-history ownership: Blame attributes the current relay append and close chain to the original relay implementation, while history shows Vincent Koc as the dominant contributor across the queue-policy and relay-adoption files. (src/gateway/talk-realtime-relay-voice.ts:89, 95e50d3a7f14)

Likely related people:

  • vincentkoc: Merged the durable transcript queue foundation and authored the current relay adoption series; history shows the largest contribution footprint in the relevant queue and relay files. (role: shared-policy and recent relay contributor; confidence: high; commits: fcb73388379a, cdf683f00442, d6f6bcf29166; files: src/talk/voice-transcript.ts, src/gateway/talk-realtime-relay-voice.ts, src/gateway/talk-realtime-relay-session-create.ts)
  • steipete: Blame traces the current-main unbounded append and close chain to the original relay implementation commit. (role: original relay-path contributor; confidence: medium; commits: 95e50d3a7f14; files: src/gateway/talk-realtime-relay-voice.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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-01T04:51:47.878Z sha 4d05e91 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T04:59:03.081Z sha e3f8a49 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:20:12.048Z sha e3f8a49 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:27:39.489Z sha b99f1e40f6d0825e620b2bea2978f2d212a1aa96 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:47:53.285Z sha b99f1e40f6d0825e620b2bea2978f2d212a1aa96 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T05:57:50.314Z sha cdf683f :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc force-pushed the fix/talk-transcript-persistence-bound-clean branch from 0546c98 to b786f4a Compare August 1, 2026 05:32
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
Base automatically changed from fix/talk-transcript-persistence-bound-clean to main August 1, 2026 05:49
@vincentkoc
vincentkoc force-pushed the fix/talk-transcript-relay-bound branch from b99f1e4 to cdf683f Compare August 1, 2026 05:52
@vincentkoc
vincentkoc marked this pull request as ready for review August 1, 2026 05:52
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 1, 2026
@vincentkoc
vincentkoc merged commit 4c2d2d3 into main Aug 1, 2026
133 of 136 checks passed
@vincentkoc
vincentkoc deleted the fix/talk-transcript-relay-bound branch August 1, 2026 06:20
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

gateway Gateway runtime 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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