Skip to content

feat(talk): enable GPT Live with Codex OAuth - #113354

Merged
Solvely-Colin merged 44 commits into
mainfrom
s/gpt-live-oauth-voice
Jul 26, 2026
Merged

Solvely-Colin merged 44 commits into
mainfrom
s/gpt-live-oauth-voice

Conversation

@Solvely-Colin

@Solvely-Colin Solvely-Colin commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #113353

What Problem This Solves

This PR enables GPT Live (gpt-realtime-2.1) in browser and iOS Talk for users already signed in with Codex OAuth.

Browser Talk currently requires an OpenAI Platform API key even when Codex already has a working subscription login and native realtime session support. The OAuth credential cannot be exposed to the browser or sent to the public Platform Realtime endpoint.

Why This Change Was Made

OpenAI realtime authentication is now selected automatically in this order:

  1. talk.realtime.providers.openai.apiKey
  2. an openai API-key auth profile
  3. OPENAI_API_KEY
  4. only when no Platform credential is authored, the active Codex OAuth session

There is no auth-mode setting, new environment variable, provider alias, or UI selector. If neither Platform auth nor Codex OAuth is available, Talk remains unavailable. An authored Platform credential remains authoritative if it is invalid, so OAuth does not hide configuration errors.

The OAuth fallback is internal to the bundled Codex and OpenAI plugins; it adds no public Plugin SDK broker/registry surface, and the public realtime provider types are unchanged from main. The browser receives only a bounded, single-use WebRTC exchange token. The Codex plugin starts an ephemeral read-only V3 realtime thread with the Talk instructions and bounded recent session context, then stops and unsubscribes it on completion, failure, disconnect, or shutdown.

Platform auth remains first and keeps the full Realtime feature set, including direct tools and Video Talk. The Codex OAuth fallback is browser/iOS WebRTC-only and advertises only what the Codex realtime contract supports.

Cross-origin Control UI deployments use the existing gateway.controlUi.allowedOrigins policy for the SDP preflight. This PR adds no config surface.

User Impact

Users with an existing Codex subscription login can open Talk and speak with GPT Live without adding an OpenAI API key or choosing an auth mode. The session starts with recent OpenClaw conversation context and persists completed user and assistant transcript turns back to the active session.

Users with an OpenAI Platform key keep the current Platform-first behavior and features.

Evidence

OAuth-only live proof

Live-tested commit ec59b607831347910b577014308ed3555d15b226. Current head 4b464fd443cb804be0655949a9669390dbce20ef merges current main 81b7a0a00657a6b6cfbc808cfa914a53c75659cb; the incoming main commits have no file overlap with the PR, and the exact-head build and managed Gateway install are green.

  • Removed OPENAI_API_KEY from the proof process.
  • Used an isolated config with no realtime API key, no auth-profile rows, and no legacy auth-profile file.
  • talk.catalog reported OpenAI ready through Codex OAuth with WebRTC browser-session support and no unsupported direct tools or video frames.
  • A real Chromium RTCPeerConnection sent generated microphone audio through /plugins/codex/realtime/calls.
  • The SDP exchange returned HTTP 200 application/sdp; remote description, data channel, and one remote audio track all completed.
  • Observed session.started, input_transcript.added, turn.created, turn.delta, output_transcript.added, and turn.done.
  • Spoken input and the assistant reply were both transcribed and persisted into OpenClaw session history.
  • Reusing the one-time token returned 401; an expired token also returned 401.
  • Capacity was restored after disconnect and expiry, and talk.client.close succeeded.

