Skip to content

fix(openai): support flexible GPT Image 2 dimensions - #118476

Merged
steipete merged 2 commits into
mainfrom
codex/qa0803-openai-image-dimensions
Aug 3, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa0803-openai-image-dimensions

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

GPT Image 2 generation and editing snapped valid flexible dimensions to legacy presets, rejected valid large square images, and incorrectly treated unsupported below-minimum pixel counts as valid flexible dimensions.

Why This Change Was Made

The provider enforces the documented GPT Image 2 flexible-size recognition contract: dimensions divisible by 16, maximum edge 3840, aspect ratio at most 3:1, and 655360 through 8294400 total pixels. Valid explicit sizes are preserved. Invalid flexible sizes retain the existing compatibility behavior and normalize to supported presets rather than being rejected. Shared normalization keeps landscape/portrait hints, and public image-tool docs explain the bounds and no-snap behavior.

User Impact

Operators can generate AND edit valid arbitrary sizes including 1024x640, 2304x2304, 2560x2560, and 2880x2880. Unsupported requested dimensions continue to normalize through the established supported-size compatibility path.

Real Authenticated Generation AND Reference-Image Edit

Both genuine packaged product CLI operations ran against the live OpenAI Images API with the exact provider/runtime candidate:

GENERATION
model: gpt-image-2
requested/returned size: 1024x640
quality: low
real output: image/jpeg, 36249 bytes
ignoredOverrides: []
natural exit: 0

REFERENCE-IMAGE EDIT
reference input: committed apps/linux/src-tauri/icons/icon.png (real 512x512 PNG)
model: gpt-image-2
requested/returned size: 1024x640
quality: low
real edited output: image/jpeg, 49995 bytes
ignoredOverrides: []
failedFallbackAttempts: 0
provider requests: exactly 1
natural exit: 0

Both requests preserve the explicit 655360-pixel minimum non-square size. Credentials and binary contents are not disclosed. Testbox: https://github.com/openclaw/openclaw/actions/runs/30787071524

Regression Evidence

  • Seven valid/invalid dimension cases failed before the final official-contract correction; unsupported dimensions continue to normalize to compatible preset output.
  • node scripts/run-vitest.mjs extensions/openai/image-generation-provider.test.ts src/image-generation/runtime.test.ts — 129/129 passing.
  • Official OpenAI image guide and installed [email protected] SDK directly inspected.
  • docs/tools/image-generation.md documents flexible direct-OpenAI sizing, both models, exact constraints, and aspect-only normalization.
  • Fresh independent Sol/high review clean; production +36 lines.
  • ALL ClawSweeper rank-ups addressed: public docs, genuine authenticated reference-image edit, and explicit compatibility-preserving invalid-size normalization (not false preflight rejection).
  • AI-assisted implementation and independently verified source review.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 3, 2026, 1:27 AM ET / 05:27 UTC.

ClawSweeper review

What this changes

This PR lets the OpenAI image plugin preserve valid explicit GPT Image 2 dimensions, retains aspect-ratio-derived presets when no size is specified, and documents the supported direct-API geometry rules.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 6 items remain

Keep this PR open. The valid flexible-dimension pass-through is in the right provider boundary, but the branch still normalizes invalid flexible sizes into a paid legacy-size request despite its stated preflight-failure outcome, and it lacks real after-fix proof for the multipart image-edit path. The protected maintainer label also requires human handling rather than automated cleanup.

