Skip to content

fix(talk): diagnose invalid OpenAI realtime auth#87273

Open
BSG2000 wants to merge 2 commits into
openclaw:mainfrom
BSG2000:fix/talk-openai-realtime-auth-diagnostic-pr
Open

fix(talk): diagnose invalid OpenAI realtime auth#87273
BSG2000 wants to merge 2 commits into
openclaw:mainfrom
BSG2000:fix/talk-openai-realtime-auth-diagnostic-pr

Conversation

@BSG2000

@BSG2000 BSG2000 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

What problem does this PR solve?

  • Talk configured for OpenAI Realtime could surface a raw provider error such as Incorrect API key provided when the available credential was an Azure AI Foundry / Azure OpenAI model key or OpenAI-compatible proxy key rather than a direct OpenAI Platform credential.

Why does this matter now?

  • OpenAI Realtime Talk auth is separate from the regular model-provider stack. Users with Azure-backed model configs need a clear diagnostic instead of a misleading low-level OpenAI API-key failure.

What is the intended outcome?

  • OpenAI Realtime Talk fails early with an actionable message that explains direct OpenAI Realtime auth, openai-codex OAuth, or Azure gateway relay configuration.
  • Obvious Azure/proxy-style keys are not sent to the OpenAI Realtime client-secret endpoint.
  • Upstream invalid-key responses and pre-ready WebSocket auth failures are translated into the same safe diagnostic without leaking the configured secret.

What is intentionally out of scope?

  • This does not add a new Azure Foundry browser WebRTC flow.
  • This does not change Google Gemini Live or other Talk providers.
  • This does not edit CHANGELOG.md.

What does success look like?

  • A user with only Azure AI Foundry / Azure OpenAI model credentials no longer sees only a raw Incorrect API key provided error when enabling OpenAI Realtime Talk.

What should reviewers focus on?

  • The auth-resolution behavior in extensions/openai/realtime-voice-provider.ts, especially preserving valid direct OpenAI Realtime setups and openai-codex OAuth fallback.
  • The diagnostics avoid leaking key material.

AI-assisted: yes. I used GitHub Copilot CLI to implement and validate this fix, and I understand the resulting code changes.

Linked context

Which issue does this close?

  • N/A; no public issue exists for this local reproduction.

Which issues, PRs, or discussions are related?

  • N/A.

Was this requested by a maintainer or owner?

  • No maintainer request; this is a focused bug fix from a real local Talk/OpenAI Realtime configuration issue.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: OpenAI Realtime Talk with Azure AI Foundry / Azure OpenAI or OpenAI-compatible proxy credentials could expose a raw provider invalid-key error instead of explaining that direct OpenAI Realtime auth is required.
  • Real environment tested: Local OpenClaw checkout on Ubuntu 24.04 under WSL, using the same local OpenClaw config directory as my running setup. The setup is Azure-backed for regular model providers and has no valid direct OpenAI Platform Realtime key.
  • Exact steps or command run after this patch:
    • OPENAI_API_KEY=<redacted proxy key> node --import tsx -e "import { buildOpenAIRealtimeVoiceProvider } from './extensions/openai/realtime-voice-provider.ts'; const provider = buildOpenAIRealtimeVoiceProvider(); try { await provider.createBrowserSession?.({ providerConfig: {}, instructions: 'diagnostic smoke test' }); console.log('unexpected success'); process.exitCode = 1; } catch (error) { const message = error instanceof Error ? error.message : String(error); console.log(message.replace(/REDACTED_KEY_PATTERN/g, '<redacted key>')); console.log('secret leaked:', message.includes(process.env.OPENAI_API_KEY ?? '')); }"
    • node scripts/run-vitest.mjs extensions/openai/realtime-voice-provider.test.ts src/gateway/server-methods/talk.test.ts --run
    • corepack pnpm check:changed
    • git diff --check
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
Config (/home/<user>/.openclaw/openclaw.json): missing env var "GEMINI_API_KEY" at talk.realtime.providers.google.apiKey - feature using this value will be unavailable
Talk Realtime provider 'openai' requires a direct OpenAI API key (or supported OpenAI Realtime auth such as openai-codex OAuth). Azure AI Foundry / Azure OpenAI model credentials and OpenAI-compatible proxy keys are not valid for OpenAI Realtime sessions against api.openai.com. Configure talk.realtime.providers.openai.apiKey or OPENAI_API_KEY with a direct OpenAI Platform key, configure openai-codex OAuth, or use Talk gateway relay with an Azure Realtime deployment (azureEndpoint + azureDeployment).
secret leaked: false

Additional local validation output:

Test Files  3 passed (3)
Tests  96 passed (96)

check:changed completed with typecheck extensions, typecheck extension tests, lint extensions, media download helper guard, runtime sidecar loader guard, and runtime import cycles all passing. Re-run after both Codex follow-up fixes and the ClawSweeper P1 custom-endpoint fix.

  • Observed result after fix: The OpenAI Realtime browser-session path rejects obvious non-direct keys before minting client secrets, preserves OAuth fallback when available, and wraps upstream invalid-key failures into the actionable diagnostic.
  • What was not tested: A live OpenAI Realtime WebRTC session with a real OpenAI Platform key, and a live Azure Realtime deployment through gateway relay.
  • Proof limitations or environment constraints: I do not have a valid direct OpenAI Platform Realtime key or Azure Realtime deployment available in this environment, so live provider calls were not performed. The proof includes a real local OpenClaw source execution of the failing credential class plus targeted regression coverage and repository checks.
  • Before evidence (optional but encouraged): The previous behavior was represented by existing tests expecting the raw Incorrect API key provided startup failure; this PR updates that behavior to the clearer Talk Realtime auth diagnostic.

Tests and validation

Which commands did you run?

  • OPENAI_API_KEY=<redacted proxy key> node --import tsx -e "..."
  • node scripts/run-vitest.mjs extensions/openai/realtime-voice-provider.test.ts src/gateway/server-methods/talk.test.ts --run
  • corepack pnpm check:changed
  • git diff --check

What regression coverage was added or updated?

  • Added OpenAI Realtime provider tests for obvious proxy keys, Azure-looking keys, configured proxy keys, keychain-resolved proxy keys, OAuth fallback, and upstream invalid-key wrapping.
  • Updated the pre-ready WebSocket auth-failure expectation to the new diagnostic.

What failed before this fix, if known?

  • Users could receive a raw OpenAI provider error such as Incorrect API key provided: <redacted OpenAI-like key> when Talk used OpenAI Realtime with a non-direct OpenAI credential.

If no test was added, why not?

  • Tests were added.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes.

Did config, environment, or migration behavior change? (Yes/No)

No migration. There is a diagnostic-only auth behavior change for clearly invalid OpenAI Realtime credentials, plus an escape hatch OPENCLAW_OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY for unusual direct-key formats.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

Yes.

What is the highest-risk area?

  • Misclassifying an unusual but valid OpenAI Realtime credential as non-direct.

How is that risk mitigated?

  • The early rejection is limited to high-confidence proxy/Azure-looking formats and invalid prefixes, valid-looking direct OpenAI keys still reach the existing OpenAI flow, openai-codex OAuth is preferred/fallback capable for GPT Realtime models, and an environment escape hatch allows unvalidated keys.

Current review state

What is the next action?

  • Ready for maintainer review.

What is still waiting on author, maintainer, CI, or external proof?

  • CI and maintainer review.
  • Maintainers can decide whether the provided local proof is sufficient or if they want live Azure/OpenAI Realtime proof.
  • codex review --base origin/main was not run because the codex CLI is not available in this environment.
  • Maintainer edits are enabled on the fork PR.

Which bot or reviewer comments were addressed?

  • Addressed ClawSweeper P1 feedback about endpoint-only custom Realtime routes: configured and env proxy-looking keys are preserved for custom azureEndpoint routes, with regression tests.
  • Documented OPENCLAW_OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY as an emergency override instead of leaving it undocumented.
  • Addressed Codex feedback about overly broad 403 mapping: non-auth 403 responses from the Realtime client-secret endpoint are now preserved as provider permission errors, and a regression test covers this behavior.
  • Addressed Codex feedback about Azure realtime startup auth failures: startup auth rewriting now only applies to direct OpenAI realtime WebSocket sessions, and a regression test preserves Azure deployment 401 errors.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: openai size: M labels May 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added the proof: supplied External PR includes structured after-fix real behavior proof. label May 27, 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: 6111a4aabe

ℹ️ 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".

