Skip to content

fix(images): transferStyle sends the source and the style reference - #322

Merged
jddunn merged 2 commits into
masterfrom
feat/style-transfer-two-images
Oct 12, 2026
Merged

jddunn merged 2 commits into
masterfrom
feat/style-transfer-two-images

Conversation

@jddunn

@jddunn jddunn commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

transferStyle({ image, styleReference, prompt }) took two images and sent one (src/api/transferStyle.ts at 76c0fe7):

  • Replicate's Flux Redux route, first in the auto order, sent the reference alone and got back a variation of it; the source was never read.
  • The editImage routes (Fal, Stability, OpenAI, Replicate's other models) sent the source alone, so the style came from the prompt.
  • A provider without editImage generated from text.

Every route now sends both images. The four providers with a call that takes both get transferStyle and styleTransferModel:

Provider Default Call The two images
Replicate black-forest-labs/flux-2-pro (also flux-2-max, flux-2-flex, flux-2-dev) POST /models/{owner}/{name}/predictions input_images [source, reference], aspect_ratio: match_input_image
Fal fal-ai/flux-2-pro/edit (also the max, flex and flux-2 edit endpoints) the queue image_urls [source, reference]
Stability stable-image-style-transfer (reported; the endpoint takes no model) POST /v2beta/stable-image/control/style-transfer init_image, style_image; strength as style_strength
OpenAI gpt-image-2.5-sunburst (and the other GPT Image models) POST /images/edits two image[] parts, the source first

FLUX.2 and OpenAI edit by instruction and take no strength. They are sent an instruction that names the two images (by index for FLUX.2, as its documentation does: "The person from image 1 is petting the cat from image 2"), then the caller's prompt. A strength below 0.5 picks the light instruction, otherwise the full one.

Each provider checks these before its request:

  • the model, against the provider's verified list, before either image is read (a custom baseUrl takes any name);
  • the two images' formats;
  • the limits the provider documents (Stability: 10 MiB in all, 10,000-character texts, its seed and option ranges; OpenAI: under 50 MB an image, a 32,000-character prompt);
  • an answer that holds no image.

Replicate also refuses a providerOptions.input that would replace the prompt or the images, and any extraBody. A prediction must end succeeded.

Fal's queue reads a failure's detail at the submit answer's response_url, for every Fal call. The rebuilt path can answer 405 on a multi-segment endpoint, as the file itself notes.

The vendor facts, each read from its source:

Linked issues

None.

Type of change

  • Bug fix
  • Feature
  • Performance
  • Documentation
  • Refactor
  • Tests
  • Build or CI

How this was verified

CI only; nothing was run on a workstation.

  • src/api/__tests__/transferStyle.http.test.ts (new) runs transferStyle() through the real provider classes and fetch against a local node:http server. Every request is recorded, a request no case expects fails the case, and a URL outside the server is refused. Multipart bodies are read with the platform's own parser. It covers:
    • the request each provider is sent: fields, part types and file names, headers, and the literal instructions at strengths 0.49 and 0.5;
    • Replicate's poll of a starting prediction, and Fal's status and result reads at the URLs its submit answer gives;
    • the auto order with each set of keys, a provider whose factory is unregistered, and none;
    • refusals that read no image (image URLs on the server with no route): a provider without the call, models outside the lists, the argument checks;
    • refusals before the request: formats, reserved options, limits;
    • answers without an image: a canceled prediction, empty data, a Fal failure, a zero-byte answer;
    • a custom endpoint's model.
  • image-operation-default-models.e2e.test.ts: the Stability style case is on the style-transfer endpoint, and the OpenAI style calls send two image[] parts.
  • transferStyle.test.ts: its three cases are unchanged and still hold.
  • The design went through an adversarial spec review (Codex gpt-6.1-sol, high: 7 P1 and 8 P2, all folded in) and a fold check (gpt-6-luna, high: 3 P2, folded in) before the code was written.

Migration notes

Released as a fix (a patch), not a new minor. Every path that is now refused was returning the wrong image, no package in the monorepo calls transferStyle(), and a new minor would leave every consumer pinned to ^0.13 without AgentOS's later fixes until it is moved by hand (the breaking-change gate's reason). What changes for a caller:

  • Every route reads both images, the source included.
  • The auto order (Replicate, Fal, Stability, OpenAI) is the same, and its models are the defaults above.
  • Refused where they used to run:
    • providers without a two-image call (BFL, MiniMax, OpenRouter, local Stable Diffusion);
    • models outside a provider's list, unless its baseUrl is custom;
    • GIF on Stability and OpenAI, and bytes that are not a JPEG, PNG, WebP or GIF image;
    • on Replicate, a providerOptions.input that sets prompt, input_images, image or input_image, and any extraBody.
  • The global default's model no longer applies to a style transfer.
  • negativePrompt reaches Stability only, and size reaches OpenAI only.
  • On Replicate, seed, outputFormat and outputQuality still apply, while negativePrompt, aspectRatio, numOutputs, goFast, megapixels and disableSafetyChecker are no longer sent.

