Skip to content

Fix OpenAI audio auth to use API keys - #90793

Merged
sallyom merged 3 commits into
openclaw:mainfrom
Glucksberg:codex/openai-audio-api-key-auth
Jun 6, 2026
Merged

sallyom merged 3 commits into
openclaw:mainfrom
Glucksberg:codex/openai-audio-api-key-auth

Conversation

@Glucksberg

@Glucksberg Glucksberg commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Route OpenAI media-understanding audio auth through the openai-audio-transcriptions API contract.
  • This makes the auth resolver reject ChatGPT/Codex OAuth profiles for OpenAI audio transcription and continue to the configured OpenAI platform API key.
  • Add a regression test for the mixed setup where openai:default is OAuth but OPENAI_API_KEY is available for audio.

Why

OpenAI chat/Codex OAuth can be valid for model turns, but /audio/transcriptions requires an OpenAI platform API key. Media-understanding audio previously resolved provider auth without a modelApi, so the generic OpenAI OAuth profile could be selected before the API key path. That made audio transcription fail even on hosts that had a valid platform key configured for transcription.

Real behavior proof

Behavior addressed: OpenAI audio transcription must use a platform API key even when the OpenAI provider also has an OAuth openai:default profile configured for chat/Codex use.

Real environment tested: Local OpenClaw source checkout on this branch, real OpenAI HTTPS calls, real OPENAI_API_KEY loaded from the gateway environment, and an isolated temporary agent auth store containing an intentionally invalid OAuth openai:default profile.

Exact steps or command run after this patch: Ran a source-level node --import tsx --input-type=module proof script that generated a short MP3 through OpenAI /audio/speech, saved an isolated invalid OAuth auth profile for openai:default, then called runCapability({ capability: "audio" }) with the real bundled OpenAI media-understanding provider and model: "whisper-1".

Evidence after fix:

{
  "ok": true,
  "provider": "openai",
  "model": "whisper-1",
  "transcript": "Open CLAW Audio API Keyproof.",
  "outcome": "success",
  "attempts": [
    {
      "provider": "openai",
      "model": "whisper-1",
      "outcome": "success"
    }
  ],
  "oauthProfilePresent": true,
  "envApiKeyPresent": true
}

Observed result after fix: The audio transcription succeeded through OpenAI with a real platform API key even though the configured openai:default OAuth profile was present and intentionally invalid.

What was not tested: No packaged gateway restart or channel voice-note round trip was run for this PR; the live proof covered the source media-understanding auth/transcription path that this patch changes.

Verification

  • node_modules/.bin/oxfmt src/media-understanding/runner.entries.ts src/media-understanding/runner.local-no-auth.test.ts
  • node_modules/.bin/oxlint src/media-understanding/runner.entries.ts src/media-understanding/runner.local-no-auth.test.ts
  • node scripts/run-vitest.mjs src/media-understanding/runner.local-no-auth.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode local -> clean, no accepted/actionable findings

@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 6, 2026
@clawsweeper

clawsweeper Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 6, 2026, 12:10 AM ET / 04:10 UTC.

Summary
The PR scopes OpenAI media-understanding audio auth to the openai-audio-transcriptions API contract, shares that contract with request attribution, and adds regression coverage for OAuth-plus-API-key and fallback-provider audio selection.

PR surface: Source +43, Tests +204. Total +247 across 7 files.

Reproducibility: yes. Current main is source-reproducible because media execution and selection omit modelApi, while model-auth only rejects OpenAI OAuth for non-Codex API contexts when modelApi is supplied; I did not run tests because this review is read-only.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No packaged gateway restart or channel voice-note round trip was rerun; confidence rests on the source media-understanding live proof, targeted regression tests, and the shared auth contract.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow auth-resolution fix after normal maintainer checks so OpenAI audio uses platform API-key auth while non-audio media and non-OpenAI provider auth behavior remain unchanged.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P2] No repair lane is needed because the PR has no blocking findings; the remaining action is ordinary maintainer review, checks, and merge handling.

Security
Cleared: The diff narrows auth selection and adds tests only; it does not add dependencies, workflows, lockfile changes, secret storage expansion, or new code-execution paths.

Review details

Best possible solution:

Land the narrow auth-resolution fix after normal maintainer checks so OpenAI audio uses platform API-key auth while non-audio media and non-OpenAI provider auth behavior remain unchanged.

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

Yes. Current main is source-reproducible because media execution and selection omit modelApi, while model-auth only rejects OpenAI OAuth for non-Codex API contexts when modelApi is supplied; I did not run tests because this review is read-only.

Is this the best way to solve the issue?

Yes. The PR is the narrowest maintainable fix I found: it reuses the existing model-auth API-key-only guard and scopes the new auth context to OpenAI audio, while tests cover OAuth-plus-API-key audio, OAuth-only fallback selection, and video remaining unscoped.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 092075534e54.

Label changes

Label justifications:

  • P2: This is a focused OpenAI audio transcription auth bug fix with limited blast radius and regression coverage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix live output from real OpenAI HTTPS audio generation/transcription using a real OPENAI_API_KEY while an invalid openai:default OAuth profile was present.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix live output from real OpenAI HTTPS audio generation/transcription using a real OPENAI_API_KEY while an invalid openai:default OAuth profile was present.
Evidence reviewed

PR surface:

Source +43, Tests +204. Total +247 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 45 2 +43
Tests 3 204 0 +204
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 249 2 +247

What I checked:

  • Repository policy read: Root AGENTS.md was read fully, and src/agents/AGENTS.md was read because the changed media runner calls the shared model-auth boundary; that policy drove the deep caller/callee, dependency, proof, and no-mutation review shape. (AGENTS.md:1, 092075534e54)
  • Current-main root cause: Current main resolves media provider execution auth by calling resolveApiKeyForProvider without modelApi, so OpenAI audio requests cannot trigger the existing non-Codex OpenAI API-key-only guard before profile selection. (src/media-understanding/runner.entries.ts:517, 092075534e54)
  • Existing auth contract: model-auth already treats provider openai plus a defined non-openai-chatgpt-responses modelApi as requiring API-key auth, and skips incompatible OAuth profile candidates when that context is supplied. (src/agents/model-auth.ts:91, 092075534e54)
  • PR implementation: The PR head adds a tiny helper that returns openai-audio-transcriptions only for OpenAI audio, so video, image, and non-OpenAI providers keep an undefined auth API context. (src/media-understanding/openai-audio-api.ts:6, a05c99521a07)
  • Execution path fixed: The PR head passes the audio-specific modelApi into execution-time resolveApiKeyForProvider, which makes the OpenAI audio transcription request resolve an API key instead of an OAuth profile. (src/media-understanding/runner.entries.ts:530, a05c99521a07)
  • Auto-selection path fixed: The maintainer follow-up commit also passes the same OpenAI audio auth context into hasAvailableAuthForProvider, so OAuth-only OpenAI audio can be skipped before falling through to another usable audio provider. (src/media-understanding/runner.ts:112, a05c99521a07)

Likely related people:

  • steipete: Shortlog and history show the heaviest contribution to media-understanding, including inbound media understanding and provider registration/refactor work that owns the affected runner boundary. (role: feature-history owner; confidence: high; commits: 1b973f7506, 3e010e280a, 1687c672a7; files: src/media-understanding/runner.ts, src/media-understanding/runner.entries.ts, src/media-understanding/provider-registry.ts)
  • vincentkoc: History shows repeated media-understanding runtime/request shaping work, including splitting runtime contracts and filling provider capability docs adjacent to this OpenAI-compatible audio path. (role: adjacent owner; confidence: high; commits: 6e74d77a42, 90fac50987, d92ba4f8aa; files: src/media-understanding/runner.ts, src/media-understanding/openai-compatible-audio.ts, src/media-understanding/shared.ts)
  • obviyus: Current-main blame for the relevant media runner, model-auth guard, and OpenAI-compatible audio files points at a recent broad source commit, making this useful recent-source routing even though older feature history is shared. (role: recent area contributor; confidence: medium; commits: 3d68f7e5f74b; files: src/media-understanding/runner.entries.ts, src/media-understanding/runner.ts, src/agents/model-auth.ts)
  • sallyom: The public review identified the remaining auto-selection gap on the previous PR head, and the final head commit applies that fix by sharing the auth context with selection. (role: reviewer and follow-up owner; confidence: high; commits: a05c99521a07; files: src/media-understanding/openai-audio-api.ts, src/media-understanding/runner.ts, src/media-understanding/runner.entries.ts)
  • Glucksberg: Beyond authoring this PR, history shows prior merged media audio work in this area, so they have relevant domain context for the transcription runner behavior. (role: recent media contributor; confidence: medium; commits: 8b70ba6ab8, 60598cb65b16, a135c99f7a97; files: src/media-understanding/runner.entries.ts, src/media-understanding/runner.local-no-auth.test.ts, src/media-understanding/openai-compatible-audio.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 6, 2026
@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. P2 Normal backlog priority with limited blast radius. labels Jun 6, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 6, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 6, 2026
@sallyom sallyom self-assigned this Jun 6, 2026
sallyom
sallyom previously requested changes Jun 6, 2026

@sallyom sallyom 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.

Thanks for the focused fix - my local review found an issue I'm pushing a small fix for:

  • With this PR, OpenAI audio execution requires the openai-audio-transcriptions auth context, so ChatGPT/Codex OAuth is correctly rejected for /audio/transcriptions. But auto-selection was still checking plain openai auth, so OAuth-only OpenAI could be selected before another usable provider like Mistral, then fail during execution without falling through.
  • The small fix shares the OpenAI-audio auth context between selection and execution. Now OAuth-only OpenAI is skipped for audio transcription, and a provider with a valid API key can be selected instead.
  • Adding a regression test for OAuth-only OpenAI + usable Mistral auth.
  • users with OAuth-only OpenAI plus another usable audio provider, local Whisper, or Mistral may now get successful audio transcription through that fallback instead of an OpenAI auth failure.

@sallyom
sallyom dismissed their stale review June 6, 2026 03:15

Posted in error; maintainer requested removal.

@sallyom
sallyom merged commit 6f909f6 into openclaw:main Jun 6, 2026
166 of 168 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 6, 2026
* fix(media): require api key auth for OpenAI audio

* fix(media): narrow OpenAI audio auth API scope

* fix(media): align OpenAI audio auth selection

Signed-off-by: sallyom <[email protected]>

---------

Signed-off-by: sallyom <[email protected]>
Co-authored-by: sallyom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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.

2 participants