Skip to content

fix(discord): preserve routed agent for realtime voice - #125111

Merged
steipete merged 1 commit into
mainfrom
steipete/elated-thompson-d62ab6
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/elated-thompson-d62ab6

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where Discord realtime voice autoJoin on multi-agent gateways routed to the correct agent but dropped agentId before provider readiness and bridge authentication, causing AGENT_SELECTION_REQUIRED and no joined session.

Why This Change Was Made

Carries the host-selected owner through the existing generic realtime provider configured context and bridge session request, then propagates it through Discord, OpenAI/xAI agent-scoped credential lookup, Google Meet, voice-call, and the gateway relay sibling. There is explicitly no global or default-agent fallback.

User Impact

autoJoin and adjacent realtime voice surfaces now use the routed agent's credential store and reach bridge ready/joined instead of silently failing.

Evidence

  • Regression failed before the fix with AGENT_SELECTION_REQUIRED: expected routed agent molty and zero bridge creation; it passes after the fix.
  • Focused tests: 235 tests passed across Discord, Talk, OpenAI, xAI, Google Meet, and voice-call; the xAI rerun passed 73 tests; extension-test typecheck passed.
  • Full changed-surface gate passed on direct AWS Crabbox: https://crabbox.openclaw.ai/portal/runs/run_13970917770a (provider AWS; lease stopped).
  • Final autoreview clean, with no accepted/actionable findings.
  • Production LOC: +60/-10 (net +50). Tests: +252/-6 (net +246). The growth is the additive ownership contract and sibling/provider propagation.
  • Live gap: no operator gateway was deployed or restarted, and no post-fix live Discord channel proof was performed.
  • No CHANGELOG.md edit, per repository policy.

AI-assisted: yes.

@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 17, 2026 06:27
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: voice-call Channel integration: voice-call gateway Gateway runtime extensions: openai plugin: google-meet extensions: xai size: M maintainer Maintainer-authored PR labels Aug 17, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 17, 2026, 2:35 AM ET / 06:35 UTC.

ClawSweeper review

What this changes

This PR propagates the selected agent through realtime voice provider readiness, bridge creation, and OpenAI/xAI credential lookup across Discord and sibling voice surfaces.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open: the shared Discord fix is sound, but two agent-scoped paths remain incomplete and can still reject valid routed credentials.