For a variation of the reference use variateImage(); to change the source by a prompt use editImage().

Checklist

  • Tests cover the changed behavior.
  • Docs are updated (STYLE_TRANSFER.md, IMAGE_EDITING.md, HIGH_LEVEL_API.md).

Summary by Sourcery

Send both the source and style reference through supported provider-specific style-transfer APIs, replacing the previous single-image and text-only fallbacks.

Bug Fixes:

  • Make transferStyle() send both the source image and style reference to the provider instead of sending only one image or falling back to text generation.

Enhancements:

  • Add provider-specific two-image style transfer support for Replicate and Fal FLUX.2, Stability style transfer, and OpenAI image edits, including provider-specific defaults, validation, strength handling, and result processing.
  • Reject unsupported providers, models, formats, options, limits, and image-less responses before returning incorrect results.
  • Expose style-transfer capability for supported providers and clarify the distinction between style transfer, image variation, and prompt-based editing.

Documentation:

  • Update style-transfer, image-editing, and high-level API documentation to describe two-image behavior, provider routing, supported models, parameters, and restrictions.

Tests:

  • Add end-to-end HTTP coverage for provider requests, polling, auto-routing, validation, failure handling, and custom endpoints.
  • Extend image operation default-model tests to cover the new Stability endpoint and OpenAI two-image edits.

Chores:

  • Introduce shared image-format detection, multipart construction, data URL handling, and style-transfer prompt utilities.

@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 12, 2026 03:18
@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @jddunn, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 14 billable files and costs up to $3.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 3 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: framerslab/agentos/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Team
  • Run ID: f696ece1-88d4-4fdc-9344-27a06fcb6f65

📥 Commits

Reviewing files that changed from the base of the PR and between 01dfe54 and e13899e.


📒 Files selected for processing (14)
  • docs/features/IMAGE_EDITING.md
  • docs/features/STYLE_TRANSFER.md
  • docs/getting-started/HIGH_LEVEL_API.md
  • src/api/__tests__/transferStyle.http.test.ts
  • src/api/runtime/__tests__/image-operation-default-models.e2e.test.ts
  • src/api/transferStyle.ts
  • src/io/media/images/IImageProvider.ts
  • src/io/media/images/PolicyAwareImageRouter.ts
  • src/io/media/images/blobPart.ts
  • src/io/media/images/providers/FalImageProvider.ts
  • src/io/media/images/providers/OpenAIImageProvider.ts
  • src/io/media/images/providers/ReplicateImageProvider.ts
  • src/io/media/images/providers/StabilityImageProvider.ts
  • src/io/media/images/styleTransfer.ts

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

This breaking change makes transferStyle a true source-plus-style-reference operation across Replicate, Fal, Stability, and OpenAI, using each provider’s native two-image API, strict preflight validation and model routing, updated capability metadata, documentation, and extensive HTTP-level tests.

Sequence diagram for two-image style transfer routing

