From a1a1184155671bcfdddf5b7347df2bf09ce807cd Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Mon, 20 Jul 2026 14:20:46 +0000 Subject: [PATCH] Prepend character descriptions to global prompt --- ltx_director.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ltx_director.py b/ltx_director.py index 48fcbec..6d9fb10 100644 --- a/ltx_director.py +++ b/ltx_director.py @@ -373,8 +373,23 @@ def _character_prompt_replacements(characters: list[dict]) -> dict[str, str]: for tag in tags: replacements[tag] = replacement return replacements - - + + +def _prepend_character_descriptions(global_prompt: str, characters: list[dict] | None = None) -> str: + descriptions = [ + (character.get("description", "") or "").strip() + for character in (characters or []) + if (character.get("description", "") or "").strip() + ] + if not descriptions: + return global_prompt or "" + + prefix = ". ".join(descriptions) + if not (global_prompt or "").strip(): + return prefix + return f"{prefix}. {global_prompt.strip()}" + + def _preprocess_prompts_with_characters(global_prompt, local_prompts, characters: list[dict] | None = None): """Invisibly swaps out @characterN/@charN/@alias tags with their character descriptions.""" if "@" not in (global_prompt or "") and "@" not in (local_prompts or ""): @@ -2084,6 +2099,7 @@ class LTXDirector(io.ComfyNode): image_cache=image_cache, input_dir=input_dir, ) + global_prompt = _prepend_character_descriptions(global_prompt, characters) char_slot_images = [list(character.get("images") or []) for character in characters] char_images = [img for slot_images in char_slot_images for img in slot_images]