Comment thread extensions/openai/realtime-voice-provider.ts
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 25, 2026, 6:49 AM ET / 10:49 UTC.

ClawSweeper review

What this changes

This PR changes the shared OpenAI Realtime voice provider to reject known Azure/proxy credentials on direct api.openai.com sessions, replace unsafe provider errors with an actionable diagnostic, add regression coverage, and document the direct-key requirement.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

The PR has recent activity, proof, and a bounded auth-diagnostic goal, but it should stay open for a maintainer decision on whether direct OpenAI Realtime may reject unknown key formats. The available review context does not support a safe cleanup close.

Priority: P1
Reviewed head: 410b1a6e236e41006eb610e75841e604057f9571
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has useful redacted real behavior proof and broad regression coverage, but the credential-classification contract still requires maintainer confirmation.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies a redacted after-fix local run showing the intended diagnostic and no secret leakage, plus focused test results; live provider sessions remain untested but are not necessary to verify the reported invalid-key diagnostic.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies a redacted after-fix local run showing the intended diagnostic and no secret leakage, plus focused test results; live provider sessions remain untested but are not necessary to verify the reported invalid-key diagnostic.
Evidence reviewed 4 items Recent PR activity: The branch was force-pushed on July 21, 2026 and the item was updated on July 25, 2026, so it does not meet stale or abandoned-PR conditions.
Prior review continuity: The latest completed ClawSweeper review at 3f174de found no code findings but required human judgment on the guarded key-shape rejection and environment override.
Contributor proof: The PR body includes a redacted local source execution that reports the safe diagnostic and confirms the supplied proxy key was absent from the emitted message; it also reports focused tests and changed checks passing.
Findings None None.
Security Needs attention Confirm the key-classification trust boundary: The added gate can reject unknown direct OpenAI key formats before provider authentication, while the override weakens the gate process-wide; this needs an explicit supported credential-format contract.

How this fits together

OpenClaw’s shared OpenAI Realtime voice provider resolves credentials for browser client-secret sessions and server-side WebSocket bridges used by Talk and other voice surfaces. It chooses between direct OpenAI and configured custom/Azure endpoints, then passes the resulting session or error to the calling voice flow.

flowchart LR
  A[Voice surface config] --> B[OpenAI Realtime provider]
  C[Configured key or profile] --> B
  B --> D{Direct OpenAI endpoint?}
  D -->|Yes| E[Validate and mint session]
  D -->|Custom or Azure| F[Use configured endpoint]
  E --> G[Voice session or safe diagnostic]
  F --> G
Loading

Decision needed

Question Recommendation
Should direct api.openai.com Realtime reject every key format not currently recognized, or only credentials positively identified as Azure/proxy credentials? Reject only known non-OpenAI formats: Preserve unknown key formats for direct OpenAI authentication and keep the new safe diagnostic for positively identified Azure/proxy credentials.

Why: This is an upgrade-sensitive auth contract: rejecting unknown formats can block valid future OpenAI Platform keys, while allowing them preserves the existing opaque-key behavior and relies on sanitized provider failures.

Before merge

  • Resolve security concern: Confirm the key-classification trust boundary - The added gate can reject unknown direct OpenAI key formats before provider authentication, while the override weakens the gate process-wide; this needs an explicit supported credential-format contract.
  • Resolve merge risk (P1) - The branch introduces a process-wide environment override and changes direct OpenAI credential acceptance; maintainers must confirm that rejecting unknown key formats is acceptable rather than preserving opaque-key behavior.
  • Resolve merge risk (P1) - The checkout could not be inspected, so current-main implementation, owner history, scoped guidance, and the final PR-head diff could not be independently verified.
  • Complete next step (P2) - A maintainer must choose the supported direct OpenAI key-classification contract before this auth-sensitive patch can merge.

Findings

  • [medium] Confirm the key-classification trust boundary
Agent review details

Security

Needs attention: The patch’s safe-error goal is security-positive, but the new environment override and credential classifier require maintainer review of their authentication boundary.

PR surface

Source +92, Tests +220, Docs +16. Total +328 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 99 7 +92
Tests 1 222 2 +220
Docs 2 16 0 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 337 9 +328

Review metrics

Metric Value Why it matters
New auth recovery surface 1 environment override added The new override changes how existing direct OpenAI Realtime setups recover from a local credential-classification rejection.

