Skip to content

fix(images): forward background and shrink large references on the Codex hosted image path - #15941

Merged
diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.52from
HDBR:fix/codex-hosted-image-background
Oct 10, 2026
Merged

diegosouzapw merged 3 commits into
cheaper-inference:release/v3.8.52from
HDBR:fix/codex-hosted-image-background

Conversation

@HDBR

@HDBR HDBR commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Two small fixes on the Codex hosted image_generation path (the gpt-5.6-*-image catalog entries that #14976 deliberately left on the Responses tool):

  • background is now forwarded to the tool. The hosted tool accepts background ("transparent", "opaque", "auto"), but the handler only copied size and quality, so a logo or sticker request with background: "transparent" always came back on an opaque canvas. The dedicated Images API path (fix(providers): route Codex GPT Image models to dedicated Images API #14976) already forwards it; this aligns the hosted path.
  • Large inline reference images are downscaled before upload. On /v1/images/edits the backend answers 503 when an inline reference is large (we saw it consistently above ~400 KB, from a self-hosted instance in production use). References above 400 KB are now resized to a 1024 px long edge with the existing optional-sharp helper (normalizeImageBuffer); smaller references, and platforms where sharp fails to load, pass through unchanged.

Changes

  • open-sse/handlers/imageGeneration.ts: toolConfig.background from body.background (trimmed, ignored when blank); new exported shrinkCodexReferenceImage() used for each reference image.
  • tests/unit/image-generation-handler.test.ts: one test for background forwarding (set and blank), one for shrinkCodexReferenceImage (small passthrough; a >400 KB PNG shrinks to a ≤1024 px long edge and keeps its mime).
  • changelog.d/fixes/: fragment.

Tests

node --import tsx/esm ... --test tests/unit/image-generation-handler.test.ts
tests 52, pass 52, fail 0

Injected defect: with the previous handler and the new tests, the two new tests fail (50 pass, 2 fail).
Prettier: clean. ESLint on the two touched files: the same 6 pre-existing findings as the base, none on changed lines.

@HDBR
HDBR requested a review from diegosouzapw as a code owner October 8, 2026 16:55
HDBR and others added 2 commits October 8, 2026 13:55
The handler test file is frozen at 2235 lines. The new background and shrink cases now live in their own file.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit af6bcb7 into cheaper-inference:release/v3.8.52 Oct 10, 2026
19 of 41 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks @HDBR — Codex hosted image generation forwards background and shrinks reference images larger than 400 KB. This is in the upcoming release.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants