Skip to content

refactor(openai): split realtime voice by layer - #122414

Merged
steipete merged 4 commits into
mainfrom
steipete/realtime-voice-split-0811
Aug 12, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/realtime-voice-split-0811

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The OpenAI realtime voice provider and its main unit suite had grown into two oversized files that mixed authentication, session policy, outbound response state, inbound event projection, transport lifecycle, browser routing, and test fixtures. That made ownership and safe maintenance difficult, especially around response/tool state and reconnect ordering.

Why This Change Was Made

This follows the landed xAI realtime layering: session policy, protocol, events, bridge, and provider facade. buildOpenAIRealtimeVoiceProvider remains the sole public export at the unchanged path, the api.ts re-export and private capability symbol remain intact, and Quicksilver keeps its type-only peer-runtime edge plus dynamic load in the gateway bridge.

The second commit removes only the four approved dead paths: the redundant configured-profile result branch, duplicated GPT-Live browser auth selection, the browser cancel pass-through helper, and the impossible response.done type check. GA/Azure/browser payload distinctions, legacy audio/transcript aliases, and Azure deployment behavior remain unchanged.

User Impact

No user-visible behavior change is intended. Maintainers get smaller owner-focused modules and suites, while existing OpenAI realtime, Azure, browser, GPT-Live, tool, response-control, and reconnect behavior remains covered.

Evidence

Remote proof was attempted first. The local Testbox executable was unavailable and managed Crabbox broker authentication was unavailable, so trusted-source proof fell back to serialized local execution as required.

  • pnpm test:extension openai: 51 files passed, 839 tests passed.
  • Focused post-split matrix: 10 files passed, 150 tests passed.
  • pnpm lint:tmp:export-name-collisions: passed.
  • pnpm check:wrapper-shadowing: passed, 0 current and 0 baselined.
  • pnpm plugin-sdk:surface:check: passed; all 152 public SDK subpaths verified.
  • pnpm check:import-cycles: passed, 0 runtime value cycles.
  • pnpm build: passed in 6m38s, including CLI bootstrap, plugin SDK export, runtime postbuild, and Control UI checks.
  • OpenAI changed-surface lazy-boundary check: 6 files checked, 0 advisories; realtime-quicksilver-peer.runtime.ts remains dynamically loaded only by the gateway bridge.
  • node scripts/check-changed.mjs: local fallback after remote unavailability; all selected checks passed except the repository-wide plugin-boundary report, which reports one pre-existing compatibility record already due for removal.
  • Exact requested pnpm lint:tmp:dynamic-import-warts -- --fail: reports 113 repository-wide pre-existing advisories and exits 1; none is in the five split OpenAI modules or the Quicksilver gateway bridge.
  • Max-lines ratchet: passed with both obsolete OpenAI entries removed.
  • Structured Codex autoreview was run before each commit/fixup; final component reviews reported no accepted/actionable findings.

LOC classification from git diff --numstat origin/main...HEAD:

  • Production: +2,193 / -2,074, net +119. The remaining growth is the explicit module import and protected-hook ownership boundary needed to separate transport lifecycle from protocol/event state.
  • Tests and test support: +5,167 / -4,259, net +908.
  • Tooling: +0 / -2.

Test LOC grew net +908 from splitting the 4,259-line suite into per-owner files with suite-local hoisted mocks, the proposal's explicit anti-leak choice for Vitest's non-isolated runner. Consolidating more pure fixtures without sharing hoisted state is a possible follow-up.

@clawsweeper

clawsweeper Bot commented Aug 12, 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 12, 2026 03:40
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@steipete
steipete force-pushed the steipete/realtime-voice-split-0811 branch from 8989bd3 to 1ecd93b Compare August 12, 2026 04:50
@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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 12:56 AM ET / 04:56 UTC.

ClawSweeper review

What this changes

The PR splits OpenAI realtime voice session policy, protocol state, event handling, WebSocket transport, and tests into focused modules while retaining the existing provider export.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review. Current main still has the monolithic realtime voice provider, while this branch preserves the public factory and internal hook contract; no blocking source defect was found in the refactor pass.

