Repository navigation
fix(discord): OAuth GPT-Live voice can't select the Gateway-relay bridge, and misses auto-join on a disconnected startup - #138441
Conversation
…Y auto-join The OpenAI provider only selects the OAuth GPT-Live Gateway-relay bridge when a participant-aware runAgentConsult callback and the gateway-relay surface are both present on the bridge-creation request. Discord's realtime speaker session built the request without either, so Discord voice could never select that bridge path. - Wire DiscordRealtimeConsults.runAgentConsult (new) into the bridge request built by DiscordRealtimeSpeakerSession, alongside the gateway-relay surface. The new consult runner resolves Discord speaker identity through the existing forced-consult coordinator, dedupes concurrent identical prompts, and fails closed on abort, on a stale provider epoch (reconnect/continuity reset), or on missing speaker context. - Plumb the optional runAgentConsult field through RealtimeVoiceBridgeSessionParams in src/talk/session-runtime.ts so it reaches the provider's bridge-creation request. Separately: runDiscordGatewayLifecycle only reconciled voice auto-join when Discord's gateway was already READY at lifecycle start. When startup began disconnected, READY arriving during waitForGatewayReady was never followed by a reconciliation call, so an occupied configured voice channel could be missed on a cold, disconnected startup. Added the matching post-READY reconciliation on the other side of the wait. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UMZAfYFwUJfM8wYnseU4ew
|
🦞👀 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. |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. The OAuth relay work is superseded by a merged, shipped implementation. The claimed remaining startup gap bypasses existing READY and guild-snapshot listeners in its reproduction, so it does not establish a distinct fix worth retaining. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Retain the shipped relay implementation and event-owned auto-join flow; investigate any distinct current-release startup failure through actual READY and guild-snapshot dispatch. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Retain the shipped relay implementation and event-owned auto-join flow; investigate any distinct current-release startup failure through actual READY and guild-snapshot dispatch. Do we have a high-confidence way to reproduce the issue? No current-main reproduction is established: OAuth relay wiring has shipped, and the startup test bypasses the READY and guild-snapshot listeners that perform reconciliation. No tests were executed during this read-only review. Is this the best way to solve the issue? No. The merged relay implementation covers the useful change with stronger lifecycle handling; adding another startup reconciliation duplicates the existing event-owned path without demonstrating its failure. Security review: Security review needs attention: The superseded callback does not propagate cancellation to agent execution; no dependency or supply-chain changes were introduced.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning medium; reviewed against 094f165494ce. |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Thanks @almostjulian for identifying these voice startup paths. I checked both claims independently on current main (
Validation: 49 tests passed across Security: no changes to credential eligibility, participant authorization/cancellation, or configured guild/channel targets and allowlists. Closing as superseded; the useful relay work is already implemented, with no distinct remaining startup fix established. Thank you for the contribution. |
What Problem This Solves
Resolves two problems in Discord realtime voice startup:
the OAuth GPT-Live Gateway-relay bridge. The OpenAI provider only selects that bridge
when the bridge-creation request declares the
gateway-relaysurface and supplies aparticipant-aware agent-consult callback; Discord's realtime speaker session supplied
neither, so it silently fell back to a different path even when the Gateway-relay
route was the intended one for a Gateway-owned client like Discord.
runDiscordGatewayLifecycleis still waiting for it (rather than before lifecyclesetup began), voice auto-join into an already-occupied configured channel is never
reconciled. The existing reconciliation only fires on the
gatewayReadyAtLifecycleStartbranch, so a channel occupied at the moment READY lands mid-wait can be missed for the
rest of that session.
Why This Change Was Made
DiscordRealtimeConsults.runAgentConsult, the Gateway-relay entry point theOpenAI provider calls directly instead of routing through Discord's native realtime
tool-call protocol. It resolves Discord speaker identity through the existing
forced-consult coordinator, dedupes concurrent identical prompts to one agent turn,
and fails closed on abort, on a stale provider epoch (reconnect/continuity reset), or
on missing speaker context. Wired it, plus the
gateway-relaysurface, into thebridge-creation request built by
DiscordRealtimeSpeakerSession, and plumbed the newoptional
runAgentConsultfield throughRealtimeVoiceBridgeSessionParamsinsrc/talk/session-runtime.tsso it reaches the provider.gatewayReadyAtLifecycleStartbranch: when startup began disconnected, reconcile onceafter
waitForGatewayReadyresolves instead of only before it. The two branches aremutually exclusive (
gatewayReadyAtLifecycleStarttrue vs. false), so this cannotdouble-fire against the existing call.
No config surface, schema, or public API changed.
User Impact
bridge with correct Discord participant identity attached to each consult, instead of
silently running a different bridge path.
disconnected gateway startup, not only when Discord happened to already be connected
before lifecycle setup began.
Evidence
Local proof (fresh clone off current
main,pnpm install, no unrelated changes):pnpm tsgo:coreandpnpm tsgo:extensions: clean, no errors.pnpm test extensions/discord/src/monitor/provider.lifecycle.test.ts extensions/discord/src/voice/realtime-turns.test.ts extensions/discord/src/voice/realtime-consults.test.ts src/talk/session-runtime.test.ts:118/118 passing (5 new tests: the post-READY auto-join reconciliation test, a test
asserting the provider is asked for the
gateway-relaysurface and exposesrunAgentConsult, a duplicate-consult dedup test, and two parametrized fail-closedtests for abort / continuity-reset).
git stashof only the four production files, tests kept, all 5 fail; restored, all 118 pass
again) before opening this PR.
node_modules/.bin/oxfmton the touched files: no changes needed.node_modules/.bin/oxlinton the touched files: clean.I don't currently have a way to live-test the OAuth GPT-Live Gateway-relay path itself
(needs a configured Discord bot + ChatGPT/Codex OAuth voice session), so this PR relies
on the unit/integration proof above plus review of the existing, already-tested
Gateway-relay provider-selection logic this change plugs into
(
resolveConfiguredRealtimeVoiceProvider, exercised byextensions/openai/realtime-voice-provider-routing.test.ts, unchanged here). Happy todo a live pass if a maintainer can point me at a suitable test setup.