Skip to content

fix(images): style transfer follow-ups from the cold read of #322 - #328

Merged
jddunn merged 1 commit into
masterfrom
fix/style-transfer-follow-ups
Oct 12, 2026
Merged

jddunn merged 1 commit into
masterfrom
fix/style-transfer-follow-ups

Conversation

@jddunn

@jddunn jddunn commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

A cold review of #322 (Opus 5.5) found no P0 to P2 and eight P3s. This takes seven of them. The eighth, Replicate data URLs over 1 MB, is recorded below, since it affects editImage as much as style transfer.

  • Refusal before credentials. A provider without a two-image call (BFL, MiniMax, OpenRouter, local Stable Diffusion) is now refused before its key or base URL is looked for. Before, transferStyle({ provider: 'bfl' }) said "No API key for bfl", and only once the key was set that bfl has no style transfer.

  • baseUrl needs a named provider, as apiKey does. With no provider named, a baseUrl reached the provider the environment picked, with that provider's key. With REPLICATE_API_TOKEN set, transferStyle({ baseUrl: 'https://gateway.example/v1', … }) sent the Replicate token to that host. FAL_BASE_URL now sets Fal's base URL, as REPLICATE_BASE_URL, STABILITY_BASE_URL and OPENAI_BASE_URL do for theirs, so a provider picked from the environment can still be pointed elsewhere.

  • Fal failures. Fal's queue status is IN_QUEUE, IN_PROGRESS or COMPLETED. A failed request completes, with error and error_type (https://fal.ai/docs/documentation/model-apis/inference/queue). A COMPLETED status that carries an error now fails with it, for every Fal call. The test answers in that shape, where the old case answered FAILED, which Fal does not send.

  • Model lists. Replicate's listAvailableModels names the four FLUX.2 models transferStyle runs on, and Flux Redux as a variation of one reference. Fal's names the four FLUX.2 edit endpoints.

  • Wording. The custom-endpoint rule is now stated per provider:

    • OpenAI and Fal take any name;
    • Replicate takes any owner/name, never a pinned version;
    • Stability takes no model, and accepts stable-image-style-transfer alone.

    Fal's flux-2/edit defaults (PNG, no auto size) are stated beside those of the other three endpoints.

  • Tests. New cases in transferStyle.http.test.ts:

    • a Replicate prediction that fails when created, and one whose poll ends failed;
    • Stability's composition_fidelity and change_strength sent, and refused out of range;
    • the 10 MiB limit across two images;
    • the global default lending its key and base URL to its own provider but not its model, and nothing to another provider;
    • a provider: prefix winning over provider;
    • a Fal FLUX.2 model named without /edit;
    • Replicate's pinned-version refusal;
    • the BFL refusal with no key;
    • the baseUrl refusal.

Follow-up, not in this change: Replicate's guidance keeps data URLs under 1 MB (https://replicate.com/docs/topics/predictions/input-files). Uploading larger images through its files endpoint would apply to editImage, upscaleImage and transferStyle alike.

Linked issues

Follows #322.

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. The cases above run against the local server of transferStyle.http.test.ts, which refuses any request outside it. The auto-order cases now point each provider at the server through its own base-URL variable.

Migration notes

A transferStyle() call that passed baseUrl with no provider named is now refused. Name the provider, or set the provider's base-URL variable.

Summary by Sourcery

Harden image style transfer routing, validation, provider error handling, and documentation across supported providers.

Bug Fixes:

  • Validate style-transfer provider support before resolving credentials and reject ambiguous custom base URLs that lack an explicitly named provider.
  • Handle Replicate prediction failures and Fal requests that complete with embedded errors correctly.
  • Enforce provider-specific model rules, request limits, and Stability option ranges for style transfers.

Enhancements:

  • Add provider-specific base URL selection, including Fal, and clarify model and endpoint behavior across supported providers.
  • Update Replicate and Fal model listings to reflect the FLUX.2 style-transfer endpoints and distinguish reference-image variation models.

Documentation:

  • Document provider routing, custom endpoint model rules, request defaults, and refusal conditions for style transfer.

Tests:

  • Expand HTTP coverage for provider routing, credential isolation, model validation, payload options, size limits, and Replicate and Fal failure responses.

A provider with no two-image call is refused before its key or base URL
is looked for. A baseUrl, like an apiKey, needs a named provider: with
none it reached the provider the environment picked, with that
provider's key. FAL_BASE_URL sets Fal's base URL, as the other image
providers' variables do theirs. A Fal status of COMPLETED that carries
an error is the failure Fal reports, and fails with it. Replicate's and
Fal's model lists name the FLUX.2 models and edit endpoints transferStyle
runs on, and Flux Redux as a variation of one reference. The rule a
custom base URL follows is stated per provider, and Fal's flux-2/edit
defaults (PNG, no auto size) beside the other three endpoints'. Tests
cover Replicate's failed predictions, Stability's fidelity and strength
options and its 10 MiB sum, the global default, the provider prefix,
Fal's edit completion and Replicate's pinned-version refusal.
@jddunn
jddunn requested a review from Victor-Evogor as a code owner October 12, 2026 04:08
@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 2 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

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-12T04:10:38.358239Z 8c56c59 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.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 9 billable files and costs up to $2.25.

  • 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 23 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: 61ac309a-b96f-477b-88b3-ddbddcde7420