Priority: P2
Reviewed head: 1ecd93bf07c9a9ae42adc60a257b7d137f7880fa

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source pass found a coherent owner-boundary refactor with no blocking defect; exact-head CI remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-preserving refactor is exempt from the external-contributor real-behavior-proof gate; its PR body supplies focused local validation claims.
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, behavior-preserving refactor is exempt from the external-contributor real-behavior-proof gate; its PR body supplies focused local validation claims.
Evidence reviewed 7 items Current-main comparison: Current main still contains the monolithic provider implementation, so the refactor is not already implemented or superseded.
Preserved provider boundary: The PR keeps buildOpenAIRealtimeVoiceProvider as the provider factory and retains the internal realtime-provider symbol used by core browser and gateway control paths.
Runtime entry point: The OpenAI plugin continues to register the same provider factory with the broker and logger supplied by the plugin lifecycle.
Findings None None.
Security None None.

How this fits together

The bundled OpenAI plugin turns browser or gateway voice requests into managed realtime WebSocket sessions, then reports audio, transcripts, response state, and tool events back to OpenClaw. This refactor separates those responsibilities inside the plugin without changing the provider registration path.

flowchart LR
A[Browser or gateway request] --> B[OpenAI voice provider]
B --> C[Session policy and routing]
C --> D[Realtime WebSocket bridge]
D --> E[Protocol and event state]
E --> F[Audio, transcript, and tool callbacks]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as mergeable but behind current main, and exact-head checks are still running; validate the final merge result before landing.
  • Complete next step (P2) - No mechanical repair is identified; this maintainer-owned refactor should remain in normal review until exact-head checks complete.
Agent review details

Security

None.

PR surface

Source +437, Tests +590, Other -2. Total +1025 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 6 2511 2074 +437
Tests 8 4849 4259 +590
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 2 -2
Total 15 7360 6335 +1025

Review metrics

Metric Value Why it matters
Production versus test delta production +119; tests and test support +908; tooling -2 The small production increase is tied to explicit module boundaries, while the larger test increase comes from splitting the existing suite and shared test support.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single provider factory and private core hook, then land only after exact-head CI confirms the split preserves native, Azure, browser, GPT-Live, tool, and reconnect behavior.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single provider factory and private core hook, then land only after exact-head CI confirms the split preserves native, Azure, browser, GPT-Live, tool, and reconnect behavior.

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

Not applicable: this is a behavior-preserving refactor rather than a report of a user-facing defect; the relevant check is preservation of the existing voice-session paths.

Is this the best way to solve the issue?

Yes: separating policy, protocol, events, and transport follows the existing xAI realtime pattern while preserving the public provider factory and core-private hook.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, behavior-preserving refactor is exempt from the external-contributor real-behavior-proof gate; its PR body supplies focused local validation claims.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bundled-provider refactor with bounded runtime impact and no demonstrated urgent regression.
  • 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, behavior-preserving refactor is exempt from the external-contributor real-behavior-proof gate; its PR body supplies focused local validation claims.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the recent sideband-control and tool-result ownership work as well as this refactor. (role: feature owner and recent area contributor; confidence: high; commits: 7dcb4fb76032, bb019e4a53ca; files: extensions/openai/realtime-voice-provider.ts, extensions/openai/realtime-voice-bridge.ts, extensions/openai/index.ts)
  • Vincent Koc: History shows multiple focused fixes for reconnect, lifecycle reset, and socket startup behavior in this provider. (role: recent lifecycle contributor; confidence: high; commits: 4f8a9c830127, 3ba1f31c55ec, ebf335f1a6d1; files: extensions/openai/realtime-voice-provider.ts, extensions/openai/realtime-voice-bridge.ts)

Rank-up moves

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

  • Confirm green exact-head checks and the clean GitHub merge result before landing.

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 merged commit dac940b into main Aug 12, 2026
115 checks passed
@steipete
steipete deleted the steipete/realtime-voice-split-0811 branch August 12, 2026 05:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
* refactor(openai): split realtime voice by layer

* refactor(openai): delete dead realtime auth branches

* chore(lint): ratchet max-lines baseline after realtime-voice split

* style(openai): prune split leftovers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openai 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: XL 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