sequenceDiagram
    participant Caller
    participant transferStyle
    participant Provider
    participant VendorAPI

    Caller->>transferStyle: transferStyle(image, styleReference, prompt)
    transferStyle->>Provider: initialize()
    transferStyle->>Provider: styleTransferModel(modelId)
    Provider-->>transferStyle: resolved model
    transferStyle->>transferStyle: imageToBuffer(image)
    transferStyle->>transferStyle: imageToBuffer(styleReference)
    transferStyle->>Provider: transferStyle(image, styleImage, prompt, strength)
    Provider->>VendorAPI: Send source and reference images
    VendorAPI-->>Provider: Image result
    Provider-->>transferStyle: ImageGenerationResult
    transferStyle-->>Caller: Restyled image
Loading

Flow diagram for style transfer preflight and execution

flowchart TD
    A[Resolve provider and style-transfer model] --> B{Provider supports transferStyle?}
    B -- No --> Z[Refuse before reading images]
    B -- Yes --> C[Validate model and options]
    C --> D[Read source and style reference]
    D --> E[Validate image formats and provider limits]
    E --> F[Build provider-native two-image request]
    F --> G{Provider response contains an image?}
    G -- No --> H[Raise error]
    G -- Yes --> I[Return restyled image]
Loading

File-Level Changes

Change Details Files
Rework transferStyle into a strict two-image operation with provider-specific capability and model routing.
  • Add a provider-level transferStyle contract and style-transfer model resolution.
  • Route auto-detection to Replicate, Fal, Stability, or OpenAI defaults while rejecting unsupported providers and models before reading images.
  • Stop using the global generation default and preserve custom-endpoint model overrides.
src/api/transferStyle.ts
src/io/media/images/IImageProvider.ts
src/io/media/images/PolicyAwareImageRouter.ts
Implement native two-image style transfer requests for all supported providers.
  • Send source and reference in the provider-native formats and ordering.
  • Use FLUX.2/OpenAI instructions selected by the strength threshold and Stability's style_strength.
  • Add provider-specific limits, format validation, option filtering, response validation, and polling/error handling.
src/io/media/images/providers/ReplicateImageProvider.ts
src/io/media/images/providers/FalImageProvider.ts
src/io/media/images/providers/StabilityImageProvider.ts
src/io/media/images/providers/OpenAIImageProvider.ts
src/io/media/images/styleTransfer.ts
src/io/media/images/blobPart.ts
Improve Fal queue handling and shared image-part construction for the new requests.
  • Use Fal's returned response URL when retrieving failure details.
  • Add format-aware MIME types, extensions, filenames, blobs, and data URLs.
src/io/media/images/providers/FalImageProvider.ts
src/io/media/images/blobPart.ts
Document the breaking behavior and provider matrix for image-guided style transfer.
  • Clarify that both source and reference images are always sent.
  • Document defaults, supported models, provider-specific fields, restrictions, strength semantics, and migration alternatives.
docs/features/STYLE_TRANSFER.md
docs/features/IMAGE_EDITING.md
docs/getting-started/HIGH_LEVEL_API.md
Add comprehensive request-level and default-model coverage.
  • Test real provider classes against a local HTTP server, including multipart/JSON payloads, polling, routing, validation, refusal paths, and empty-image responses.
  • Update default-model tests for Stability's dedicated endpoint and OpenAI's two image[] parts.
src/api/__tests__/transferStyle.http.test.ts
src/api/runtime/__tests__/image-operation-default-models.e2e.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Send both images to supported style-transfer providers

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Send source and reference images together instead of silently omitting one.
• Add two-image style transfer to Replicate, Fal, Stability, and OpenAI with provider-specific
 validation.
• Document breaking routing and model changes, and test requests against a local HTTP server.
Diagram

graph TD
  A["Caller"] --> B["transferStyle API"] --> C["Provider contract"] --> R["Replicate FLUX.2"]
  C --> F["Fal FLUX.2"]
  C --> S["Stability control"]
  C --> O["OpenAI edits"]
  B --> H["Shared helpers"]
  H --> R
  H --> F
  H --> S
  H --> O
Loading
High-Level Assessment

