Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: gate guidance_scale on pipeline signature so multi-reference FLUX.2 renders don't crash

[._.]/ Adam Eivy62c8321a8c12
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 07104a9b1a..1fbe7b9b53 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -18,6 +18,8 @@
## Fixed
+- **Multi-reference FLUX.2 renders no longer crash on `guidance_scale`** — generating with reference images on a FLUX.2-klein model loads the guidance-distilled `Flux2KleinKVPipeline`, whose `__call__()` doesn't accept `guidance_scale`. The runner passed it unconditionally in the base kwargs (only the optional kwargs were signature-filtered), so every multi-reference render died with `TypeError: …got an unexpected keyword argument 'guidance_scale'`. `guidance_scale` is now gated on the live pipeline signature like `negative_prompt`/`strength`/`image`. The same run also silently dropped its LoRA — `set_adapters` raised `'tuple' / int` because `zip(*loaded)` hands diffusers tuples where it does arithmetic over the weights; the adapter names/scales are now passed as lists. (`scripts/flux2_macos.py`, `scripts/lora_utils.py`)
+
- **Single LoRA + init/reference image no longer fails validation** — submitting a local FLUX render with exactly one LoRA selected *and* an init or reference image attached used to 400 with "expected array, received string." The multipart path sends one LoRA as a bare repeated field (the parser only builds an array for two or more), and the route never wrapped it before Zod validation. Single-LoRA submissions over multipart now coerce correctly (matching the existing reference-strengths handling). Two-or-more LoRAs and the JSON path were always fine. (`server/routes/imageGen.js`)
- **Workspace-root validation on git/scaffold routes** — git operations and app scaffolding refuse paths outside allowed workspace roots; file staging uses literal pathspecs (no git glob expansion); `env` removed from the shell command allowlist so process secrets can't land in persisted job output.
- **Route validation + linkable tabs** — jira, loops, CoS, digital-twin, automation-schedule, and history inputs are now Zod-validated; Prompt Manager and Messages triage tabs live in the URL (deep-linkable); previously-swallowed client errors are logged.
diff --git a/scripts/flux2_macos.py b/scripts/flux2_macos.py
index c5495a7157..a1016d5d8a 100755
--- a/scripts/flux2_macos.py
+++ b/scripts/flux2_macos.py
@@ -475,18 +475,21 @@ def main() -> None:
int(args.width),
unpack_latents=_unpack_flux2_latents,
)
- # Flux2KleinPipeline.__call__ doesn't always accept negative_prompt or
- # strength — passing an unsupported kwarg raises TypeError. Filter to
- # what the live signature actually accepts.
+ # Flux2KleinPipeline.__call__ doesn't always accept negative_prompt,
+ # strength, or guidance_scale — passing an unsupported kwarg raises
+ # TypeError. Filter to what the live signature actually accepts.
+ # Flux2KleinKVPipeline (multi-reference editing) is guidance-distilled and
+ # omits `guidance_scale` entirely, so gate it like the rest.
accepted = set(inspect.signature(pipe.__call__).parameters.keys())
pipe_kwargs = dict(
prompt=args.prompt,
height=int(args.height),
width=int(args.width),
num_inference_steps=int(args.steps),
- guidance_scale=float(args.guidance),
generator=generator,
)
+ if "guidance_scale" in accepted:
+ pipe_kwargs["guidance_scale"] = float(args.guidance)
if args.negative_prompt and "negative_prompt" in accepted:
pipe_kwargs["negative_prompt"] = args.negative_prompt
if callback is not None and "callback_on_step_end" in accepted:
diff --git a/scripts/lora_utils.py b/scripts/lora_utils.py
index a4342de359..ae34a932d2 100644
--- a/scripts/lora_utils.py
+++ b/scripts/lora_utils.py
@@ -44,7 +44,10 @@ def apply_loras(pipe, lora_paths, lora_scales) -> None:
)
if not loaded:
return
- adapter_names, scales = zip(*loaded)
+ # `zip(*loaded)` yields tuples; diffusers' set_adapters does arithmetic over
+ # the weights (e.g. `weight / len(...)`) and raises `'tuple' / int` on a
+ # tuple, so hand it plain lists.
+ adapter_names, scales = (list(x) for x in zip(*loaded))
if hasattr(pipe, "set_adapters"):
try:
pipe.set_adapters(adapter_names, adapter_weights=scales)