📥 Commits

Reviewing files that changed from the base of the PR and between f01f56e and 8c56c59.


📒 Files selected for processing (9)
  • docs/features/STYLE_TRANSFER.md
  • src/api/__tests__/transferStyle.http.test.ts
  • src/api/model.ts
  • src/api/transferStyle.ts
  • src/io/media/images/IImageProvider.ts
  • src/io/media/images/__tests__/ReplicateImageProvider.test.ts
  • src/io/media/images/providers/FalImageProvider.ts
  • src/io/media/images/providers/ReplicateImageProvider.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 PR hardens style-transfer routing and validation, adds provider-specific base URL and model semantics, updates Replicate and Fal model/API handling, improves asynchronous failure reporting, and expands HTTP/provider tests and documentation for the corrected behavior.

Sequence diagram for Fal style transfer failure handling

sequenceDiagram
    participant Client
    participant Fal as FalImageProvider
    participant Queue as Fal Queue API
    Client->>Fal: transferStyle()
    Fal->>Queue: Submit two-image edit request
    Queue-->>Fal: requestId
    loop Poll status
        Fal->>Queue: Get request status
        Queue-->>Fal: IN_QUEUE or IN_PROGRESS
    end
    Queue-->>Fal: COMPLETED with error and error_type
    Fal-->>Client: Throw Fal.ai request failed error
Loading

Flow diagram for style transfer routing and validation

flowchart TD
    A[transferStyle options] --> B{Named provider or prefixed model?}
    B -- No --> C{Environment provider selected}
    C --> D[Use provider environment base URL]
    C --> E{baseUrl supplied?}
    E -- Yes --> F[Refuse baseUrl without named provider]
    E -- No --> G[Continue routing]
    B -- Yes --> H[Resolve provider and model]
    H --> I{Provider supports two-image transfer?}
    I -- No --> J[Refuse before credentials and base URL]
    I -- Yes --> K[Resolve apiKey and baseUrl]
    D --> G
    G --> L[Initialize provider]
    K --> L
    L --> M[Validate provider-specific model]
    M --> N[Send source and reference images]
Loading

File-Level Changes

Change Details Files
Harden provider routing and credential/base-URL resolution before network or image work.
  • Reject providers without two-image style transfer before credential lookup.
  • Require an explicit provider or provider-prefixed model when baseUrl is supplied.
  • Add Fal's environment-specific base URL and ensure global defaults only lend configuration to their named provider.
  • Preserve provider-prefixed model precedence over the provider option.
src/api/transferStyle.ts
src/api/model.ts
src/api/__tests__/transferStyle.http.test.ts
docs/features/STYLE_TRANSFER.md
Align provider model validation, model catalogs, and endpoint behavior with supported style-transfer APIs.
  • Document provider-specific custom-endpoint model rules, including Replicate owner/name validation and Stability's model restriction.
  • Add FLUX.2 style-transfer models for Replicate and Fal, while retaining Flux Redux as a single-reference variation.
  • Normalize Fal model names without /edit to their edit endpoints and document endpoint-specific defaults.
src/api/transferStyle.ts
src/io/media/images/IImageProvider.ts
src/io/media/images/styleTransfer.ts
src/io/media/images/providers/ReplicateImageProvider.ts
src/io/media/images/providers/FalImageProvider.ts
src/io/media/images/__tests__/ReplicateImageProvider.test.ts
docs/features/STYLE_TRANSFER.md
Improve failure handling for Replicate and Fal asynchronous requests.
  • Surface Replicate errors both at prediction creation and after polling.
  • Treat Fal COMPLETED responses carrying error and error_type as failures instead of relying on an unsupported FAILED status.
src/io/media/images/providers/FalImageProvider.ts
src/api/__tests__/transferStyle.http.test.ts
Validate and transmit Stability style-transfer options and request limits.
  • Send composition_fidelity and change_strength from provider options.
  • Reject values outside their documented ranges.
  • Enforce the 10 MiB Stability limit across the combined source and reference images.
src/api/__tests__/transferStyle.http.test.ts
docs/features/STYLE_TRANSFER.md

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

Fix style transfer routing and Fal failure handling

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Require an explicit provider for custom base URLs and reject unsupported providers before
 credential lookup.
• Surface Fal queue failures and align provider model lists with supported style-transfer models.
• Clarify provider-specific rules and add HTTP tests for routing, validation, and failures.
Diagram

graph TD
  A["Style transfer call"] --> B{"Provider named?"}
  B -->|Named| D["Two-image check"] --> E["Resolve credentials"] --> F["Validate model"] --> G["Load images"] --> H["Provider transfer"]
  B -->|Auto-detect| C["Select from environment"] --> D
Loading
High-Level Assessment

Keep the provider-scoped routing approach. Allowing a call-level base URL with auto-detection risks sending an environment-selected provider's key to an unintended host; provider-specific base-URL variables preserve auto-detection without that ambiguity. Checking two-image support before credential resolution also gives a stable, actionable refusal.

Files changed (9) +225 / -34

Enhancement (1) +10 / -3
ReplicateImageProvider.tsAlign Replicate model discovery with style transfer +10/-3

Align Replicate model discovery with style transfer

• Lists the four supported FLUX.2 style-transfer models and reclassifies Flux Redux as a single-reference variation. Makes the custom-endpoint error explain that Replicate requires an owner/name model.

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

Bug fix (2) +49 / -11
transferStyle.tsBind base URLs to named providers and check capabilities first +26/-9

Bind base URLs to named providers and check capabilities first

• Rejects a call-level base URL unless the call names a provider or uses a provider-prefixed model. Checks for two-image style-transfer support before resolving credentials and clarifies the option contracts.

src/api/transferStyle.ts

FalImageProvider.tsSurface Fal queue errors and list edit models +23/-2

Surface Fal queue errors and list edit models

• Treats a COMPLETED queue status carrying an error as a failure, including its error type when present. Adds the four FLUX.2 edit endpoints to model discovery and corrects documentation of endpoint defaults.

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

Refactor (1) +8 / -4
styleTransfer.tsAllow provider-specific custom-endpoint error guidance +8/-4

Allow provider-specific custom-endpoint error guidance

• Adds an optional message to the shared model-validation error helper so providers can describe their own custom-endpoint model rules.

src/io/media/images/styleTransfer.ts

Tests (2) +145 / -9
transferStyle.http.test.tsExpand provider-backed style transfer HTTP coverage +140/-7

Expand provider-backed style transfer HTTP coverage

• Tests routing and global-default boundaries, unsupported providers, model normalization, and Replicate failure responses. Adds Stability option and combined-size checks, updates Fal failure fixtures, and routes auto-detected providers through their own base-URL variables.

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

ReplicateImageProvider.test.tsVerify Replicate style-transfer model discovery +5/-2

Verify Replicate style-transfer model discovery

• Asserts that model discovery identifies all four supported FLUX.2 models for style transfer and describes Flux Redux as a single-reference variation.

src/io/media/images/tests/ReplicateImageProvider.test.ts

Documentation (2) +12 / -7
STYLE_TRANSFER.mdClarify provider routing and model restrictions +7/-4

Clarify provider routing and model restrictions

• Documents the named-provider requirement for call-level base URLs and provider-specific environment variables. Specifies custom-endpoint model rules, unsupported-provider refusal order, and Fal edit-endpoint defaults.

docs/features/STYLE_TRANSFER.md

IImageProvider.tsDocument provider-specific custom model rules +5/-3

Document provider-specific custom model rules

• Clarifies that custom endpoints do not share one unrestricted model policy: Replicate requires an unpinned owner/name, Stability accepts no arbitrary model, and OpenAI and Fal accept arbitrary names.

src/io/media/images/IImageProvider.ts

Other (1) +1 / -0
model.tsResolve Fal base URLs from the environment +1/-0

Resolve Fal base URLs from the environment

• Adds FAL_BASE_URL to the shared provider-to-environment mapping so Fal can use an environment-configured endpoint.

src/api/model.ts

@jddunn
jddunn merged commit dc7fb4c into master Oct 12, 2026
10 checks passed
@jddunn
jddunn deleted the fix/style-transfer-follow-ups branch October 12, 2026 04:13
@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 (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Listed Fal edit models fail to generate 🐞 Bug ≡ Correctness
Description
FalImageProvider.listAvailableModels() adds four /edit endpoints to a catalog that does not
distinguish editing from generation. When a caller selects one for generateImage() without a
reference image, the provider submits a prompt without the image_urls those edit endpoints
require.
Code

src/io/media/images/providers/FalImageProvider.ts[R634-636]

+      ...FAL_STYLE_TRANSFER_MODELS.map((modelId) => ({
+        providerId: this.providerId,
+        modelId,
Evidence
The added IDs end in /edit, but catalog entries carry no machine-readable capability. Ordinary
generation forwards the selected model and adds image_urls only when a reference image is
supplied; the separate style-transfer path always supplies its input images.

src/io/media/images/providers/FalImageProvider.ts[633-639]
src/io/media/images/IImageProvider.ts[7-12]
src/api/generateImage.ts[431-434]
src/io/media/images/providers/FalImageProvider.ts[349-351]
src/io/media/images/providers/FalImageProvider.ts[375-390]
src/io/media/images/providers/FalImageProvider.ts[600-608]

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

## Issue description
Fal's newly listed edit endpoints can be selected for ordinary generation, which submits no required input images.
## Fix Focus Areas
- src/io/media/images/providers/FalImageProvider.ts[633-639]
- src/io/media/images/IImageProvider.ts[7-12]
- src/io/media/images/providers/FalImageProvider.ts[375-390]
## Recommended Fix
Represent model capabilities in the catalog and prevent edit-only entries from being selected for generation without the required reference image, while keeping them discoverable for style transfer.

ⓘ 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

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