Priority: P1
Reviewed head: e805790cb18042042686522acb48733f035797fb

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has useful focused regressions but needs the two remaining routed-agent paths corrected before it is merge-ready.
Proof confidence 🌊 off-meta tidepool Not applicable: The contributor proof gate does not apply to this member-authored PR; its stated lack of a deployed Discord voice run remains useful validation context but is not the merge gate here.
Patch quality 🦐 gold shrimp (3/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor proof gate does not apply to this member-authored PR; its stated lack of a deployed Discord voice run remains useful validation context but is not the merge gate here.
Evidence reviewed 7 items Current-main defect: Discord already uses the routed agent for session policy, but current main omits it when resolving the provider and creating the bridge.
Shared owner boundary: Current main accepts agentId at the resolver boundary but does not pass it to provider readiness; the bridge runtime likewise omits it from createBridge.
PR repair path: The proposed branch supplies agentId at the Discord resolver and bridge calls, and adds the corresponding generic context fields.
Findings 2 actionable findings [P1] Resolve voice providers after routing each call
[P2] Carry agent scope into browser capability checks
Security None None.

How this fits together

Realtime voice starts with a channel or call route that selects an agent, then resolves a provider and opens its audio bridge. Provider plugins use that agent scope to locate credentials before a voice session can join.

flowchart LR
  A[Voice route] --> B[Selected agent]
  B --> C[Provider readiness]
  C --> D[Realtime bridge]
  D --> E[Agent-scoped credentials]
  E --> F[Voice session]
Loading

Before merge

  • Resolve voice providers after routing each call (P1) - Per-number routes can select a different agent, but this startup-time resolution uses only the default config.agentId; the handler receives the routed agent later and only forwards it to bridge creation. A route whose agent alone has usable OpenAI/xAI credentials can therefore fail startup or retain a provider selected for the default agent. Resolve readiness after the call route is known and add a per-number credential-routing regression.
  • Carry agent scope into browser capability checks (P2) - The changed browser-session auth path now resolves Platform credentials for req.agentId, but Talk capability evaluation does not carry that agent and OpenAI's gateway-control check remains unscoped. An agent-only Platform profile can therefore pass provider resolution yet be rejected as lacking gateway-control. Thread the selected agent through the capability context and cover this route.
  • Resolve merge risk (P1) - A voice-call deployment whose default agent lacks credentials but whose routed number agent has them can fail during plugin startup or select the wrong provider before the call route is known.
  • Resolve merge risk (P1) - A selected agent can satisfy browser-session authentication yet be rejected for gateway-control because capability detection remains unscoped.
  • Resolve merge risk (P1) - The optional agentId addition is an exported realtime-provider SDK contract; existing plugins must retain the unchanged unscoped behavior when a host has no route-owned agent.

Findings

  • [P1] Resolve voice providers after routing each call — extensions/voice-call/src/runtime.ts:237-242
  • [P2] Carry agent scope into browser capability checks — extensions/openai/realtime-voice-provider.ts:187-191
Agent review details

Security

None.

PR surface

Source +50, Tests +246. Total +296 across 26 files.

View PR surface stats
Area Files Added Removed Net
Source 18 60 10 +50
Tests 8 252 6 +246
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 26 312 16 +296

Review metrics

Metric Value Why it matters
Production versus regression coverage production +60/-10; tests +252/-6 The shared provider-context expansion is substantial for a bug fix and should land only after the remaining routed-agent consumers use the same canonical path.

Stored data model

Persistent data-model change detected: serialized state: src/talk/session-runtime.test.ts, serialized state: src/talk/session-runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete route-wide agent propagation (recommended)
    Move voice-call provider selection to the resolved call route and pass the requested agent through browser capability checks, with regression coverage for both agent-scoped credential paths.

Technical review

Best possible solution:

Resolve provider readiness at the effective per-call route, carry the same agent scope into browser capability evaluation, and retain one optional shared provider-context field for all realtime hosts.

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

Yes, source-reproducible: a multi-agent Discord route reaches provider readiness and bridge creation without its route agent on current main, and the same startup-versus-route mismatch is visible for voice-call number routes.

Is this the best way to solve the issue?

No: the shared fix is the right owner boundary, but it must also resolve voice-call providers after route selection and use agent-scoped browser capability checks.

Full review comments:

  • [P1] Resolve voice providers after routing each call — extensions/voice-call/src/runtime.ts:237-242
    Per-number routes can select a different agent, but this startup-time resolution uses only the default config.agentId; the handler receives the routed agent later and only forwards it to bridge creation. A route whose agent alone has usable OpenAI/xAI credentials can therefore fail startup or retain a provider selected for the default agent. Resolve readiness after the call route is known and add a per-number credential-routing regression.
    Confidence: 0.98
  • [P2] Carry agent scope into browser capability checks — extensions/openai/realtime-voice-provider.ts:187-191
    The changed browser-session auth path now resolves Platform credentials for req.agentId, but Talk capability evaluation does not carry that agent and OpenAI's gateway-control check remains unscoped. An agent-only Platform profile can therefore pass provider resolution yet be rejected as lacking gateway-control. Thread the selected agent through the capability context and cover this route.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: Multi-agent realtime voice can currently fail a configured channel or call workflow when the routed agent owns the only usable credentials.
  • add merge-risk: 🚨 compatibility: The optional agentId field changes the exported realtime provider configured-context contract used by plugins.
  • add merge-risk: 🚨 auth-provider: The patch changes OpenAI and xAI realtime readiness and credential lookup from a default scope to a routed agent scope.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The contributor proof gate does not apply to this member-authored PR; its stated lack of a deployed Discord voice run remains useful validation context but is not the merge gate here.

Label justifications:

  • P1: Multi-agent realtime voice can currently fail a configured channel or call workflow when the routed agent owns the only usable credentials.
  • merge-risk: 🚨 auth-provider: The patch changes OpenAI and xAI realtime readiness and credential lookup from a default scope to a routed agent scope.
  • merge-risk: 🚨 compatibility: The optional agentId field changes the exported realtime provider configured-context contract used by plugins.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The contributor proof gate does not apply to this member-authored PR; its stated lack of a deployed Discord voice run remains useful validation context but is not the merge gate here.

Evidence

What I checked:

Likely related people:

  • steipete: Recent main refactors cover the Discord and shared Talk realtime ownership path. (role: recent realtime owner and current PR author; confidence: high; commits: df4e6666c6ba, 90beb639e7e8, e805790cb180; files: extensions/discord/src/voice/realtime-session.runtime.ts, src/talk/provider-resolver.ts, src/talk/session-runtime.ts)
  • vincentkoc: History shows sustained work on gateway relay, xAI, and voice-call lifecycle ownership. (role: recent adjacent realtime lifecycle contributor; confidence: medium; commits: e41c574793c4, e35d22807e5f; files: src/gateway/talk-realtime-relay-session-create.ts, extensions/xai/realtime-voice-auth.runtime.ts, extensions/voice-call/src/webhook/realtime-handler.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve provider readiness from the effective voice-call route and add a route-specific credential regression.
  • Pass requestedAgentId through browser capability evaluation and test agent-scoped gateway-control availability.

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 commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head e805790cb18042042686522acb48733f035797fb.

Root cause: Discord realtime autoJoin resolved the routed agent, then dropped that host-selected owner before generic provider readiness and bridge creation. The canonical boundary is now explicit: the host passes agentId through RealtimeVoiceProviderConfiguredContext and the bridge request, while each provider continues to own agent-scoped credential resolution. The same contract is propagated through Talk, OpenAI, xAI, Google Meet, voice-call, and the gateway relay sibling.

Before the fix, the regression failed with AGENT_SELECTION_REQUIRED: expected routed agent molty and created zero bridges. After the fix, the selected owner reaches provider readiness and bridge auth; the Discord regression reaches bridge connect and joined status.

Focused proof:

Provenance is clear: #122479 / 90beb63 introduced/carried forward the ownerless resolver and bridge calls on 2026-08-12; code author, PR author, and merger were @steipete, with no bot automerge trigger.

Production LOC: +60/-10 (net +50). Tests: +252/-6 (net +246). The production growth is the additive host-selected owner contract plus provider/sibling propagation.

Known proof gap: no operator gateway was deployed or restarted, and there is no post-fix live Discord proof.

Best-fix verdict: this is the owner-boundary repair. A global/default-agent fallback would select the wrong credential owner, a Discord-only guard would leave sibling realtime surfaces inconsistent, and inferring ownership from the session key would reconstruct an authoritative fact downstream instead of carrying it from the host selection boundary.

ClawSweeper exact-head review handling:

  • Voice-call per-number provider re-resolution: skipped for this landing. Moving provider selection from plugin startup into the per-call route is a separate lifecycle behavior change without a failing regression in this evidence set, and product/test changes were outside this landing-only authorization. This PR preserves selection timing and carries the already selected owner into bridge/auth.
  • Browser capability/gateway-control agent scoping: skipped for this landing. Expanding capability evaluation is a separate public capability-contract change without failing proof here; this repair is bounded to provider readiness, bridge creation, and provider-owned auth for the reported Discord path.
  • The optional agentId context preserves existing unscoped plugin behavior when a host does not provide a route-owned agent.
  • The two optional rank-up moves mirror the two deferred changes above and are skipped for the same scope and proof reasons.

@steipete
steipete merged commit 73ab74e into main Aug 17, 2026
282 of 285 checks passed
@steipete
steipete deleted the steipete/elated-thompson-d62ab6 branch August 17, 2026 06:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: voice-call Channel integration: voice-call extensions: openai extensions: xai gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. plugin: google-meet rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant