Repository navigation
fix(discord): preserve realtime speaker and playback ownership - #137433
Conversation
Bind provider connections to one Discord principal so delayed transcripts and native consultations cannot inherit another speaker's authority. Keep the shared agent route and serialize response-owned audio on one room player, preserving continuations and recovery after playback gaps. Admit host-requested responses before dispatch and map Google Live turn completion to canonical terminal outcomes so queued speech can finish. Closes #137349 Related: #136982, #123243 Follow-up: #137417
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 1:28 PM ET / 17:28 UTC. ClawSweeper reviewWhat this changesThis PR gives each Discord realtime speaker a separate provider connection, retains shared agent routing and room playback, and completes Google Live responses at their native turn boundary. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep open for maintainer handling: this is a current, non-redundant fix for the linked Discord voice ownership bug. The implementation correctly moves principal binding to the speaker-owned provider connection and preserves one room player, but it adds a public plugin-SDK lifecycle callback that needs an explicit compatibility decision before merge. Priority: P1 Review scores
Verification
How this fits togetherDiscord voice captures speaker audio, sends it through a realtime provider connection, routes accepted transcripts to the OpenClaw agent, and plays replies through one Discord room player. The PR makes the provider connection the owner of a speaker’s identity while the room remains the owner of playback ordering. flowchart LR
Audio[Discord speaker audio] --> Lane[Speaker-owned provider connection]
Lane --> Transcript[Transcript and tool callbacks]
Transcript --> Agent[Shared OpenClaw agent route]
Lane --> Output[Response-owned audio]
Output --> Player[Shared room playback queue]
Player --> Room[Discord voice room]
Decision needed
Why: The callback is added to an exported SDK type, while the visible capacity discussion does not decide that external plugin contract. Before merge
Agent review detailsSecurityNone. PR surfaceSource +543, Tests +1219, Docs +1. Total +1763 across 27 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: Keep the speaker-owned connection and shared-player design, then explicitly accept and document Do we have a high-confidence way to reproduce the issue? Yes, at source level: the new guest/owner ordering test drives distinct provider connections and verifies the delayed transcript reaches agent ingress with its original owner flag. The PR body also records a real-provider/real-player run, but it was not rerun in this read-only review. Is this the best way to solve the issue? Unclear: the per-speaker connection is the cleanest demonstrated fix for missing wire-level source ancestry, but the added exported callback needs a deliberate SDK-contract decision before this can be called the best complete solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 41344e0b7dbd. LabelsLabel 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 (1 earlier review cycle)
|
|
Resolving the capacity/rank-up decision for this requested fix-and-land workflow: retain the documented limit of eight retained speaker-owned provider connections per room. This is a resource bound, not a promise that every provider account permits eight sessions. Provider account limits still apply, and a failed source stays local. The pool reclaims idle connections, while busy admission is recorded rather than transferring one participant's identity to another. The production growth is also accepted for the repaired ownership boundary: most of the old runtime moves unchanged into the speaker owner; the new code owns bounded connection generations, draining, room playback arbitration, and response completion. The old shared context queue and lane-wide stream/reset/watchdog path are removed. Item IDs/FIFO/text matching cannot recover authenticated speaker ancestry across the supported protocols, so a net-neutral timing guard would leave the underlying defect. No new config, dependency, schema, or protocol version is introduced. CI found two transcript-tool integration expectations outside the voice suite that still treated one speaker's provider closure as the whole room ending. The follow-up test update will explicitly prove that the same recording survives source recovery and then finalizes on room leave, preserving all replacement-session and late-callback checks. Production behavior is unchanged by that test update. |
|
Merged via squash.
|
|
The refreshed review's public-SDK premise does not match the package contract. Decision: retain
Source evidence at the merged commit: private entrypoint classification, public/private export generation, package exports, request admission, and harness turn ownership. The review also records that its own environment could not install the Google SDK or list docs. Those are reviewer-environment limitations: the implementation work inspected the installed SDK and native lifecycle contract, ran the docs listing, and completed the recorded live Google interruption/completion proof. The merged voice dependency versions and all 27 changed file blobs match the final reviewed candidate. The refreshed review reports no concrete code or security findings. |
…law#137433) * fix(discord): preserve realtime speaker and playback ownership Bind provider connections to one Discord principal so delayed transcripts and native consultations cannot inherit another speaker's authority. Keep the shared agent route and serialize response-owned audio on one room player, preserving continuations and recovery after playback gaps. Admit host-requested responses before dispatch and map Google Live turn completion to canonical terminal outcomes so queued speech can finish. Closes openclaw#137349 Related: openclaw#136982, openclaw#123243 Follow-up: openclaw#137417 * test(discord): preserve room capture across speaker recovery
* feat(meta): add Muse Spark 1.3 models (#136553) * feat(meta): add Muse Spark 1.3 models * docs(meta): cite Muse Spark 1.3 recommendation Co-authored-by: Tharun Tej Tammineni <[email protected]> --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit 194b7f2) * feat(anthropic): support Fable 5.1 from shared model metadata (#135638) * feat(anthropic): support Fable 5.1 from shared model metadata * test(anthropic): keep alias coverage within the file limit * fix(media): decouple image limits from catalog augmentation (cherry picked from commit 0a9b08c) * feat(openai): support GPT Image 2.5 variants (#143068) * feat(openai): support GPT Image 2.5 variants * docs(openai): correct GPT Image 2.5 section link (cherry picked from commit f93881f) * feat(fal): support GPT Image 2.5 variants (#143069) * feat(fal): support GPT Image 2.5 variants * test(agents): restore Windows media fixture isolation (cherry picked from commit a57c799) * fix(bedrock): preserve images returned by tools (#149336) ## What Problem This Solves Tool-returned images make the next request fail with `ValidationException` on affected Bedrock routes. Fixes #149332. ## Why This Change Was Made The serializer generates image labels from each tool-call ID; input images need no labels. All consecutive tool results come first, followed by image groups in the same tool order. Request state has one writer. `stream.runtime.ts`: +28/−1 for this conversion. Growth accepted under the owner's standing acceptance (2026-09-15). ## User Impact Image-reading turns can finish without losing image bytes, tool associations, or error status. ## Evidence Authenticated `chat.send` → registered `read` on a synthetic PNG: main sent a nested image and failed; candidate sent a sibling image and completed with the scripted “Red square; blue circle.” Our run used a recording HTTP transport. The [contributor's real two-tool run](#149336 (comment)) confirms image interpretation and association. ## Compatibility Concrete route identities select the conversion. Opaque aliases keep their layout. The general schema permits nested images for some routes; this repair addresses the affected route’s observed rejection. No config or public interface changes. ## Consumers All clients use the existing Bedrock serializer. ## Invalidation Conversion is request-local. Stored transcript rows and original image bytes remain unchanged. ## Tests `node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-providers.config.ts extensions/amazon-bedrock`: 289 tests across 12 files passed on a fresh merge with main. Types, lint, formatting, file-size and assertion limits, and unused-export checks passed. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 115522a) * fix: preserve Ultra across model runtime boundaries (#135397) * fix: preserve Ultra across model runtime boundaries Keep native Codex Ultra as a runtime mode instead of clamping it against physical Responses effort tiers. Share the selected collaboration effort between turn fields and remove the redundant forwarding wrapper. Carry the active parent thinking level through existing spawn context so one-shot overrides reach native subagents without changing saved preferences. Keep explicit child overrides and configured child defaults authoritative. Scope Control UI thinking catalog fallback to the selected runtime, sharing one prepared entry for picker options and the inherited default. Document the native orchestration/budget boundary and active-turn inheritance. * refactor: simplify Ultra reasoning fixtures * fix: preserve active thinking across shared tool contexts * docs: clarify Off thinking for side questions (cherry picked from commit ee9e22b) * fix(anthropic): Fable 5.1 sessions lose reasoning after model switches and runtime events (#136782) * fix(anthropic): keep Fable 5.1 thinking valid across model switches and runtime context Claude Fable 5.1 binds each thinking block to the producing model and to the exact request prefix that preceded it. Three harness behaviors conflicted with that contract on Anthropic-family routes: - Moving a session onto Fable 5.1 (from Opus 5, Sonnet 5, Opus 4.8, Fable 5) dropped readable reasoning client-side; the replay contract now preserves it while leaving Fable 5.1 still drops. - The per-turn runtime-context carrier was injected transiently after the active user turn, stripped on the next request, relocated inside tool loops, and removed by the context-engine assembly. It is now persisted right after its user turn and replayed in place; inline inbound metadata stays in place too, and consecutive user turns are no longer merged at load for the Messages API because the merged form lost the second turn's timestamp stamp. - Direct API-key requests with adaptive thinking send the thinking-binding-controls beta with prefix_mismatch_behavior=drop_block, so a residual mismatch degrades to a server-side unbilled drop with a warning listing the dropped paths instead of a 400, a duplicate request, and a transcript-wide thinking wipe. OAuth, proxies, Bedrock, Vertex, and Foundry keep the existing strip-and-retry recovery. Live-verified against api.anthropic.com: nine-request Fable/Opus/Fable session with tool loops and carriers reports input_transformations: [] on every request with four retained thinking blocks; a /think change on the direct API yields a logged server-side drop and no retry. * fix(anthropic): limit the preserved-thinking replay target to Fable 5.1 Mythos 5.1 is not registered in the bundled catalog and has no cross-model replay proof, so unregistered Mythos targets keep the existing drop path. (cherry picked from commit 30837ae) * feat(openai): support GPT-6 Astra (#137550) * feat(openai): support GPT-6 Astra * fix(models): preserve declared pricing tiers during catalog refresh (cherry picked from commit eb72093) * fix(openai): require discovery before offering Astra for OAuth (#137561) (cherry picked from commit 8b1add5) * fix(diagnostics-prometheus): reject unauthorized metric scrapes (#140903) * fix(diagnostics-prometheus): require operator.read for metric scrapes The Prometheus scrape route registers under the trusted-operator runtime scope surface, so the Gateway authenticates the caller and applies its named-role scope ceiling before dispatch. The handler never consulted those scopes, so an authenticated identity whose role grants no operator scopes still received the full diagnostics document with 200, while the same caller was correctly refused on equivalent read operations. Check the runtime request scopes inside the handler and fail closed with 403 "missing scope: operator.read" unless the caller holds operator.read, operator.write, or operator.admin, mirroring the Gateway read implication set. The guard runs before rendering so HEAD probes cannot disclose the document size either. * test(diagnostics-prometheus): prove role-limited scrape denial (cherry picked from commit 0c9330b) * fix(discord): enforce sender media policy on guild asset uploads (#140334) The Discord emoji-upload, sticker-upload, and event-create branches dropped the sender-scoped media access options before dispatching the action, so the guild runtime loaded the requested host-local path with only a byte limit. A sender permitted to run those actions could therefore place bytes from a file outside their allowed media roots into an outbound Discord emoji, sticker, or event-cover request. Forward the resolved action options from all three branches, carry mediaAccess/mediaLocalRoots/mediaReadFile through the guild runtime, and load upload sources through buildOutboundMediaLoadOptions like every other outbound Discord media path. Adds regression coverage that a source outside the sender roots is rejected before any request is issued, with an in-roots control. (cherry picked from commit e5e7764) * fix(discord): preserve realtime speaker and playback ownership (#137433) * fix(discord): preserve realtime speaker and playback ownership Bind provider connections to one Discord principal so delayed transcripts and native consultations cannot inherit another speaker's authority. Keep the shared agent route and serialize response-owned audio on one room player, preserving continuations and recovery after playback gaps. Admit host-requested responses before dispatch and map Google Live turn completion to canonical terminal outcomes so queued speech can finish. Closes #137349 Related: #136982, #123243 Follow-up: #137417 * test(discord): preserve room capture across speaker recovery (cherry picked from commit 85d510c) * fix(doctor): preserve enabled skills during automatic updates (#138730) Use runtime-repair approval for optional skill disabling. Keep standalone explicit repair and required config migrations unchanged. (cherry picked from commit acc9a65) * fix: generated images disappear after failed tool calls (#131226) ## What Problem This Solves WebChat drops generated media when a later tool failure is the turn's only reply payload. ## Root cause The embedded-run terminal projection assigned successful tool media to the first non-reasoning payload. A later error warning could become that owner. Gateway error projection then discarded the attached media. ## Fix - Attach tool media only to a successful, non-reasoning reply. - Emit a separate media-only payload when the turn has no successful reply. - Preserve the newer host-owned and automatic-delivery media paths from current `main`. - Keep regression coverage at the payload owner and physical-delivery boundaries. - Remove the mocked browser test that manually inserted its expected result. ## Evidence - Baseline: current `main` at `8544aed05a5dbffb871483be781f71351203319e`. - Real path: branch-built Control UI → real Gateway → mock OpenAI Responses provider → successful image tool → later failing tool → terminal WebChat event. - Red: current `main` rendered zero generated images. - Green: `d2a10d40c633bfe796ad4ab19222aa831184a327` rendered one generated image. - Anti-cheat: the proof recorded `image-success` before `later-failure` and verified that Chromium loaded the exact Gateway-served asset from the branch build. ## Validation - Focused unit and integration tests: 19 passed across 2 Vitest shards. - Real Gateway and built Control UI proof: passed on current `main` and the candidate head with opposite image assertions. - Targeted format, Oxlint, conflict-marker, max-lines, assertion-safety, and diff checks passed. - Type checks run in continuous integration because repository policy forbids them on this host. Production change: `+3/-3`, net zero. Test change: `+23/-1`, net `+22`. Co-authored-by: A28Hui <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 88be1b8) * fix(matrix): refresh verification status before reporting device trust (#136226) * fix(matrix): refresh verification status before reporting device trust Refresh own-device keys after crypto preparation and before the authoritative trust read. Keep the missing-device preflight and use the Matrix SDK’s existing query contract. * test(slack): remove core-coupled threading duplicate --------- Co-authored-by: Dallin Romney <[email protected]> (cherry picked from commit a812054) * chore(release): prepare extended-stable 2026.8.33 * fix(release): integrate model and Discord security backports * docs(release): clarify extended-stable workflow baseline * fix(release): complete stable-line backport integration * fix(ios): restore dependency resolution with WebRTC 152 (#134942) * fix(release): repair frozen validation inputs * fix(discord): stop error replies after voice consult cancellation (#135380) * fix(discord): stop error replies after voice consult cancellation Treat host-cancelled Discord realtime consults as terminal cancellation, preserve late-call dedupe, and wait for every native delivery before returning forced playback ownership. Timeouts and genuine errors retain their normal handling. Closes #135340. Related phone cancellation helper: #134924. * test(acp): run CLI lifecycle checks against prepared runtime * test(cli): cover selective runtime build admission * test(ci): account for ACP runtime preparation * fix(release): complete Discord cancellation backport * test(release): keep candidate fixtures current * test(update): isolate frozen release version --------- Co-authored-by: tharuntejmeta <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Vincent Koc <[email protected]> Co-authored-by: dclosefuturex <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: Pavan Kumar Gondhi <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: CGlashu <[email protected]> Co-authored-by: A28Hui <[email protected]>
Closes #137349. Related: #123243, #136982.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Fixes an issue where users speaking in a shared Discord voice channel could have a delayed transcript dispatched as another participant, including that participant's owner/tool context. Later audio could also consume the earlier speaker's wake-name follow-up or leave a second final transcript without a reply.
The repaired flow also prevents one speaker's generated audio from replacing another answer on the room player, and prevents interrupted audio from restarting when late provider chunks arrive. Google Live now reports native response completion, so completed or interrupted replies release queued speech.
Why This Change Was Made
A realtime provider connection now belongs to one Discord speaker for its entire lifetime. Transcript and native-tool callbacks inherit that fixed principal; capture timing, text matching, and model-supplied names no longer determine identity. The room retains the existing shared OpenClaw agent route and owns one physical playback queue. Subscription replacements let old spoken replies drain while fencing transcript delivery; authority changes retire old connections; source failures stay local; idle connections are reclaimed.
The shared voice runtime admits explicit text and greeting requests before provider dispatch, allowing even an empty response from a provider without OpenAI-style lifecycle events to finish. Google maps
turnCompleteto the canonical completed/cancelled outcome;generationCompletealone does not finish a turn. Accepted interruptions discard remaining audio until the provider's terminal event. Each output owns its own PCM stream, room-player request, drain callback, and watchdog, so a later native continuation cannot inherit an ended stream. Normal player starvation allows the same response to resume; actual encoder failure fences its remaining audio. Reconnect uses each exact-speech request's recorded playback fact to avoid replaying speech already heard.Alternatives considered: keeping a current-speaker/FIFO queue cannot distinguish delayed, missing, or multiple finals. OpenAI/xAI transcript item IDs do not establish which input principal owns a native tool call, and the inspected OSS Codex frameless contract exposes transcript text/delegation IDs without Discord-source ancestry. A separate connection per principal provides the common ownership boundary without inventing provider wire fields or switching to batch STT/TTS.
User Impact
Realtime voice remains enabled and agent-backed room conversation history remains shared. Direct
bidimodel history is scoped to each speaker's realtime connection; agent consults provide shared room history. Multiple speakers use more provider connections. The room retains at most eight connections and reports busy admission rather than transferring identity; provider account limits still apply. Existing voice configuration is preserved, with no new configuration keys, dependencies, database changes, or protocol version changes. The bounded connection policy and production growth were reviewed and retained in the capacity/rank-up decision.Release-note context: Discord realtime voice preserves speaker identity across delayed transcripts and tool calls, serializes room playback, fences interrupted audio, and recovers failed speaker connections. Google Live correctly completes normal and interrupted replies, including empty host-requested responses.
Evidence
907f6956ee5eae23d8a44fe224fd8bcd5faefefd: the guest/owner reproduction dispatches a delayed guest question withsenderIsOwner: true; the repaired manager retainsu-guest/false. Nine of ten new speaker lifecycle tests fail against the baseline; the roster-refresh preservation case passes both.toReversed()and preserve fully idle speakers when another speaker stops the room. The final 28-case real-player suite covers both the active and pending control branches. Discord transport and agent replies are synthetic; this is not a live Discord socket/microphone-room claim.turnComplete, but no canonical completion. Repaired live run produced 417,156 PCM bytes with outcomescompleted, completed, cancelled, completed, including audio interruption and a subsequent reply; zero provider errors.The lead personally inspected OSS Codex
728cb12fe5794b0c3a8e776fb4994b1650b973a8, particularlycodex-rs/codex-api/src/endpoint/realtime_websocket/protocol_frameless_bidi.rs:20,48,58,73,protocol_v2.rs, andprotocol.rs. Provider contract evidence also includes Google Live's native server-content lifecycle.Production LOC: +1,426/-883 (net +543), tests/support +1,691/-472 (net +1,219), docs +3/-2. The old room runtime moves into the speaker owner; most of that module is unchanged. Growth adds the per-principal connection/drain lifecycle, a single room playback owner, and generic request/terminal ownership. Redundant audio-admission state, retained roster copies, and the lane-wide shared stream/reset/watchdog path were removed. The response-owned playback refactor and idle-source control guard add 30 production lines. A net-neutral timing-queue patch cannot establish the missing source identity or arbitrate concurrent provider output. Discord no longer uses the old context tracker; its existing private runtime export is unchanged. This is not a typed public SDK compatibility promise: both stable
v2026.8.2and the merged package classifyrealtime-voiceas private and exclude its declarations.Remaining protocol limit: Google Live and the inspected Codex frameless protocol do not expose a response-start event before any automatic output. This repair tracks actual native starts where provided and host-requested speech; it does not invent starts from input transcripts or promise cancellation of an entirely unobserved automatic response. Retiring such a provider connection would be a separate lifecycle design.
Provenance: the affected shared-input/context-pruning path is reachable in stable
v2026.8.2; the introducing commit has not been established. #123243 repaired a later await-order race, while this repair addresses source attribution before transcript delivery.Named follow-up: #137417 records the pre-existing mismatch between the newest generated native audio item and the item currently audible. Baseline synthetic GA bridge proof rejects interruption using a short queued item; fixing heard-duration/truncation identity requires a separate provider/transport metadata contract. This PR does not override the provider's intentional echo-duration guard.
Validation commands:
node scripts/run-vitest.mjs extensions/discord/src/voice extensions/google/realtime-voice-provider.test.ts extensions/google/realtime-voice-transcript-finality.test.ts extensions/google/realtime-voice-meeting.test.ts src/talk/agent-talkback-runtime.test.ts src/talk/session-runtime.test.ts src/talk/realtime-session-harness.test.ts;node scripts/check-changed.mjs;pnpm build. Independent Codex autoreview: full candidate, P0–P2, scoped-clean after repairing the accepted playback findings; fresh test-only follow-up review also scoped-clean through P2 at565c8533bced0a6fbef8e87f90534739513282a4.Build note:
pnpm buildexited successfully while emitting a UI startup gzip budget advisory (350,147 bytes versus the 350,141-byte enforcement limit). This change contains no UI source edits.Private runtime contract:
onResponseRequestsynchronously admits supported host text/greeting requests before provider dispatch; it is skipped for blank text, unsupported methods, and inactive sessions. The session rechecks admission after the callback. The harness establishes turn ownership first, so synchronous empty responses can finish. This hook does not represent automatic provider response starts or tool-result continuations, and does not promote the existing private realtime runtime subpath into the typed public SDK.