Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

fix(agent): route agent image gen through Image Studio lock

mrbizarrofdb2c05ad2a5
diff --git a/agent/tools.py b/agent/tools.py
index 5659b89..ba32507 100644
--- a/agent/tools.py
+++ b/agent/tools.py
@@ -1415,14 +1415,35 @@ def _generate_shot_images(args: dict, ops: PanelOps, session: dict) -> dict:
take_index = 0
out_dir = base_dir
+ # Serialize against the manual /image/generate path. Without this,
+ # an agent anchor run can overlap with an Image Studio click and
+ # spawn two concurrent mflux/MLX subprocesses fighting for the GPU
+ # — exactly the kind of contention that has frozen Salo's Mac.
+ # Lazy import to avoid the agent.tools ↔ mlx_ltx_panel cycle; the
+ # panel has long been the importer of agent.tools at module load.
+ # (Code-review P1-2, 2026-05-09.)
+ try:
+ from mlx_ltx_panel import _IMG_STUDIO_LOCK as _img_lock
+ except Exception: # noqa: BLE001
+ _img_lock = None # tests / standalone use
t0 = time.time()
- candidates = _image_engine.generate(
- prompt=prompt, n=n, aspect=aspect,
- output_dir=out_dir,
- base_seed=(seed_base if seed_base >= 0 else None),
- refs=refs_resolved or None,
- config=cfg,
- )
+ if _img_lock is not None:
+ with _img_lock:
+ candidates = _image_engine.generate(
+ prompt=prompt, n=n, aspect=aspect,
+ output_dir=out_dir,
+ base_seed=(seed_base if seed_base >= 0 else None),
+ refs=refs_resolved or None,
+ config=cfg,
+ )
+ else:
+ candidates = _image_engine.generate(
+ prompt=prompt, n=n, aspect=aspect,
+ output_dir=out_dir,
+ base_seed=(seed_base if seed_base >= 0 else None),
+ refs=refs_resolved or None,
+ config=cfg,
+ )
elapsed = round(time.time() - t0, 2)
# Write a sidecar JSON next to each candidate so the library reader