Skip to content

fix(voice): wait for auth before starting realtime timeout - #119131

Merged
vincentkoc merged 4 commits into
mainfrom
fix/xai-oauth-realtime-connect-timeout-20260804
Aug 4, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/xai-oauth-realtime-connect-timeout-20260804

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Related: #116201

What Problem This Solves

Fixes an issue where xAI realtime voice users authenticating through OAuth could receive a connection timeout while credentials were still being refreshed, even though the resolved bearer and realtime endpoint were valid.

Why This Change Was Made

The shared connection attempt now acquires cancellation ownership immediately but starts its socket deadline explicitly after provider authentication and connection parameters are ready. The xAI and OpenAI realtime adapters use that boundary; the existing 10-second socket timeout and all terminal behavior remain unchanged.

User Impact

OAuth-backed realtime voice connections no longer fail solely because credential preparation takes longer than the socket handshake budget. Direct API-key connections, cancellation, close, retry, and terminal outcomes keep their existing behavior.

Evidence

  • Before: OAuth bearer resolution succeeded, the xAI models endpoint returned HTTP 200, and a raw realtime WebSocket opened, while the provider bridge still ended with xAI realtime voice connection timeout.
  • After: OAuth-only live talkback on grok-voice-latest returned 260,120 audio bytes, the expected final transcript marker, and response.done; double-close was idempotent, with zero late audio and zero errors.
  • Focused lifecycle tests: 9/9 passed.
  • Focused OpenAI provider tests: 120/120 passed.
  • Focused xAI provider and terminal-outcome tests: 74/74 passed.
  • Structured P0 autoreview: no accepted or actionable findings.
  • Blacksmith Testbox changed-surface validation: passed on signed head dc8bcf97d09b6f4dde45e83c9c40ba28a42d38e8.
  • GitHub exact-head CI: 78 checks passed, including openclaw/ci-gate, on final reviewed head a7cf1ba9fc74dad4924886051a7667db8388b3c5; zero failures or pending checks.
  • ClawSweeper exact-head review: no actionable patch findings; it identified this as the canonical shared-lifecycle fix and recommended merge after exact-head checks.

AI-assisted: yes.

@vincentkoc vincentkoc self-assigned this Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 3:35 AM ET / 07:35 UTC.

ClawSweeper review

What this changes

The PR starts the realtime WebSocket readiness timeout only after OpenAI or xAI authentication has produced connection parameters, while retaining the existing socket timeout afterward.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer merge review: this is a clean shared-lifecycle fix for the OAuth-versus-socket timeout race, with no actionable patch finding. The current head still needs its in-progress required checks to finish.

Priority: P2
Reviewed head: a7cf1ba9fc74dad4924886051a7667db8388b3c5
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-backed lifecycle repair with relevant regressions and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records an after-fix OAuth live talkback and focused validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records an after-fix OAuth live talkback and focused validation.
Evidence reviewed 6 items Current-main behavior: Current main arms the connection timeout when the shared connect attempt is created, before asynchronous provider credential resolution begins; this is the reported race.
Shared owner-boundary repair: The PR head makes timeout arming explicit and idempotent, preserving cleanup and abort ownership while allowing callers to start the socket deadline at the correct boundary.
Both production consumers migrated: The OpenAI and xAI native voice bridges each start the deadline after their settled/current/abort gate and immediately before WebSocket construction; no other production caller uses this lifecycle attempt.
Findings None None.
Security None None.

How this fits together

Realtime voice adapters first resolve provider credentials and a WebSocket endpoint, then use the shared session lifecycle to govern cancellation, socket startup, readiness, retry, and terminal outcomes. This change separates the credential-refresh deadline from the socket-readiness deadline.

flowchart LR
A[Voice connection request] --> B[Provider credential resolution]
B --> C[Connection parameters]
C --> D[Start socket deadline]
D --> E[WebSocket handshake]
E --> F[Session ready or terminal outcome]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned realtime voice fix merge once the current head's required checks complete? Merge after exact-head checks: Accept the shared lifecycle repair once the in-progress required checks finish successfully.

Why: The author is a repository member and the PR carries the protected maintainer label, so this workflow must leave the final merge decision to a human despite a clean technical review.

Before merge

  • Resolve merge risk (P1) - The required GitHub check set is still in progress on the current head, so merge validation is not complete.
Agent review details

Security

None.

PR surface

Source +16, Tests +60. Total +76 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 27 11 +16
Tests 2 61 1 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 88 12 +76

Review metrics

Metric Value Why it matters
Production versus test delta production +27/-11; tests +61/-1 The production growth establishes one generic timeout-ownership boundary across both adapters, with focused lifecycle and xAI regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared explicit socket-timeout boundary, retain OAuth refresh's separate bounded lifecycle, and merge after maintainer approval and exact-head checks succeed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the shared explicit socket-timeout boundary, retain OAuth refresh's separate bounded lifecycle, and merge after maintainer approval and exact-head checks succeed.

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

Yes: current main starts the 10-second attempt timer before asynchronous OAuth resolution, while the xAI resolver can wait for bounded OAuth refresh; the PR's focused delayed-credential test models that ordering.

Is this the best way to solve the issue?

Yes: placing timeout arming in the shared lifecycle and invoking it at both adapter socket boundaries is the canonical fix; it avoids provider-specific timeout workarounds while preserving cancellation and post-auth socket limits.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded OAuth realtime-voice connection failure with limited provider-specific blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nevertheless records an after-fix OAuth live talkback and focused validation.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Introduced the xAI realtime lifecycle ownership work and has substantial merged history across the lifecycle and both affected provider paths. (role: recent realtime lifecycle and xAI contributor; confidence: high; commits: b4ec765e00cc, 3bf40870ad92; files: src/talk/realtime-session-lifecycle.ts, extensions/xai/realtime-voice-bridge.ts, extensions/openai/realtime-voice-provider.ts)
  • steipete: Feature history shows extensive work on the OpenAI realtime voice provider, including recent ownership and event-boundary repairs. (role: long-running OpenAI realtime contributor; confidence: high; commits: daee265f32de, dc60a9442d5c; files: extensions/openai/realtime-voice-provider.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 (2 earlier review cycles)
  • reviewed 2026-08-04T06:28:33.983Z sha d21c6be :: needs maintainer review before merge. :: none
  • reviewed 2026-08-04T06:43:52.994Z sha dc8bcf9 :: needs maintainer review before merge. :: none

* origin/main:
  test(qa): prove shared-channel memory recall (#119111)
@vincentkoc
vincentkoc marked this pull request as ready for review August 4, 2026 07:22
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The rank-up move is complete: current main was merged into the branch with signed merge commit dc8bcf97d09b6f4dde45e83c9c40ba28a42d38e8, and exact-final-head focused tests, structured autoreview, and Blacksmith changed-surface validation all pass.

@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

* origin/main:
  fix(test): isolate shared state between test files (#118781)
  fix(telegram): use monotonic polling liveness
  fix(setup): keep compatible Claude wrappers selectable
  fix(agents): gate Claude live session protocol
  fix(agents): preserve Claude fork successor on stalls
  fix(agents): preserve Claude follow-up replies after background tasks
  fix: unblock macOS release validation (#119110)
  improve(qa): cover vision channel offload (#118862)
  test(qa): cover sandboxed exec behavior (#119053)
  fix(ai): preserve Google simple completion sanitation
  fix(macos): keep setup activation within app checks
  fix(tts): use prepared completion transport
  fix(ai): prefer provider-owned completion streams
  test(setup): type provider kind fixture
  fix(setup): complete prepared model activation
  fix(protocol): regenerate Swift wizard models
  fix(ollama): activate the model selected during setup
  fix(setup): preserve the prepared model handoff
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 4, 2026
@vincentkoc
vincentkoc merged commit 9faf34d into main Aug 4, 2026
142 of 145 checks passed
@vincentkoc
vincentkoc deleted the fix/xai-oauth-realtime-connect-timeout-20260804 branch August 4, 2026 08:08
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged without squash via signed two-parent commit.

  • Prepared head: a7cf1ba9fc74dad4924886051a7667db8388b3c5
  • Landed commit: 9faf34d3bcb6aed4b69faa24c329b03691178692
  • Live proof: OAuth-only xAI talkback returned 260,120 audio bytes, the expected transcript marker, and response.done; double-close was idempotent with zero late audio and zero errors.
  • Focused tests: 203 passed.
  • Exact-head PR CI: 77 passed, zero failed or pending.
  • ClawSweeper exact-head review: no actionable patch findings.
  • Exact merge CI: passed on 9faf34d3bcb6aed4b69faa24c329b03691178692 (https://github.com/openclaw/openclaw/actions/runs/30890734341).

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openai extensions: xai maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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