[PR #80] [MERGED] feat: add model_provider / strict_mode / fallback_provider to model run #81

Closed
opened 2026-10-26 22:34:44 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/comfy-swift-sdk/pull/80
Author: @deepme987
Created: 9/17/2026
Status: ✅ Merged
Merged: 9/18/2026
Merged by: @mattmillerai

Base: main ← Head: deepme987/router-provider-params


📝 Commits (4)

  • 32b942c chore: sync vendored Comfy Router spec from cloud@996a63c
  • 4b2fd24 feat: add model_provider / strict_mode / fallback_provider to model run
  • 67f76a6 test(router): add live e2e for model run alt-provider controls
  • 1c26dbe fix(router): apply review feedback on the alt-provider run parameters

📊 Changes

8 files changed (+1086 additions, -47 deletions)

View changed files

📝 README.md (+2 -0)
📝 Sources/ComfySwiftSDK/Internal/RouterTransport.swift (+130 -2)
📝 Sources/ComfySwiftSDK/Public/RouterError.swift (+28 -3)
📝 Sources/ComfySwiftSDK/Public/RouterModels.swift (+56 -1)
📝 Tests/ComfySwiftSDKTests/RouterErrorMappingTests.swift (+10 -6)
➕ Tests/ComfySwiftSDKTests/RouterModelsE2ETests.swift (+174 -0)
📝 Tests/ComfySwiftSDKTests/RouterRunTests.swift (+291 -0)
📝 spec/router-openapi.yaml (+395 -35)

📄 Description

What

Adds Comfy Router alt-provider controls to client.models.run, mirroring comfy-python-sdk#159. Three optional parameters, each sent as a query parameter on the run route and only when set, so a call that names none posts to byte-for-byte the URL this route has always used:

  • modelProvider: String? wires model_provider — an alternate serving provider (e.g. "fal"); omitted serves the model on its default provider.
  • strictMode: Bool? wires strict_mode as the literal true/false. false (the server default) has Router translate between the model's native contract and the alternate provider's real schema in both directions; true sends and returns the provider's own raw shape unchanged.
  • fallbackProvider: String? wires fallback_provider. On by default; pass "false" to opt out of the retry against the model's other registered provider.

Query values are percent-encoded per value (sub-delimiters &=+? escaped), so a value can never reshape the query string. The query is fixed once and reused on every collect re-send, exactly like the request body, so a same-key re-send stays the same logical request.

Also reconciles the closed RouterErrorType set with the vendored spec that this branch carries (cloud@996a63c): adds cancelled, queue_timeout, and request_not_found (15 -> 18 buckets), keeping Scripts/contract/check_router_contract.py and its swift-side twin RouterErrorMappingTests green.

Scope

Run route only (POST /v2/models/{provider}/{model}). Not submit / subscribe / queue — the backend rejects these parameters there.

This branch is stacked on the vendored-spec sync (#79) so the error-taxonomy reconciliation is checked against a spec that already declares the new buckets. Land #79 first, or land this (it carries that sync commit). The three feature parameters are defined in components.parameters of that synced spec (ModelProvider, StrictMode, FallbackProvider).

Testing

  • swift build — clean.
  • swift test --no-parallel — 380 tests, all passing, including new coverage for: omitted params leaving the URL query-free, each param wired to its contract name, strict_mode as a literal bool, the fallback_provider=false opt-out, all three together, the query surviving a collect re-send identically, reserved-character percent-encoding, and a direct RouterTransport.runQuery unit test.
  • python3 Scripts/contract/check_router_contract.py — OK: 18 error types, POST https://api.comfy.org/v2/models/{provider}/{model} bound.

No live API calls were made.

Companion PRs


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/comfy-swift-sdk/pull/80 **Author:** [@deepme987](https://github.com/deepme987) **Created:** 9/17/2026 **Status:** ✅ Merged **Merged:** 9/18/2026 **Merged by:** [@mattmillerai](https://github.com/mattmillerai) **Base:** `main` ← **Head:** `deepme987/router-provider-params` --- ### 📝 Commits (4) - [`32b942c`](https://github.com/Comfy-Org/comfy-swift-sdk/commit/32b942ca781838641c9f24bff519d857141e4e71) chore: sync vendored Comfy Router spec from cloud@996a63c - [`4b2fd24`](https://github.com/Comfy-Org/comfy-swift-sdk/commit/4b2fd24a1e441b73d4bb396eca336633487a0707) feat: add model_provider / strict_mode / fallback_provider to model run - [`67f76a6`](https://github.com/Comfy-Org/comfy-swift-sdk/commit/67f76a603d2799c8dbb2db44cc4e07e66eadb7d7) test(router): add live e2e for model run alt-provider controls - [`1c26dbe`](https://github.com/Comfy-Org/comfy-swift-sdk/commit/1c26dbee2d748e7111fe7b35447969b192daacd5) fix(router): apply review feedback on the alt-provider run parameters ### 📊 Changes **8 files changed** (+1086 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+2 -0) 📝 `Sources/ComfySwiftSDK/Internal/RouterTransport.swift` (+130 -2) 📝 `Sources/ComfySwiftSDK/Public/RouterError.swift` (+28 -3) 📝 `Sources/ComfySwiftSDK/Public/RouterModels.swift` (+56 -1) 📝 `Tests/ComfySwiftSDKTests/RouterErrorMappingTests.swift` (+10 -6) ➕ `Tests/ComfySwiftSDKTests/RouterModelsE2ETests.swift` (+174 -0) 📝 `Tests/ComfySwiftSDKTests/RouterRunTests.swift` (+291 -0) 📝 `spec/router-openapi.yaml` (+395 -35) </details> ### 📄 Description ## What Adds Comfy Router alt-provider controls to `client.models.run`, mirroring [comfy-python-sdk#159](https://github.com/Comfy-Org/comfy-python-sdk/pull/159). Three optional parameters, each sent as a query parameter on the run route and only when set, so a call that names none posts to byte-for-byte the URL this route has always used: - `modelProvider: String?` wires `model_provider` — an alternate serving provider (e.g. `"fal"`); omitted serves the model on its default provider. - `strictMode: Bool?` wires `strict_mode` as the literal `true`/`false`. `false` (the server default) has Router translate between the model's native contract and the alternate provider's real schema in both directions; `true` sends and returns the provider's own raw shape unchanged. - `fallbackProvider: String?` wires `fallback_provider`. On by default; pass `"false"` to opt out of the retry against the model's other registered provider. Query values are percent-encoded per value (sub-delimiters `&=+?` escaped), so a value can never reshape the query string. The query is fixed once and reused on every collect re-send, exactly like the request body, so a same-key re-send stays the same logical request. Also reconciles the closed `RouterErrorType` set with the vendored spec that this branch carries (`cloud@996a63c`): adds `cancelled`, `queue_timeout`, and `request_not_found` (15 -> 18 buckets), keeping `Scripts/contract/check_router_contract.py` and its swift-side twin `RouterErrorMappingTests` green. ## Scope Run route only (`POST /v2/models/{provider}/{model}`). Not submit / subscribe / queue — the backend rejects these parameters there. This branch is stacked on the vendored-spec sync (#79) so the error-taxonomy reconciliation is checked against a spec that already declares the new buckets. Land #79 first, or land this (it carries that sync commit). The three feature parameters are defined in `components.parameters` of that synced spec (`ModelProvider`, `StrictMode`, `FallbackProvider`). ## Testing - `swift build` — clean. - `swift test --no-parallel` — 380 tests, all passing, including new coverage for: omitted params leaving the URL query-free, each param wired to its contract name, `strict_mode` as a literal bool, the `fallback_provider=false` opt-out, all three together, the query surviving a collect re-send identically, reserved-character percent-encoding, and a direct `RouterTransport.runQuery` unit test. - `python3 Scripts/contract/check_router_contract.py` — `OK: 18 error types, POST https://api.comfy.org/v2/models/{provider}/{model} bound`. No live API calls were made. ## Companion PRs - Python (reference): https://github.com/Comfy-Org/comfy-python-sdk/pull/159 - TypeScript SDK: sibling change (add `model_provider` / `strict_mode` / `fallback_provider` to model run) - Go SDK: sibling change (add `model_provider` / `strict_mode` / `fallback_provider` to model run) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-swift-sdk#81
No description provided.