From c2fea55704ea8e590f5d6b87eb6e1c65eb9ccf13 Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Wed, 22 Jul 2026 09:42:19 +0000 Subject: [PATCH] Revert "Remove character description global prompt prefixing" This reverts commit 5347ca3dbcf023478308c7c1bfe0327fc2ecf61e. --- ltx_director.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/ltx_director.py b/ltx_director.py index bc25c1e..8483426 100644 --- a/ltx_director.py +++ b/ltx_director.py @@ -375,6 +375,29 @@ def _character_prompt_replacements(characters: list[dict]) -> dict[str, str]: return replacements +def _prepend_referenced_character_descriptions( + global_prompt: str, + local_prompts: str, + characters: list[dict] | None = None, +) -> str: + prompt_text = f"{global_prompt or ''} {local_prompts or ''}" + descriptions = [] + for character, tags in zip(characters or [], _build_character_tag_groups(characters or [])): + description = (character.get("description", "") or "").strip() + if not description: + continue + if any(tag in prompt_text for tag in tags): + descriptions.append(description) + + 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 +2107,7 @@ class LTXDirector(io.ComfyNode): image_cache=image_cache, input_dir=input_dir, ) + global_prompt = _prepend_referenced_character_descriptions(global_prompt, local_prompts, 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]