Repository navigation
fix(discord): prevent voice playback gaps and stale turn controls - #146798
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 7:03 AM ET / 11:03 UTC (Revision 10). ClawSweeper reviewWhat this changesImproves Discord voice buffering, streaming audio conversion, interruption handling, and speaker-bound run controls, with regression coverage and Gateway/UI test-fixture repairs. Merge readiness✅ Ready for maintainer review The repairs remain useful against inspected main. The earlier realtime and batch cancellation findings are resolved at the pinned head, and no remaining blocking introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherDiscord voice converts microphone packets into realtime or transcribed agent requests and sends synthesized replies through one shared room player. Speaker admission and run ownership constrain which requests may control agents or start playback. flowchart LR
A[Discord microphone packets] --> B[Decode and resample]
B --> C[Realtime or batch transcript]
C --> D[Current speaker admission]
D --> E[Agent request or guarded control]
E --> F[Reply audio]
F --> G[Buffered shared room player]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +345, Tests +1171, Docs +5. Total +1521 across 42 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep audio buffering with the shared room player and enforce cancellation and current speaker authority through the existing ingress and guarded-run owners. Do we have a high-confidence way to reproduce the issue? Yes, source and the supplied before/after probes identify concrete startup, delivery-gap, and cancellation paths. This read-only review did not execute tests or reproduce them locally. Is this the best way to solve the issue? Yes. The patch repairs the existing playback and admission owners, reuses the streaming resampler and guarded-input contract, and preserves ordinary-error fallback without reviving cancelled requests. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e45c014cbe00. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
Maintainer scope: voice steering uses the existing guarded-input contract. The V1 API and its deprecation window remain unchanged; ordinary unscoped queueing, status, and cancellation are preserved. The claimed loss of working no-overlay managed-room steering did not reproduce. On the exact previous control module, these calls already set
Both proof cells passed. The queue owner, fingerprint admission, Copilot implementation, and SDK compatibility documentation were unchanged in this comparison. The follow-up adds this coverage to the existing Copilot boundary test and documents the Discord limitation. The CI lint and transcript-fixture failures are also fixed in d488a4b92a84d36415a24330d44e6554585a07b3; updated CI is running. |
d488a4b to
155112a
Compare
7d2e4ac to
0bf4513
Compare
0bf4513 to
17921c2
Compare
|
Resolved the admission-fallback finding in the current patch ( The regressions run final transcripts through the production consult/talkback, receive, and ingress owners to Updated CI is pending. The previous CodeQL jobs completed analysis but failed at results upload; the two Discord CI test-timing failures are fixed and their full 53-case file passes. The PR body retains the synthetic-audio and unperformed real-room limitations. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Fixed the batch cancellation finding in aac74a0. Cancellation is terminal in both transcript paths. Batch handling rechecks session/policy after control preparation and before synthesis, and shared ingress rejects stopped or recording-only sessions before dispatch. The same batch/ingress fixtures produce nine intended failures on the previous production code and pass all 20 cases after repair. Through microphone capture, STT, the production response/ingress owners, and the final agent-dispatch spy, the tests verify zero rejected-control effects, fallback requests, new agent dispatches, or TTS starts after shutdown, revocation, or cancellation. Allowed controls, ordinary-error fallback, and new requests remain operational. An admitted agent may finish after leave, but cannot start speech synthesis. Existing recording, audio release, and queued-playback shutdown ownership is preserved. All 50 focused batch, ingress, control, and realtime-admission cases pass. The final mechanical mock-reference lint correction also passed all 15 segment cases. Extension production/test typechecks, scoped lint, formatting, diff checks, and independent P2 review passed. The updated PR body retains the scheduler/codec/RTP evidence and the explicit absence of live Discord-room/physical-speaker proof. Required CI is running on this exact head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
* temp/pr-146799: (70 commits) test: reuse explicit fallback config fixtures (openclaw#146948) fix(computer): return fresh window observations after actions (openclaw#146822) refactor(feishu): remove unreachable requester topic selection (openclaw#146904) improve(gateway): reduce CPU spent listing agent-owned sessions (openclaw#137745) fix(ui): avoid recapturing chat drafts during UI updates (openclaw#146884) fix(ui): show system uptime in the debug overlay (openclaw#146960) fix(retry): honor waits beyond the native timer limit (openclaw#145718) fix(ui): keep chat history idle when run status changes (openclaw#146802) fix(ui): reuse persisted text during chat streaming (openclaw#146831) refactor(qa): share harness drift result construction (openclaw#146903) test(agents): coordinate settings lock contention (openclaw#146949) fix(worker): avoid repeatedly serializing screenshot history (openclaw#146907) fix(secrets): stop buffered upload writes after cancellation (openclaw#146840) perf(doctor): avoid unnecessary state runtime imports (openclaw#146926) improve: reduce compaction request estimation work (openclaw#146961) fix(ci): wait for forwarded avatar imports before assertions (openclaw#146729) perf(workers): skip configured Git author lookups (openclaw#146833) fix: admit borrowed memory writes through the agent database owner (openclaw#146760) fix(discord): prevent voice playback gaps and stale turn controls (openclaw#146798) improve: reduce worktree filesystem stalls and archive syncs (openclaw#146906) ...
* commit 'ccfd2377cd07d1ad3a583ba64d08e29a065f7061': (1587 commits) fix(ui): avoid recapturing chat drafts during UI updates (#146884) fix(ui): show system uptime in the debug overlay (#146960) fix(retry): honor waits beyond the native timer limit (#145718) fix(ui): keep chat history idle when run status changes (#146802) fix(ui): reuse persisted text during chat streaming (#146831) refactor(qa): share harness drift result construction (#146903) test(agents): coordinate settings lock contention (#146949) fix(worker): avoid repeatedly serializing screenshot history (#146907) fix(secrets): stop buffered upload writes after cancellation (#146840) perf(doctor): avoid unnecessary state runtime imports (#146926) improve: reduce compaction request estimation work (#146961) fix(ci): wait for forwarded avatar imports before assertions (#146729) perf(workers): skip configured Git author lookups (#146833) fix: admit borrowed memory writes through the agent database owner (#146760) fix(discord): prevent voice playback gaps and stale turn controls (#146798) improve: reduce worktree filesystem stalls and archive syncs (#146906) fix(ui): avoid extra chat rail work while replies stream (#146883) improve(ui): speed up populated Usage timelines (#146947) test(gateway): retain auth recovery failure diagnostics (#146925) fix(tests): create private temporary home directories (#146931) ... # Conflicts: # test/tsconfig/tsconfig.core.test.agents-other.json # test/tsconfig/tsconfig.core.test.agents-root.json
…enclaw#146798) * fix(discord): smooth voice playback and preserve turn ownership * test(discord): verify legacy control compatibility and satisfy CI * refactor(discord): use a duplex Opus stream * fix(discord): keep revoked voice requests cancelled through dispatch * test(ui): close named file tab in root identity proof * test(discord): wait for agent dispatch before resetting voice * test(gateway): keep CLI auth fixtures isolated through cancellation * fix(discord): keep cancelled batch voice turns from dispatching
What Problem This Solves
Fixes broken-up Discord voice replies when continuous audio arrives unevenly, silent input spuriously interrupts playback, or a provider reconnect leaves buffered microphone audio behind.
User Impact
Discord voice absorbs brief delivery gaps, plays short continuous replies without waiting for response completion, and accepts valid Opus packets longer than 20 ms. Existing voice modes and the shared room playback queue remain available. Continuous playback adds up to 120 ms of initial buffering.
Why This Change Was Made
Keep resampling state with each audio stream and bound Opus encoding work between event-loop turns. Only audible current microphone input can request local interruption, and a declined interruption remains eligible to retry. Reconnects discard old filter state while allowing fresh input from the same speaker capture.
Voice run controls refresh speaker admission, honor disabled delegation, and retain the exact selected run across asynchronous work. Rejected admission or cancellation ends that transcript instead of starting a fallback request in both realtime and batch modes. Batch turns recheck session and policy validity after control preparation and before speech synthesis; the shared ingress owner rejects stopped and recording-only sessions before dispatch. Native delegation and delayed forced-consult/talkback requests refresh admission after roster preparation, with the originating provider session checked after the lookup. Authorized room-wide cancellation still works when voice targets an existing text conversation; steering retains the run's tool-authority checks. Guarded steering remains unavailable on V1-only backends such as Copilot; ordinary V1 queueing, status, cancellation, and new requests remain available. The existing SDK contract and deprecation window are unchanged.
Related codec repair: libopus-wasm #18 fixes a WebAssembly stack overflow without changing libopus 1.6.1. That fix is merged upstream; consuming its binary requires a separate package release and dependency update. This PR currently retains the published codec pins.
Evidence
Full Discord CI exercised 3,861 cases: 3,859 passed and two existing tests reset the provider before agent dispatch. The tests now wait for that observable dispatch; their complete 53-case file passes, with stale-delivery assertions unchanged. All 53 core run-control and registered-authority tests passed. Regressions were first demonstrated on the old implementation, including 10 ms startup deadlock, FIFO overtaking, retained microphone samples after reconnect, and stale control effects. Independent review is clean through P2. A controlled comparison using the real Copilot V1 active-run handle passed on both the previous and repaired control modules: ordinary queueing, status, and cancellation work; no-overlay voice steering rejects before I/O in both. Its rejection reason changes from
tool_authority_mismatchtoguarded_injection_unsupported.The admission follow-up exercises final transcripts through the production consult/talkback, receive, and ingress owners to
runCommandFromIngress, using synthetic Discord member responses. With identical final fixtures, the previous production code fails seven of 13 admission cases; an additional comparison reproduces both role-removal cases while roster lookups wait. The repaired code passes all 62 admission/participant/control/consult/transcript cases, including all 15 admission cases. Together with 26 playback cases, the capture timing case, and 53 continuity cases, 142 selected cases pass. Coverage includes role removal after scheduling or during roster lookup, role restoration after a denied utterance, provider reset during admission, native calls with and without an abort signal, and preserved ordinary-error fallback. Final independent review is clean through P2.The final batch follow-up exercises microphone capture and STT through the production response and ingress owners to the agent-dispatch boundary. The same fixtures fail nine cases on the previous production code and pass all 20 batch/ingress cases after repair; 50 batch, ingress, control, and realtime-admission sibling cases pass together. Shutdown, policy revocation, and independent cancellation cause zero rejected-control effects, fallback requests, new agent dispatches, or TTS starts. Allowed controls, new requests, and ordinary-error fallback still work. An already-running agent may finish after leave, but its reply cannot begin speech synthesis. Recording and existing audio-release/playback-stop ownership remain unchanged. The final patch passed independent review through P2.
Repeated wall-clock playback with the real scheduler and codec produced the following results; each repaired playback scenario ran twice and consumed all 100 source frames with no errors.
The runtime build, 32 runtime E2E cases, core and plugin production/test type checks, and changed-file gates passed. The final Duplex encoder also passes 79 audio/playback tests, four suppression-policy tests, typed lint, and repeated wall-clock probes. Required CI passed for final head
aac74a069f2aae76aec7d7b183a0fcc809d12914. The exact-head CI watcher reports green; superseded historical check runs are excluded. ClawSweeper revision 9 reviewed this same head and reports no remaining actionable findings.CI initially exposed inherited sidebar-helper and test-graph capacity failures; main fixed both in #146803, so this PR drops its redundant recovery commits. The earlier missing-loader CI fixture failure was fixed on main in #146702. A subsequently merged file-link test still looked for the retired Review close button; this PR corrects that selector to close the named file tab. All seven file-link E2E scenarios pass without changing path, content, line, or request assertions.
The remaining Gateway CLI-account CI failure exposed a test-lifetime issue: a timed-out case could restore the host environment while the next case was acquiring its fake CLI. The fixture now uses a test-owned executable path, checks cancellation before startup and new turns, and joins cleanup through Vitest. All six cases pass with fresh test caches and the unchanged 90-second limit; native continuity took 88.4 seconds. A controlled cancellation regression fails when the startup guard is removed. Production Gateway and provider code are unchanged.
The playback proof uses the real Discord audio scheduler and Opus codec with synthetic PCM. It does not send audio to a live Discord room or prove physical speaker output.