Checks

  • 186 focused tests passed across Talk resolver/client/gateway, browser WebRTC, Codex runtime/session, and the OpenAI provider.
  • The configured-origin preflight tests cover allowed, rejected, case-normalized, private-network, and successful POST response behavior.
  • Targeted Oxlint passed for the final Codex route and tests.
  • Full build passed, including all 142 public Plugin SDK declaration subpaths and Control UI performance gates.
  • Testbox run 30176595449 passed extension lint, extension production/test type checks, Plugin SDK surface validation, and the full build on the preceding cleanup head.
  • Fresh full-branch Autoreview found the cross-origin preflight gap; the fix was verified and the final fix review returned no findings, rating the patch correct.
  • git diff --check passed.
  • Exact head 4b464fd443cb804be0655949a9669390dbce20ef builds successfully, verifies all 142 public Plugin SDK subpaths, passes Control UI performance gates, and is installed as the managed Gateway LaunchAgent with healthy RPC on OpenClaw 2026.7.2.

Direct Codex contract check

Checked sibling Codex source at 000d2540ad73996f3589ae178bfe447bfd67cef2:

  • codex-rs/app-server-protocol/src/protocol/common.rs:848-876 declares thread/realtime/start and thread/realtime/stop.
  • codex-rs/app-server-protocol/src/protocol/v2/realtime.rs:95-148 defines model/output/startup context, V3 initial items, and browser-generated WebRTC SDP transport.
  • codex-rs/app-server/src/request_processors/turn_processor.rs:1029-1112 validates and maps realtime start.
  • codex-rs/app-server/src/bespoke_event_handling.rs:399-480 emits started, SDP, and transcript notifications.
  • codex-rs/app-server/src/request_processors/turn_processor.rs:1195-1211 and bespoke_event_handling.rs:548-555 implement stop and closed notification behavior.

Related: #87273

AI-assisted implementation: Codex.

Copilot AI review requested due to automatic review settings July 24, 2026 15:17
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime extensions: openai extensions: codex size: XL maintainer Maintainer-authored PR labels Jul 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eb5606102

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an explicit, experimental talk.realtime.providers.openai.authMode: "codex-oauth" route so browser/iOS WebRTC Talk can use the Gateway’s existing Codex OAuth subscription (via the bundled Codex plugin) instead of requiring an OpenAI Platform API key, while keeping the default API-key flow intact.

Changes:

  • Adds a plugin-SDK “browser session broker” registry and wires the OpenAI realtime voice provider to delegate codex-oauth browser sessions to a registered broker.
  • Implements the Codex plugin broker + HTTP route to perform a one-time WebRTC SDP exchange via the Codex app-server and start an ephemeral read-only v3 thread seeded with bounded context.
  • Updates Talk/Gateway/UI to pass bounded recent transcript items into session creation and refactors UI WebRTC support helpers.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ui/src/pages/chat/realtime-talk-webrtc.ts Refactors WebRTC Talk transport, delegates SDP exchange, adds new server event handling, and improves autoplay/playback retry logic.
ui/src/pages/chat/realtime-talk-webrtc-support.ts New helper module for SDP offer exchange and shared WebRTC utilities/constants.
src/talk/provider-types.ts Extends browser session create request for broker-based flows (agent/workspace + initialItems) and adds broker type.
src/talk/client-voice-session.ts Returns the created sessionId from ensureClientVoiceAgentSessionEntry for downstream use.
src/talk/client-voice-session.test.ts Updates tests to assert returned sessionId is stored.
src/talk/browser-session-broker-registry.ts Adds a process-scoped registry for provider/authMode browser-session brokers.
src/talk/browser-session-broker-registry.test.ts Adds coverage for normalization + stale cleanup behavior in the broker registry.
src/plugin-sdk/realtime-voice.ts Exposes broker APIs/types via the plugin SDK.
src/gateway/server-methods/talk.test.ts Adds coverage for bounded initialItems selection and verifies broker inputs include agent/workspace/context items.
src/gateway/server-methods/talk-client.ts Plumbs agent session id + workspace dir + bounded transcript preview into browser session creation.
src/config/schema.labels.ts Adds label for talk.realtime.providers.*.authMode.
src/config/schema.help.core.ts Documents the new authMode config field.
extensions/openai/realtime-voice-provider.ts Adds explicit codex-oauth delegation to a registered broker; disables external CLI auth for Platform-key resolution.
extensions/openai/realtime-voice-provider.test.ts Adds tests for codex-oauth broker delegation and updates provider-auth expectations.
extensions/codex/src/realtime-browser-session.ts Implements the Codex OAuth realtime browser-session broker + one-time reservation and SDP handler.
extensions/codex/src/realtime-browser-session.test.ts Adds tests for reservations, disconnect cleanup, handler behavior, and request shape.
extensions/codex/openclaw.plugin.json Adds config path trigger for talk.realtime.providers.openai.authMode.
extensions/codex/index.ts Registers the broker and HTTP route when the plugin is in full registration mode; adds lifecycle cleanup on disable.
docs/web/control-ui.md Updates Control UI docs to describe the explicit Codex OAuth WebRTC Talk route.
docs/providers/openai.md Updates OpenAI provider docs to mention experimental Codex OAuth for browser WebRTC Talk.
docs/nodes/talk.md Documents configuration for selecting authMode: "codex-oauth" and its limitations.
Comments suppressed due to low confidence (1)

extensions/codex/src/realtime-browser-session.ts:232

  • This check uses reservations.size (which includes active sessions) but the error message says "pending". If the intent is to cap total concurrent Codex realtime sessions, the message should reflect that and the constant name should align (see rename above).
      prunePendingOffers();
      if (reservations.size >= CODEX_REALTIME_MAX_PENDING) {
        throw new Error("Too many pending Codex OAuth realtime sessions; try again in a minute");
      }

Comment thread src/config/schema.help.core.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added the app: ios App: ios label Jul 24, 2026
@blacksmith-sh

This comment has been minimized.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Jul 25, 2026
@Solvely-Colin

Copy link
Copy Markdown
Contributor Author

Addressed the architecture concern from the current ClawSweeper review and refreshed the branch onto current main.

What changed:

  • Removed the public Plugin SDK realtime broker registrar/types/registry.
  • Kept auth automatic and Platform-first: explicit realtime key → OpenAI API-key profile → OPENAI_API_KEY → Codex OAuth only when no Platform credential is authored.
  • Added no auth-mode config, environment variable, provider alias, or UI selector.
  • Kept the Codex fallback internal to the bundled Codex/OpenAI integration with a versioned process-owned lease.
  • Made gateway-relay provider resolution explicitly use the bridge surface.
  • Added configured-origin CORS handling for the internal SDP route. It reuses gateway.controlUi.allowedOrigins; no new config surface.

Exact head: ec59b607831347910b577014308ed3555d15b226
Included main: bfc8c89c3540f95a9b3dc2ac4f252f83c817903d

Fresh proof:

  • OAuth-only isolated state: no OPENAI_API_KEY, no realtime API key, zero auth-profile rows, and no legacy auth-profile file.
  • Real Chromium WebRTC: SDP 200 application/sdp, remote description applied, data channel opened, and one remote audio track received.
  • Observed session.started, input_transcript.added, turn.created, turn.delta, output_transcript.added, and turn.done.
  • Assistant transcript received; user and assistant transcript entries persisted; close succeeded.
  • One-time token replay 401; expired token 401; capacity restored after disconnect and expiry.
  • Configured cross-origin preflight returned 204 with the expected origin/method/header/private-network policy; an untrusted origin returned 403.
  • The first media attempt reached session.started but synthetic-audio transcription timed out; the immediate repeat completed end-to-end on the same SHA.
  • 186 focused tests passed across core Talk, gateway, UI, Codex, and OpenAI provider shards.
  • Targeted Oxlint, git diff --check, and the full build passed. The build verified all 142 public Plugin SDK subpaths and Control UI performance gates.
  • Final Autoreview returned no findings and rated the fix correct.
  • The exact-head build is installed on the managed Gateway LaunchAgent and RPC is healthy.

