fix(media): route OAuth image defaults through Codex#92824
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 14, 2026, 5:05 AM ET / 09:05 UTC. Summary PR surface: Source +538, Tests +1306. Total +1844 across 19 files. Reproducibility: yes. source-reproducible from current main and the linked issue logs: broad OpenAI provider auth can admit an implicit direct OpenAI image candidate while openai-responses image execution requires API-key material. I did not run a fresh OAuth-only install in this read-only pass. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land or revise this PR after maintainer acceptance of the image-only auth-aware implicit routing behavior and the scoped Codex app-server auth lifecycle, while keeping explicit direct OpenAI image choices intact. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible from current main and the linked issue logs: broad OpenAI provider auth can admit an implicit direct OpenAI image candidate while openai-responses image execution requires API-key material. I did not run a fresh OAuth-only install in this read-only pass. Is this the best way to solve the issue? Yes, with maintainer acceptance: applying the auth-mode decision at implicit image candidate selection and carrying scoped auth into isolated Codex media startup are the right boundaries. The remaining question is upgrade-visible default-routing policy, not a line-level patch defect. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 439a9e97fd61. Label changesLabel justifications:
Evidence reviewedPR surface: Source +538, Tests +1306. Total +1844 across 19 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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 review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Land-ready verificationBest-fix judgment: yes. This routes OAuth-backed implicit OpenAI image understanding through the owning Codex plugin, preserves scoped versus persisted auth provenance, and keeps isolated app-server startup plus refresh callbacks on one prepared store. The maintainer fixes also prevent rotating-token reuse and guard concurrent account replacement.
Direct upstream Codex contract checked at
No new live-provider OAuth media call was run in this maintainer pass; exact-SHA CI, focused behavior proof, and direct dependency-contract proof are green. |
Summary
AI-assisted bug fix for #87168.
This PR makes implicit image media-understanding model selection auth-mode-aware for OpenAI-family defaults:
openai/...image media candidates only when direct OpenAI API-key-capable auth is available for the directopenai-responsesroutecodex/gpt-5.5for implicit OpenAI image defaults and auto candidates only when canonical OpenAI OAuth/token auth plus the Codex app-server route are both availableopenai/...andcodex/...image overridesagentDirinto isolated Codex media app-server client startup so agent-scoped OAuth is available at executionRoot Cause
The old image selection path checked provider-level auth and treated canonical OpenAI OAuth as enough to select direct OpenAI image media models. Runtime execution later requires API-key auth for
openai-responses, producing the misleadingOPENAI_API_KEYerror. Codex image media can use the Codex app-server route, but that route must be selected deliberately and only when the auth signal is real.Verification
node scripts/run-vitest.mjs src/agents/tools/model-config.helpers.test.ts src/agents/tools/image-tool.test.ts extensions/codex/media-understanding-provider.test.tsnode scripts/run-vitest.mjs src/agents/tools/pdf-tool.model-config.test.tsgit diff --check.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-outputclean: no accepted/actionable findings reportedReal behavior proof
Behavior addressed: OAuth/token-only OpenAI auth no longer selects unusable direct OpenAI image media defaults or implicit image fallbacks; image auto-selection uses Codex when the Codex media route is actually available.
Real environment tested: Local OpenClaw PR worktree with the locally installed Codex CLI authenticated by ChatGPT/Codex token credentials. The subprocess explicitly removed
OPENAI_API_KEY.Exact steps or command run after this patch: Ran an inline
tsxscript withenv -u OPENAI_API_KEYthat importedbuildCodexMediaUnderstandingProvider, generated a 64x64 PNG using OpenClaw's PNG encoder, and calledprovider.describeImagewithprovider: "codex",model: "gpt-5.5", and a temporary agent directory.Evidence after fix:
{ "ok": true, "provider": "codex", "model": "gpt-5.5", "openaiApiKeyPresent": false, "image": { "mime": "image/png", "width": 64, "height": 64, "bytes": 208 }, "durationMs": 49654, "textPreview": "Solid red square." }Observed result after fix: The real Codex media provider completed image understanding through
codex/gpt-5.5with noOPENAI_API_KEYin the subprocess environment. Regression coverage also proves OAuth/token-only image defaults selectcodex/gpt-5.5, non-OpenAI primaries do not retain bad implicit OpenAI image fallback candidates, direct OpenAI API-key auth keepsopenai/..., explicit overrides remain unchanged, legacyopenai-codex:*profiles do not trigger Codex behavior, and external CLI Codex OAuth survives the candidate auth filter.What was not tested: Crabbox remote proof. PDF live UX proof is not part of this PR because PDF routing is intentionally unchanged.
Fixes #87168