Merge-risk options

Maintainer options:

  1. Narrow the key classifier before merge (recommended)
    Reject only positively recognized Azure/proxy credentials and let other formats reach the existing direct OpenAI authentication path.
  2. Accept the override-backed contract
    Approve the current classification only if maintainers explicitly accept the new environment-variable recovery path for unusual direct OpenAI keys.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Reject only positively identified Azure/proxy key formats; preserve unknown direct-key formats and add focused regression coverage.

Technical review

Best possible solution:

Keep this PR open for a maintainer decision on the direct-key classification boundary; if accepted, retain only positive Azure/proxy detection and avoid a permanent operator override for unknown direct OpenAI key formats.

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

No high-confidence current-main reproduction was established in this review because the repository inspection command could not run. The PR body supplies a plausible local source execution for a proxy-looking key, but it does not establish the current-main behavior independently.

Is this the best way to solve the issue?

Unclear. The safe diagnostic and secret-redaction goal are sound, but the correct key-classification boundary requires maintainer intent because the proposed broad rejection can affect valid unknown direct-key formats.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies a redacted after-fix local run showing the intended diagnostic and no secret leakage, plus focused test results; live provider sessions remain untested but are not necessary to verify the reported invalid-key diagnostic.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P1: The patch changes how configured OpenAI Realtime credentials are accepted and can block a working voice workflow for affected users.
  • merge-risk: 🚨 compatibility: A new key-shape gate and process-wide override can alter behavior for existing direct OpenAI Realtime configurations.
  • merge-risk: 🚨 auth-provider: The changed provider path selects and rejects authentication credentials before direct Realtime sessions begin.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body supplies a redacted after-fix local run showing the intended diagnostic and no secret leakage, plus focused test results; live provider sessions remain untested but are not necessary to verify the reported invalid-key diagnostic.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies a redacted after-fix local run showing the intended diagnostic and no secret leakage, plus focused test results; live provider sessions remain untested but are not necessary to verify the reported invalid-key diagnostic.

Evidence

Security concerns:

  • [medium] Confirm the key-classification trust boundary
    The added gate can reject unknown direct OpenAI key formats before provider authentication, while the override weakens the gate process-wide; this needs an explicit supported credential-format contract.
    Confidence: 0.78

What I checked:

  • Recent PR activity: The branch was force-pushed on July 21, 2026 and the item was updated on July 25, 2026, so it does not meet stale or abandoned-PR conditions. (410b1a6e236e)
  • Prior review continuity: The latest completed ClawSweeper review at 3f174de found no code findings but required human judgment on the guarded key-shape rejection and environment override. (extensions/openai/realtime-voice-provider.ts, 3f174dee1063)
  • Contributor proof: The PR body includes a redacted local source execution that reports the safe diagnostic and confirms the supplied proxy key was absent from the emitted message; it also reports focused tests and changed checks passing. (extensions/openai/realtime-voice-provider.test.ts, 95de98617524)
  • Related feature remains separate: The linked Azure gateway-relay feature request remains open and explicitly treats this PR as diagnostics-only, so it does not supersede this bounded bug fix.

Likely related people:

  • BSG2000: Authored the current PR branch and the linked diagnostics and Azure Realtime follow-up discussion, but current-main ownership could not be independently traced because read-only repository commands were unavailable. (role: recent area contributor; confidence: low; commits: 95de98617524, 410b1a6e236e; files: extensions/openai/realtime-voice-provider.ts, extensions/openai/realtime-voice-provider.test.ts)

Rank-up moves

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

  • Obtain maintainer approval for the key-classification boundary or narrow it to positively identified Azure/proxy formats.

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 (3 earlier review cycles)
  • reviewed 2026-06-26T10:17:04.953Z sha 67eb33e :: needs maintainer review before merge. :: none
  • reviewed 2026-06-29T16:42:28.395Z sha 67eb33e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-06T12:16:07.806Z sha 3f174de :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Frosted Proofling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: collects tiny proofs.
Image traits: location status garden; accessory proof snapshot camera; palette sunrise gold and clean white; mood bright-eyed; pose pointing at a small proof artifact; shell matte ceramic shell; lighting moonlit rim light; background tiny artifact crates.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Frosted Proofling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 27, 2026
@BSG2000