Direct Codex contract check used sibling Codex 000d2540ad73996f3589ae178bfe447bfd67cef2:

  • codex-rs/app-server-protocol/src/protocol/common.rs:848-876
  • codex-rs/app-server-protocol/src/protocol/v2/realtime.rs:95-148
  • codex-rs/app-server/src/request_processors/turn_processor.rs:1029-1112,1195-1211
  • codex-rs/app-server/src/bespoke_event_handling.rs:399-480,548-555

Current exact-head CI is running: https://github.com/openclaw/openclaw/actions/runs/30178371315

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 25, 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.

@Solvely-Colin

Copy link
Copy Markdown
Contributor Author

Final-head refresh is pushed at 330808cc13f36f20d75d1b2d6a3a1b883857b132, containing current main ddd3d4fdb32135808e601474a8b90a41bb087926.

  • The two incoming main commits have zero file overlap with this PR.
  • Exact-head pnpm build passed, including all 142 public Plugin SDK subpaths and the Control UI performance gates.
  • The exact-head build is installed as the managed Gateway LaunchAgent; port 18789 is listening and RPC is healthy on OpenClaw 2026.7.2.
  • The OAuth-only audio/WebRTC behavior proof was captured at ec59b607831347910b577014308ed3555d15b226; the final merge changes no PR-touched file, so that behavior surface is unchanged.
  • Fresh exact-head CI: https://github.com/openclaw/openclaw/actions/runs/30178693980

The public Plugin SDK broker/registrar called out in the prior review is gone; the fallback is now an internal bundled Codex/OpenAI seam. There is still no auth-mode config, env var, or UI selector.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 25, 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:

@Solvely-Colin

Solvely-Colin commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Final cleanup is pushed at 4b464fd443cb804be0655949a9669390dbce20ef, containing current main 81b7a0a00657a6b6cfbc808cfa914a53c75659cb.

This resolves the remaining SDK concern:

  • The public realtime provider types are now identical to main; there is no public broker, registrar, dynamic capability hook, cancellation hook, surface field, agent context field, or native-agent capability added by this PR.
  • Codex OAuth browser readiness, native handoff capability, bounded startup context, and cancellation use one versioned process-private bundled-provider seam.
  • Auth stays automatic: Platform/API-key input wins; when none is authored, ready Codex OAuth can serve browser/iOS WebRTC; when neither exists, Talk is unavailable. No auth-mode config, env var, or UI selector was added.

Exact-head proof:

  • pnpm tsgo:test passed after tightening the internal test fixture types.
  • pnpm deadcode:full passed after removing the final test-only exports, and fresh local Autoreview returned zero findings.
  • 146 focused tests passed across Talk resolver/gateway, OpenAI, and Codex realtime.
  • pnpm build passed on the current merged head, including all 142 public Plugin SDK subpaths and Control UI performance gates.
  • Full branch Autoreview against main returned zero findings and rated the patch correct.
  • The exact build is installed as the managed Gateway LaunchAgent. It reported HTTP listening in 8.8s, reached ready, and the WebSocket RPC connectivity probe is healthy.
  • Fresh CI: https://github.com/openclaw/openclaw/actions/runs/30180149181

@clawsweeper re-review

Final CI update: exact-head run 30180149181 passed on attempt 2 with 69 successful jobs, 5 expected skips, and zero failures. Attempt 1\u0027s only failure was an untouched macOS Swift retain-cycle test; the targeted rerun passed, including OpenClawKit tests and the full Swift test step.

@clawsweeper

clawsweeper Bot commented Jul 25, 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.

@clawsweeper

clawsweeper Bot commented Jul 26, 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:

@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: 🦐 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 Jul 26, 2026
@Solvely-Colin
Solvely-Colin merged commit de9ed64 into main Jul 26, 2026
218 of 227 checks passed
@Solvely-Colin
Solvely-Colin deleted the s/gpt-live-oauth-voice branch July 26, 2026 00:41
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: web-ui App: web-ui docs Improvements or additions to documentation extensions: codex extensions: openai 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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

[Feature]: Use Codex OAuth for browser realtime Talk

2 participants