Keep style transfer as an optional provider capability. Reusing editImage or generation was considered, but those operations do not consistently accept both images; the dedicated contract makes unsupported providers fail explicitly while retaining each provider's existing transport and authentication.

Files changed (14) +1480 / -158

Enhancement (8) +774 / -15
IImageProvider.tsDefine the provider-level two-image style-transfer contract +52/-0

Define the provider-level two-image style-transfer contract

• Adds ImageStyleTransferRequest and optional transferStyle and styleTransferModel methods. Extends Stability provider options with composition fidelity and change strength.

src/io/media/images/IImageProvider.ts

PolicyAwareImageRouter.tsAdvertise supported style-transfer providers +4/-4

Advertise supported style-transfer providers

• Adds the style-transfer capability to Fal, Stability, and OpenAI alongside Replicate, matching providers with two-image implementations.

src/io/media/images/PolicyAwareImageRouter.ts

blobPart.tsAdd signature-based image typing and payload helpers +57/-3

Add signature-based image typing and payload helpers

• Identifies PNG, JPEG, WebP, and GIF from their bytes and supplies matching multipart file parts or data URLs. This keeps submitted media types aligned with the actual image format.

src/io/media/images/blobPart.ts

FalImageProvider.tsSubmit both images to Fal FLUX.2 edit endpoints +118/-5

Submit both images to Fal FLUX.2 edit endpoints

• Adds supported-model checks and a queue-backed style-transfer request containing both image URLs. Queue failures now read details from the response URL returned at submission, including for existing Fal calls.

src/io/media/images/providers/FalImageProvider.ts

OpenAIImageProvider.tsSend two-image OpenAI edits for style transfer +129/-2

Send two-image OpenAI edits for style transfer

• Adds GPT Image model checks, image and prompt limits, and two ordered multipart image parts with an image-aware instruction. Shares the edit submission path with existing single-image editing and rejects image-less results.

src/io/media/images/providers/OpenAIImageProvider.ts

ReplicateImageProvider.tsUse FLUX.2 model predictions with both input images +172/-1

Use FLUX.2 model predictions with both input images

• Adds supported-model and reserved-option checks, then sends ordered input_images to FLUX.2 with an image-aware instruction. Polls predictions to a successful terminal state and rejects outputs without images.

src/io/media/images/providers/ReplicateImageProvider.ts

StabilityImageProvider.tsUse Stability's dedicated style-transfer endpoint +140/-0

Use Stability's dedicated style-transfer endpoint

• Sends source and reference as init_image and style_image, with strength mapped to style_strength. Validates supported formats, request size, text and option limits, and nonempty image responses.

src/io/media/images/providers/StabilityImageProvider.ts

styleTransfer.tsShare image-aware instructions and style-transfer validation +102/-0

Share image-aware instructions and style-transfer validation

• Introduces light and full instructions for editing models that lack numeric strength. Centralizes two-image format checks and errors for unsupported style-transfer models.

src/io/media/images/styleTransfer.ts

Bug fix (1) +94 / -93
transferStyle.tsRoute style transfer only through two-image provider capabilities +94/-93

Route style transfer only through two-image provider capabilities

• Validates arguments, selects style-transfer-specific defaults, and rejects providers or models without the required capability before reading images. Passes both image buffers to the selected provider instead of falling back to single-image editing or generation.

src/api/transferStyle.ts

Tests (2) +544 / -9
transferStyle.http.test.tsExercise provider style transfers against a local HTTP server +529/-0

Exercise provider style transfers against a local HTTP server

• Adds request-level tests for both images, provider routing, multipart and JSON payloads, polling, validation, custom models, and empty or failed results. The server records unexpected requests and rejects traffic outside the test server.

src/api/tests/transferStyle.http.test.ts

image-operation-default-models.e2e.test.tsVerify default two-image requests for Stability and OpenAI +15/-9

Verify default two-image requests for Stability and OpenAI

• Updates the Stability expectation to its dedicated style-transfer endpoint and reported model. Checks that OpenAI style transfers send two image parts while ordinary edits still send one.

src/api/runtime/tests/image-operation-default-models.e2e.test.ts

Documentation (3) +68 / -41
IMAGE_EDITING.mdDistinguish prompt-based restyling from reference-based transfer +3/-3

Distinguish prompt-based restyling from reference-based transfer

• Clarifies that editImage derives its style from the prompt and directs readers to transferStyle when they have a reference image.

docs/features/IMAGE_EDITING.md

STYLE_TRANSFER.mdDocument two-image style transfer and breaking behavior +64/-37

Document two-image style transfer and breaking behavior

• Replaces the former one-image routing description with provider defaults, supported models, formats, limits, and strength behavior. Explains unsupported providers and directs one-image workflows to editImage or variateImage.

docs/features/STYLE_TRANSFER.md

HIGH_LEVEL_API.mdClarify the high-level style-transfer contract +1/-1

Clarify the high-level style-transfer contract

• States that transferStyle sends both the source and reference images to the provider.

docs/getting-started/HIGH_LEVEL_API.md

transferStyle took two images and sent one: Replicate's Flux Redux route
sent the reference alone, and the img2img routes sent the source alone.
Each provider with a call that takes both now has transferStyle and
styleTransferModel: Replicate and Fal on FLUX.2 (input_images and
image_urls, with an instruction that names image 1 and image 2),
Stability on its style-transfer endpoint (init_image and style_image),
and OpenAI on two image[] parts of the edits endpoint.

Each one checks the model against its verified list before either image
is read, then the images' formats, the provider's documented limits, and
an answer with no image. Fal reads a failure's detail at the submit
answer's response_url, which every Fal call now passes.

What changes for a caller: every route reads both images. The auto
order is the same, and its models are black-forest-labs/flux-2-pro
(Replicate), fal-ai/flux-2-pro/edit (Fal), stable-image-style-transfer
(Stability) and gpt-image-2.5-sunburst (OpenAI). A call that produced
the wrong image now fails with the reason: providers without a
two-image call (BFL, MiniMax, OpenRouter, local Stable Diffusion), and
models outside a provider's list unless its base URL is custom. The
global default's model no longer applies to a style transfer. On
Replicate, providerOptions.input may not set the prompt or the images,
extraBody is refused, and negativePrompt, aspectRatio, numOutputs,
goFast, megapixels and disableSafetyChecker are no longer sent.
@jddunn
jddunn force-pushed the feat/style-transfer-two-images branch from ea783cc to 65dfe43 Compare October 12, 2026 03:21
@jddunn jddunn changed the title feat(images)!: transferStyle sends the source and the style reference fix(images): transferStyle sends the source and the style reference Oct 12, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Replicate users select a rejected model 🐞 Bug ≡ Correctness
Description
REPLICATE_STYLE_TRANSFER_MODELS replaces Flux Redux with four FLUX.2 models, but
listAvailableModels() still labels Flux Redux as its style-transfer model and lists none of the
replacements. A caller choosing that advertised model for transferStyle() is rejected by
styleTransferModel() before either image is read; Fal and Stability also omit their new
style-transfer choices from their listings.
Code

src/io/media/images/providers/ReplicateImageProvider.ts[R36-40]

+export const REPLICATE_STYLE_TRANSFER_MODELS: readonly string[] = [
+  'black-forest-labs/flux-2-pro',
+  'black-forest-labs/flux-2-max',
+  'black-forest-labs/flux-2-flex',
+  'black-forest-labs/flux-2-dev',
Evidence
The new Replicate allowlist excludes the model that its existing catalog explicitly recommends for
style transfer. The new validator rejects catalog selections outside that allowlist; the Fal and
Stability catalogs likewise have no entries for their newly added transfer choices.

src/io/media/images/providers/ReplicateImageProvider.ts[36-41]
src/io/media/images/providers/ReplicateImageProvider.ts[558-570]
src/io/media/images/providers/ReplicateImageProvider.ts[692-707]
src/io/media/images/providers/FalImageProvider.ts[617-627]
src/io/media/images/providers/StabilityImageProvider.ts[648-679]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The provider model listings do not reflect the models introduced for two-image style transfer. Replicate still advertises Flux Redux for style transfer even though the new validator refuses it.
## Fix Focus Areas
- src/io/media/images/providers/ReplicateImageProvider.ts[36-41]
- src/io/media/images/providers/ReplicateImageProvider.ts[692-707]
- src/io/media/images/providers/FalImageProvider.ts[617-627]
- src/io/media/images/providers/StabilityImageProvider.ts[648-679]
## Recommended Fix
Align the listings with each provider's new style-transfer capability. Remove Replicate's obsolete style-transfer designation for Flux Redux, list its supported FLUX.2 models, and expose the new Fal and Stability choices where applicable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Invalid image data reaches providers 🐞 Bug ≡ Correctness
Description
imagePartType() treats a short magic prefix as a complete image format, accepting buffers such as
the three JPEG signature bytes or an eight-byte PNG header. When either input has such a prefix,
styleTransferImageTypes() passes it and the transfer method sends the malformed bytes to the
provider rather than refusing them locally.
Code

src/io/media/images/blobPart.ts[R47-50]

+  if (startsWith(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a)) return IMAGE_PART_TYPES['image/png'];
+  if (startsWith(0xff, 0xd8, 0xff)) return IMAGE_PART_TYPES['image/jpeg'];
+  if (startsWith(0x52, 0x49, 0x46, 0x46) && bytes.subarray(8, 12).toString('latin1') === 'WEBP') {
+    return IMAGE_PART_TYPES['image/webp'];
Evidence
Buffers supplied to imageToBuffer() are returned unchanged. The new detector classifies incomplete
headers as images, and the shared check then permits those bytes to be wrapped in a multipart part
or data URL; the new tests also use signature-only JPEG, WebP and GIF fixtures.

src/io/media/images/imageToBuffer.ts[98-101]
src/io/media/images/blobPart.ts[45-53]
src/io/media/images/styleTransfer.ts[72-89]
src/io/media/images/blobPart.ts[64-75]
src/api/tests/transferStyle.http.test.ts[65-71]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new format check accepts incomplete buffers based only on their opening bytes, so malformed image data passes local validation and is sent in a style-transfer request.
## Fix Focus Areas
- src/io/media/images/blobPart.ts[45-53]
- src/io/media/images/styleTransfer.ts[72-89]
- src/api/__tests__/transferStyle.http.test.ts[65-71]
## Recommended Fix
Validate that each buffer contains a structurally complete image of the detected format before accepting it, rather than relying on a signature alone. Add truncated-header and malformed-image cases that verify no provider request is made.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread src/io/media/images/blobPart.ts Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T03:22:27.769947Z ea783cc PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jddunn
jddunn merged commit 32761ce into master Oct 12, 2026
10 checks passed
@jddunn
jddunn deleted the feat/style-transfer-two-images branch October 12, 2026 03:29
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
## [0.13.59](v0.13.58...v0.13.59) (2026-10-12)

### fix

* **images:** transferStyle sends the source and the style reference (#322) ([32761ce](32761ce))

### docs

* **providers:** a Gemini CLI tool-call block whose body is not JSON streams as text (#320) ([76c0fe7](76c0fe7))
* thirteenth round of audit follow-ups (diagram alt texts, the PII page, HITL gaps) (#319) ([01dfe54](01dfe54))
jddunn added a commit that referenced this pull request Oct 12, 2026
A provider with no two-image call is refused before its credentials are looked for. A baseUrl needs a named provider, as an apiKey does; FAL_BASE_URL sets Fal's. A completed Fal status that carries an error fails with it. The model lists name the FLUX.2 models and edit endpoints, the custom-endpoint rule is stated per provider, and the tests cover the paths the cold read found untested.
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
## [0.13.62](v0.13.61...v0.13.62) (2026-10-12)

### fix

* **images:** style transfer follow-ups from the cold read of #322 (#328) ([dc7fb4c](dc7fb4c))
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.

1 participant