Priority: P2
Reviewed head: e61f96d589506c21b22d6b87544d5c87343bb977
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The generation proof and focused tests are useful, but an edit-path proof gap and the unresolved invalid-size contract prevent a merge-ready rating.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR body includes a credible redacted real generation terminal result, but the multipart reference-image edit behavior changed by this PR still has no corresponding after-fix real-provider result; add a redacted terminal capture, logs, or artifact and update the PR body.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body includes a credible redacted real generation terminal result, but the multipart reference-image edit behavior changed by this PR still has no corresponding after-fix real-provider result; add a redacted terminal capture, logs, or artifact and update the PR body.
Evidence reviewed 7 items Valid flexible sizes bypass legacy snapping: The proposed provider change accepts a dimension only when it satisfies the flexible-model predicate; otherwise it falls back to the existing native-size resolver.
Invalid-size test locks in normalization rather than rejection: The added test cases include below-minimum, non-multiple-of-16, over-aspect-ratio, over-edge, and over-pixel dimensions, then assert that each becomes a different supported size and is sent to the provider.
Existing fallback makes a provider request: Current-main owner code resolves an unsupported requested size to the closest native size and records metadata instead of throwing, so the proposed false predicate branch still reaches the paid request path.
Findings 1 actionable finding [P2] Reject unsupported flexible dimensions before a paid request
Security None None.

How this fits together

OpenClaw’s image tool first normalizes requested geometry using provider capabilities, then sends the resulting size to the selected provider plugin. The OpenAI plugin dispatches generation as JSON or reference-image edits as multipart requests to the Images API.

flowchart LR
  A[Image tool request] --> B[Shared geometry normalization]
  B --> C[OpenAI plugin]
  C --> D{Generate or edit}
  D --> E[OpenAI Images API]
  E --> F[Image response to agent]
Loading

Decision needed

Question Recommendation
Should invalid GPT Image 2 dimensions keep the existing normalize-to-a-supported-size behavior, or should this PR introduce a local rejection before the Images API call? Preserve normalization and align the PR: Keep the tested compatibility behavior, correct the stated invalid-size outcome, and show real edit-path evidence before merge.

Why: The branch and its tests preserve normalization, while the stated user impact says invalid geometry fails before a paid provider call; choosing rejection changes an established provider compatibility path.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body includes a credible redacted real generation terminal result, but the multipart reference-image edit behavior changed by this PR still has no corresponding after-fix real-provider result; add a redacted terminal capture, logs, or artifact and update the PR body.
  • Reject unsupported flexible dimensions before a paid request (P2) - Late finding: this unchanged branch code falls back to resolveOpenAIImageRequestSize whenever the flexible predicate rejects a size. The newly added cases therefore normalize 16x16, below-minimum, and over-limit values to a legacy preset and make a provider request, contradicting the PR’s stated outcome that invalid sizes fail before paid calls. Either implement that local rejection or revise the claimed behavior and proof to the compatible normalization contract.
  • Resolve merge risk (P1) - The branch changes the effective contract for GPT Image 2 geometry while retaining legacy normalization for invalid values; changing that path to fail locally could break callers that currently receive normalized-size metadata.
  • Resolve merge risk (P1) - The exact configured current-main revision and the installed OpenAI SDK contract could not be read because this sparse checkout needed an unavailable network fetch, so this review cannot certify the external provider limits independently.
  • Complete next step (P2) - A maintainer must choose the invalid-size compatibility contract; contributor-provided real edit proof is also required before merge.

Findings

  • [P2] Reject unsupported flexible dimensions before a paid request — extensions/openai/image-generation-provider.ts:1024-1030
Agent review details

Security

None.

PR surface

Source +36, Tests +166, Docs +9. Total +211 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 42 6 +36
Tests 2 166 0 +166
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 217 6 +211

Review metrics

None.

Stored data model

Persistent data-model change detected: vector/embedding metadata: extensions/openai/image-generation-provider.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Preserve compatible normalization (recommended)
    Align the PR description and proof with the existing normalize-and-report behavior, then add redacted live edit evidence for the multipart path.
  2. Adopt strict local validation
    If maintainers want invalid values rejected before a paid call, implement that explicit behavior with upgrade coverage and clear operator-visible error text.

Technical review

Best possible solution:

Make invalid GPT Image 2 geometry intentional and consistent: either retain compatibility normalization and remove the claim that invalid requests fail before provider calls, or add an explicit local validation error with focused upgrade coverage; then attach redacted real-provider evidence for a reference-image edit.

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

Yes for the invalid-size discrepancy by source inspection: the branch’s false flexible-validation branch invokes the existing closest-size resolver and its new tests assert a provider request with a normalized size. No independent live execution of the reviewed head was possible in this read-only environment.

