Skip to content

fix(media): image description fails with no API key when OpenAI uses ChatGPT OAuth - #167221

Closed
ericcurtin wants to merge 11 commits into
openclaw:mainfrom
ericcurtin:fix/image-runtime-auth-before-route
Closed

ericcurtin wants to merge 11 commits into
openclaw:mainfrom
ericcurtin:fix/image-runtime-auth-before-route

Conversation

@ericcurtin

@ericcurtin ericcurtin commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Related to #165961

What Problem This Solves

Fixes: image description fails with No API key found for provider "openai" when OpenAI is connected only through ChatGPT OAuth.

User Impact

view_image, inbound image analysis and openclaw infer image describe work with ChatGPT OAuth. API keys with Codex enabled work too.

Why This Change Was Made

Auth was checked against the first (Platform) route before the route was chosen. Image description now uses the same route-aware auth step as simple completions (moved to completion-model-auth.ts, not copied). Other providers are unchanged.

Evidence

Real CLI, isolated state, OAuth-only OpenAI profile, openclaw infer image describe --model openai/gpt-5.6-luna:

before (e2f407d9178): No API key found for provider "openai". You are authenticated with OpenAI ChatGPT/Codex OAuth. ...
after  (478290a1810): [openai-transport] ChatGPT Responses stream ... api=openai-chatgpt-responses
                      Failed to extract accountId from token   (fixture token; the ChatGPT route is now reached)
  • New image.auth-routing.test.ts (real resolver and route plan, stream stubbed): both cases fail before, pass after.
  • pnpm test <file> --maxWorkers=1: 2 passed, 11s.
  • Touched image, simple-completion, pdf, tts tests pass. pnpm tsgo:core and pnpm tsgo:core:test clean.
  • image.test.ts: generic abort/retry cases use a non-OpenAI provider, since OpenAI now takes the real route plan.
  • Not run: autoreview (script removed from checkout); fresh read-only review found no issues.
  • CI: besides the maintainer security-review gate, the only red is test/scripts/eager-import-closure.test.ts, which also fails on pure main (12a91e0919, 08005517c4) and on unrelated PRs. This PR does not touch it.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: 6b40f49bed82736bdaf62eaa6b9c8e6d1b519d98

These sensitive security changes were made:

  • src/agents/completion-model-auth.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR shares credential-compatible model-route preparation between image descriptions and simple completions.

Example: Describe cat.png with openai/gpt-5.6-luna using only ChatGPT OAuth.

  • Before: Authentication rejects the initial Platform route with “No API key found for provider openai.”
  • After: The patch selects the ChatGPT route; the supplied fixture trace reaches that transport but stops at account-ID extraction.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused shared-owner repair appears correct, but supplied runtime evidence does not demonstrate a successful image description.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users connected through ChatGPT OAuth receive a missing-API-key error when describing images despite having compatible inference credentials.
Reason: The patch restores a documented contract at the shared image owner and reuses established routing behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a documented image-authentication defect that remains on current main; source review found no actionable introduced bug.

Priority: P1
Reviewed head: c7f74658d59e9123fe043c861166228ee3a69d06

Before merge

  • Add real behavior proof - The changed image auth owner reaches ChatGPT transport through the real CLI, but the fixture token fails account-ID extraction before producing a description; integration tests stub streaming, and inspected screenshots demonstrate the earlier PDF repair. The prior successful-image proof request remains unmet: provide terminal output, redacted logs, or screenshots for both claimed credential setups with fresh and retained stable-release settings, redacting API keys, IPs, phone numbers, and non-public endpoints. Source inspection confirms no stored-format or schema change requiring migration. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Successful image-description output is still needed through the shipped CLI or image tool for OAuth-only and API-key-with-Codex setups, including fresh state and retained latest-stable settings.
Agent review details

How this fits together

Image tools, inbound analysis, and the image-description CLI send selected models and agent credentials through the shared image runtime, which prepares provider transport and returns description text.