BSG2000 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the P1 in 5f14335. Endpoint-only custom Realtime routes now bypass the direct-api.openai.com key-shape rejection and still send configured/env proxy-looking keys to the configured custom endpoint. Added regression coverage for both configured and env proxy-looking keys on a custom endpoint, and documented OPENCLAW_OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY as an emergency override. Re-ran targeted Talk/OpenAI Realtime tests and check:changed successfully. @clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 27, 2026
@BSG2000

BSG2000 commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Opened follow-up feature issue for Azure Foundry / Azure OpenAI GPT Realtime Talk via Gateway Relay: #87325. Keeping this PR scoped to diagnostics so Azure support can be reviewed separately with Azure-specific auth, relay, and compliance coverage.

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels May 29, 2026
@clawsweeper clawsweeper Bot added the rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. label Jun 20, 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: e310c50658

ℹ️ 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".


function openAIRealtimeDirectAuthError(cause?: unknown): Error {
return cause instanceof Error
? new Error(OPENAI_REALTIME_DIRECT_AUTH_MESSAGE, { cause })

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.

P2 Badge Drop the secret-bearing cause from auth rewrites

When the Realtime client-secret endpoint returns invalid_api_key with the rejected key in the provider message, this wrapper keeps that original error as cause. The actual talk.client.create/gateway-relay handlers return errors through formatForLog, and src/gateway/ws-log.ts deliberately walks the cause chain, so users still see the upstream Incorrect API key provided... detail/secret preview appended to the new diagnostic instead of only the safe auth guidance. Avoid attaching the provider error as a public cause here, or strip the cause before it reaches gateway RPC formatting.

Useful? React with 👍 / 👎.

Comment on lines +711 to +713
isDirectOpenAIRealtimeStartupAuthFailure(url, startupError)
? openAIRealtimeDirectAuthError(startupError)
: startupError,

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.

P1 Badge Update the delayed-startup auth test

This new direct-OpenAI startup wrapper also changes the error surfaced by the existing keeps a retried connection ready after delayed startup failure close case: that test still sends Incorrect API key provided and asserts the old raw message at extensions/openai/realtime-voice-provider.test.ts:1254. Since this branch now rejects with the direct-auth diagnostic before the deferred close is emitted, the targeted extension Vitest lane will fail unless that expectation is updated to the new message while keeping the retry/close assertions intact.

Useful? React with 👍 / 👎.

const OPENAI_REALTIME_DEFAULT_MIN_BARGE_IN_AUDIO_END_MS = 250;
const OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY_ENV = "OPENCLAW_OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY";
const OPENAI_REALTIME_DIRECT_AUTH_MESSAGE =
"Talk Realtime provider 'openai' requires a direct OpenAI API key. Azure AI Foundry / Azure OpenAI model credentials and OpenAI-compatible proxy keys are not valid for OpenAI Realtime sessions against api.openai.com. Configure talk.realtime.providers.openai.apiKey or OPENAI_API_KEY with a direct OpenAI Platform key, or use Talk gateway relay with an Azure Realtime deployment (azureEndpoint + azureDeployment).";

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.

P2 Badge Use a surface-neutral auth diagnostic

This provider is registered as the shared OpenAI realtime voice provider, so the same error is reachable from non-Talk paths such as Voice Call and Discord realtime voice. In those contexts an invalid OpenAI key will now tell the operator to configure talk.realtime.providers.openai.apiKey or use Talk gateway relay, even though Voice Call uses plugins.entries.voice-call.config.realtime.providers.openai.apiKey and Discord has its own voice.realtime config. Make the message name the generic OpenAI Realtime voice provider and include the non-Talk config surface so these users get actionable guidance.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@BSG2000

BSG2000 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the open Codex review findings from review 4568796619:

  • Direct OpenAI Realtime auth rewrites now emit only the safe diagnostic and no longer attach the upstream provider error as cause, avoiding secret-bearing details in cause-chain formatting.
  • The diagnostic is now surface-neutral for the shared OpenAI Realtime voice provider and mentions Talk, Voice Call, channel realtime config, and Azure deployment guidance without Talk-only wording.
  • Updated the delayed-startup/retry auth test to expect the new direct-auth diagnostic while preserving the retry/deferred-close assertions.

Validation:

  • oxfmt --check extensions/openai/realtime-voice-provider.ts extensions/openai/realtime-voice-provider.test.ts
  • vitest run extensions/openai/realtime-voice-provider.test.ts
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test.tsbuildinfo

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Jun 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 21, 2026
@BSG2000
BSG2000 force-pushed the fix/talk-openai-realtime-auth-diagnostic-pr branch from 3f174de to 99e956b Compare July 21, 2026 21:49

@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: 99e956b820

ℹ️ 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".

Comment thread docs/providers/openai.md

```json5
{
<Note>

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.

P2 Badge Move the auth note outside the JSON example

This <Note> is inserted after the opening { of the speech-to-text json5 fence, so Mintlify treats the callout as literal code and the copied configuration is invalid; users also never see the Realtime authentication guidance as a rendered callout. Move it outside the fenced block, preferably into the Realtime voice accordion.

AGENTS.md reference: docs/AGENTS.md:L5-L7

Useful? React with 👍 / 👎.

Comment thread docs/providers/openai.md
Comment on lines +796 to +798
OpenAI Realtime Talk auth is not shared with Azure AI Foundry or Azure
OpenAI model providers. Browser WebRTC sessions and native OpenAI backend
bridges need a direct OpenAI Platform API key; OpenAI-compatible proxy keys are not valid for the

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.

P2 Badge Reconcile the OAuth fallback guidance

For OAuth-only installations, this new direct-Platform-key requirement conflicts with the Realtime voice note at docs/providers/openai.md:912-914, which still promises an openai OAuth profile or external Codex login as fallback. The resolver restricts profiles to profileTypes: ["api_key"] in extensions/openai/realtime-voice-provider.ts:408-412, and extensions/openai/realtime-voice-provider.test.ts:770-779 explicitly verifies that OAuth is unsupported, so update the stale fallback text to leave one actionable authentication contract.

Useful? React with 👍 / 👎.

Detect keys that cannot be direct OpenAI Platform keys (Azure model keys, OpenAI-compatible proxy keys) before minting api.openai.com Realtime client secrets or opening direct Realtime websockets, and surface an actionable auth diagnostic. Preserves proxy-looking keys for custom OpenAI-compatible Realtime endpoints (azureEndpoint), Azure deployment auth failures, and the existing post-request client-secret rejection message. Adds OPENCLAW_OPENAI_REALTIME_ALLOW_UNVALIDATED_KEY escape hatch and docs.

Co-authored-by: Copilot <[email protected]>
@BSG2000
BSG2000 force-pushed the fix/talk-openai-realtime-auth-diagnostic-pr branch from 99e956b to 95de986 Compare July 21, 2026 22:37

@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: 95de986175

ℹ️ 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".

Comment on lines +773 to +775
const startupError = new Error(readRealtimeErrorDetail(event.error));
rejectStartup(
isDirectOpenAIRealtimeStartupAuthFailure(url, startupError)

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.

P2 Badge Preserve structured auth fields when classifying startup events

When OpenAI reports startup authentication through structured fields such as { code: "invalid_api_key", message: "Invalid API key" }, this converts the payload to a plain Error before classification, so isOpenAIRealtimeAuthFailure loses the code/status fields and its remaining message checks do not match that wording. The session therefore surfaces the raw provider error instead of the new safe direct-auth diagnostic; classify event.error itself while retaining startupError only for the fallback display error.

Useful? React with 👍 / 👎.

Comment on lines +492 to +493
if (!normalized.startsWith("sk-")) {
return true;

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.

P2 Badge Pass unknown Platform key formats through

When a valid OpenAI Platform credential uses a format other than the currently recognized sk-* convention, this blanket check classifies it as invalid and blocks both browser client-secret creation and the default backend bridge before OpenAI can authenticate it; the pre-change path treated the credential as opaque, and the newly added docs explicitly acknowledge that unusual direct-key formats can be rejected. Requiring a new process-wide override to preserve those sessions turns provider key-format evolution into an operator-visible outage, so reject only positively identified Azure/proxy formats or rely on the sanitized provider 401 diagnostic for unknown formats.

AGENTS.md reference: AGENTS.md:L31-L31

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 22, 2026
@clawsweeper clawsweeper Bot added 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. and removed 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. labels Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: openai 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. 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.

2 participants