Is this the best way to solve the issue?

Unclear: preserving valid explicit dimensions at the OpenAI provider boundary is the right shape, but the PR must resolve whether invalid dimensions are a compatibility-normalized input or a locally rejected error before it is the best complete fix.

Full review comments:

  • [P2] Reject unsupported flexible dimensions before a paid request — extensions/openai/image-generation-provider.ts:1024-1030
    Late finding: this unchanged branch code falls back to resolveOpenAIImageRequestSize whenever the flexible predicate rejects a size. The newly added cases therefore normalize 16x16, below-minimum, and over-limit values to a legacy preset and make a provider request, contradicting the PR’s stated outcome that invalid sizes fail before paid calls. Either implement that local rejection or revise the claimed behavior and proof to the compatible normalization contract.
    Confidence: 0.9
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.82

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded provider behavior repair with a concrete compatibility decision and missing edit-path proof.
  • merge-risk: 🚨 compatibility: Changing invalid size handling from the established nearest-supported-size normalization to rejection could affect existing image-tool callers.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body includes a credible redacted real generation terminal result, but the multipart reference-image edit behavior changed by this PR still has no corresponding after-fix real-provider result; add a redacted terminal capture, logs, or artifact and update the PR body.

Evidence

What I checked:

  • Valid flexible sizes bypass legacy snapping: The proposed provider change accepts a dimension only when it satisfies the flexible-model predicate; otherwise it falls back to the existing native-size resolver. (extensions/openai/image-generation-provider.ts:1024, 6f77430686c6)
  • Invalid-size test locks in normalization rather than rejection: The added test cases include below-minimum, non-multiple-of-16, over-aspect-ratio, over-edge, and over-pixel dimensions, then assert that each becomes a different supported size and is sent to the provider. (extensions/openai/image-generation-provider.test.ts:707, 6f77430686c6)
  • Existing fallback makes a provider request: Current-main owner code resolves an unsupported requested size to the closest native size and records metadata instead of throwing, so the proposed false predicate branch still reaches the paid request path. (extensions/openai/image-generation-provider.ts:271, 7fc23f904a18)
  • Shared normalization is the right upstream boundary: The normalizer uses model-specific size lists to decide whether explicit dimensions should be snapped, and the proposed empty list preserves explicit flexible-model values while still using provider-wide sizes for aspect-ratio-only hints. (src/image-generation/normalization.ts:60, 6f77430686c6)
  • Feature provenance: The existing OpenAI image request resolver and its current call site both blame to the same recent image-generation implementation commit, making its author the strongest routing candidate for the compatibility decision. (extensions/openai/image-generation-provider.ts:998, 7fc23f904a18)
  • Re-review continuity and current-main check: The currently reviewed head is the same SHA as the prior completed review; its only follow-up commit changed documentation, and the PR head is not an ancestor of the inspected local main checkout. Public docs: docs/tools/image-generation.md. (docs/tools/image-generation.md:312, e61f96d58950)

Likely related people:

  • steipete: Peter Steinberger authored the current OpenAI image request resolver in current-main history and the proposed flexible-dimension commits. (role: current implementation author and recent area contributor; confidence: high; commits: 7fc23f904a18, 6f77430686c6, e61f96d58950; files: extensions/openai/image-generation-provider.ts, src/image-generation/normalization.ts, extensions/openai/image-generation-provider.test.ts)

Rank-up moves

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

  • Resolve and document whether invalid flexible dimensions normalize or reject before a provider call.
  • Add redacted real-provider proof for a reference-image edit using the reviewed head.

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 (2 earlier review cycles)
  • reviewed 2026-08-03T04:59:16.647Z sha 6f77430 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-03T05:14:33.832Z sha e61f96d :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review August 3, 2026 05:03
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 3, 2026
@steipete
steipete merged commit e04caa6 into main Aug 3, 2026
143 of 147 checks passed
@steipete
steipete deleted the codex/qa0803-openai-image-dimensions branch August 3, 2026 05:40
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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