flowchart TD
  A[Image entry points] --> B[Image runtime]
  B --> C[Shared completion auth]
  D[Simple completions] --> C
  C --> E[Provider route policy]
  E --> F[Provider transport]
  F --> G[Description or completion]
Loading

Technical review

Best possible solution:

Use the existing route-aware authentication owner for image descriptions while preserving explicit credential choices and unrelated provider behavior.

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

Current-main source authenticates the initial Platform model before selecting an OAuth-compatible route, matching the affected-release report and supplied before-fix trace; no target code was executed during this review.

Is this the best way to solve the issue?

Sharing the established completion auth owner repairs the ordering at the image boundary without weakening provider compatibility checks or introducing another routing policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 993a793007d4.

Provenance checked

  • Simple-completion credential routing keeps the original intent (2848acb: Prepare authentication and its compatible physical route together to avoid pairing API keys with subscription transport.)
  • Subscription preference and explicit-auth precedence keeps the original intent (8b5fa24: Preserve subscription billing for automatic selection while retaining explicit provider, profile, and auth-order choices.)
  • Image credential-scoped metadata keeps the original intent (93bad8d: Use active-account model metadata rather than another credential’s limits; the patch retains the unrelated-provider rematerialization path and validates the selected image route.)
  • Image cancellation and retry fixtures keeps the original intent (763a9a6: Retain distinct lifecycle contracts while removing redundant mocked coverage; the patch preserves those assertions with an unrelated synthetic provider.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +86, Tests +161, Other 0. Total +247 across 8 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 252 166 +86
Tests 4 178 17 +161
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 8 431 184 +247

Review metrics

Metric Value Why it matters
Production versus test LOC Production +252/-166; tests +177/-17 Production growth creates one shared auth owner rather than copying route policy, and the added integration cases exercise the two claimed credential setups.

Root-cause cluster

Relationship: same_root_cause
Canonical: #165961
Summary: This PR addresses the remaining image-authentication ordering defect in the canonical report; the merged PDF repair covers a separate caller of the same routing contract.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The documented OAuth-only failure blocks image tools and inbound image analysis, and the responsible path remains on current main.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Provide the successful image-description evidence requested in realBehaviorProof.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-08T12:09:14.102Z sha 478290a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-08T13:37:03.081Z sha 9691b24 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T09:18:47.020Z sha 28189f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T12:18:38.315Z sha a41ecad :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T12:49:58.421Z sha a41ecad :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 8:50 PM ET / October 13, 2026, 00:50 UTC (Revision 6).

@ericcurtin

Copy link
Copy Markdown
Contributor Author

CI is green except the two maintainer approval gates (security sensitive review on completion-model-auth.ts). A successful image run needs a real ChatGPT OAuth account, so the description has the fixture token CLI trace and the routing tests only. @steipete @obviyus PTAL when you get a chance. Thank you!

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main and moved the auth store read to the async API. Touched tests and tsgo pass. @clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 12, 2026
@ericcurtin

Copy link
Copy Markdown
Contributor Author

@RomneyDa @vincentkoc PTAL when you get a chance. Thank you!

# Conflicts:
#	src/agents/simple-completion-runtime.ts
#	src/media-understanding/image.test.ts
@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main, resolved the simple-completion conflict (onAuthProfiles now flows through the shared auth step). Image, simple-completion tests and tsgo:core pass. @clawsweeper re-review

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main, resolved conflicts (plugin-owned auth now lives in the shared auth step). Image, simple-completion tests and tsgo:core pass. @clawsweeper re-review

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main (conflict in image-model-runtime.ts resolved, assertion baseline tightened). The failing runtime-llm prepared-owner test passes locally on merged main. Thank you!

@ericcurtin

Copy link
Copy Markdown
Contributor Author

Merged main to clear conflicts and the test-types red that came from main (6b40f49). Touched tests and tsgo pass.

@ericcurtin

Copy link
Copy Markdown
Contributor Author

@jalehman @joshavant PTAL when you get a chance, the security-sensitive gate needs a maintainer approval. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-review-required security-sensitive-changed size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant