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.

feat(agent): LoRA pass-through + character-lock + multi-keyframe usage rules

mrbizarroed9b87564c16
diff --git a/agent/prompts.py b/agent/prompts.py
index 0e0cbca..261f670 100644
--- a/agent/prompts.py
+++ b/agent/prompts.py
@@ -331,14 +331,85 @@ chose.
workflow ("just t2v, skip the picker"), or the shot is so abstract
that no still serves as a useful anchor (a generic ambient cutaway).
-`mode: "keyframe"` (FFLF) — multi-frame anchored interpolation. Useful
-when the user wants both start AND end frames pinned. Tier-clamped to
-{max_dim_kf}px on Comfortable. Requires Q8 weights.
+`mode: "keyframe"` — anchored interpolation. The helper accepts
+**arbitrary N keyframes** (≥2), each with a `frame_index` placement.
+Tier-clamped to {max_dim_kf}px on Comfortable. Requires Q8 weights.
+
+Use 2 keyframes (FFLF) when the user pins start + end. Use **3 or
+more** when:
+
+- The shot has a clear middle beat (turn, sit-down, look, gesture).
+ Pin a still at the beat; the model interpolates approach + departure
+ motion around it.
+- You're chaining shots and need composition control beyond "first
+ frame anchored." Cross-shot continuity is achieved by reusing
+ shot N's last frame as shot N+1's keyframe-0.
+- The character is moving across screen and faces small-in-frame
+ trouble (sub-80 px). Pin keyframes where the face is at viable size;
+ let the small-face frames happen as interpolated motion blur.
+
+`keyframes` array shape (passed to submit_shot):
+
+```
+[
+ {{"image_path": "/abs/path/k0.png", "frame_index": 0}},
+ {{"image_path": "/abs/path/k1.png", "frame_index": 60}},
+ {{"image_path": "/abs/path/k2.png", "frame_index": 120}}
+]
+```
+
+Indices are pixel-frame, 0-based, strictly ascending, all in
+[0, frames-1]. The pipeline cover-crops every keyframe to the
+target width × height.
`mode: "extend"` — append seconds to an existing clip. Slow
(~16 min/+3s on Comfortable) and audio chains poorly across
extensions. Use only when explicitly asked.
+# Character lock via LoRA
+
+The cleanest fix for "same prompt, different seed = different person"
+is a character-identity LoRA applied to **every shot** in the scene.
+The agent owns this lock across the whole session.
+
+Workflow:
+
+1. **Discover what's installed.** First mention of a recurring named
+ character → call `list_loras()`. If the user has a character LoRA
+ for someone matching the description (named character, recognizable
+ trigger words), suggest it. Don't try to install LoRAs — that
+ requires the user (Settings → LoRAs → Browse).
+2. **Lock it in project notes.** When the user agrees to use a LoRA
+ for a character, write the lock to durable memory:
+ ```
+ append_project_notes(content="Character LoRA — Emma: emma_v2.safetensors @ 0.85")
+ ```
+ Read project notes at the start of every session (or on every shot
+ for paranoia) to recover the lock across helper restarts and tab
+ reloads.
+3. **Apply on every render.** Pass the same LoRA on every
+ `submit_shot` for that character:
+ ```
+ "loras": [{{"name": "emma_v2.safetensors", "strength": 0.85}}]
+ ```
+ AND on every `generate_shot_images` call where Emma is in frame
+ (when the image engine supports it; today only some backends do —
+ if not supported, the still is still useful as composition input
+ but identity will lean on the video LoRA at render time).
+
+Two characters in one scene: pass BOTH LoRAs in the `loras` array,
+each at its own strength. Caveat — LoRA stacking quality drops above
+~2 stacked, and trigger-word collisions can blend identities. Surface
+the risk when the user asks for >2 character LoRAs at once.
+
+Strength tuning:
+- 0.85-1.0 — identity is locked, style of LoRA leaks slightly into
+ costume / lighting. Default for character ID LoRAs.
+- 0.6-0.8 — identity present but model has more freedom on costume /
+ framing. Good when the LoRA was trained on a narrow setting.
+- 0.5 or below — visible influence but easily overridden by the prompt.
+ Mostly useful for style LoRAs, not identity.
+
# Writing prompts FOR ANCHOR STILLS (Phase B)
When the user asks for **more variations of an already-generated shot**
diff --git a/agent/tools.py b/agent/tools.py
index 33e2a15..119591f 100644
--- a/agent/tools.py
+++ b/agent/tools.py
@@ -250,6 +250,15 @@ def _submit_shot(args: dict, ops: PanelOps, session: dict) -> dict:
ref_image_path: str — for i2v: absolute path to a previously-uploaded reference.
keyframes: list[dict] — for keyframe mode: [{image_path: str, frame_index: int}, ...]
≥2 items. Indices must be in [0, frames-1] and strictly increasing.
+ THREE OR MORE keyframes is the path to multi-shot character
+ continuity — see the system prompt's Character lock section.
+ loras: list[dict] — optional, works across ALL modes:
+ [{name: "filename.safetensors", strength: 0.8}, ...]
+ `name` must match a filename returned by list_loras().
+ Strength clamped to [-2.0, 2.0]. Common values: 0.7-1.0
+ for character-identity LoRAs; 0.5-0.8 for style LoRAs.
+ For character lock across a multi-shot scene, pass the
+ same LoRA on every submit_shot call (see system prompt).
source_clip: str — for extend mode: absolute path to source mp4.
extend_seconds: float = 2 — for extend: how much to add. Maps to extend_frames.
label: str — human-readable label visible in queue/history.
@@ -402,6 +411,67 @@ def _submit_shot(args: dict, ops: PanelOps, session: dict) -> dict:
form["keyframes_json"] = json.dumps(normalized)
form["keyframes_total_frames"] = str(target_frames)
+ # ---- Optional LoRAs (works across all modes) ------------------------
+ # Resolves filenames against installed LoRAs (so the agent can't apply
+ # something that isn't on disk), then emits the JSON shape the panel's
+ # parse_loras_from_form() consumes: [{path, strength}, ...].
+ #
+ # Character-lock workflow: agent reads the locked character LoRA from
+ # project notes on every shot and passes it here. See the system prompt's
+ # "Character lock via LoRA" section.
+ loras_in = args.get("loras")
+ if loras_in:
+ if not isinstance(loras_in, list):
+ raise _ToolValidationError(
+ "loras must be a list of {name, strength} dicts"
+ )
+ installed: dict[str, str] = {}
+ fn = getattr(ops, "list_loras_fn", None)
+ if fn is not None:
+ try:
+ for entry in (fn() or []):
+ fname = entry.get("filename")
+ fpath = entry.get("path")
+ if fname and fpath:
+ installed[fname] = fpath
+ except Exception as e: # noqa: BLE001
+ raise _ToolValidationError(
+ f"could not enumerate installed LoRAs: {e}"
+ ) from e
+ if not installed:
+ raise _ToolValidationError(
+ "loras requested but no LoRAs are installed in this panel. "
+ "Call list_loras() to confirm, or ask the user to install one "
+ "via Settings → LoRAs → Browse."
+ )
+ resolved: list[dict] = []
+ for item in loras_in:
+ if not isinstance(item, dict):
+ raise _ToolValidationError(
+ "each lora entry must be a dict {name, strength}"
+ )
+ name = (item.get("name") or "").strip()
+ if not name:
+ raise _ToolValidationError(
+ "each lora entry needs a 'name' (the filename returned by list_loras)"
+ )
+ if name not in installed:
+ avail = sorted(installed)[:5]
+ more = ", ..." if len(installed) > 5 else ""
+ raise _ToolValidationError(
+ f"LoRA {name!r} not installed. Available: {avail}{more}"
+ )
+ try:
+ strength = float(item.get("strength", 1.0))
+ except (TypeError, ValueError):
+ raise _ToolValidationError(
+ f"strength must be a number, got {item.get('strength')!r}"
+ )
+ strength = max(-2.0, min(2.0, strength))
+ resolved.append({"path": installed[name], "strength": strength})
+ if resolved:
+ form["loras"] = json.dumps(resolved)
+
# Sharp upscale path. Default: pipersr ON for balanced, off otherwise.
method = (args.get("upscale_method") or "").lower()
if not method: