Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(prompts): size the Ref2VA cap off measurement and bound its shot list
Lincoln Stein6ff785fdfba1
diff --git a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.pyindex 61377c29af..8b05b8911d 100644--- a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py+++ b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py@@ -41,7 +41,7 @@ One bullet per reference, tagged with how that reference is used:- `attribute_transfer` - only a named attribute is borrowed (motion, camera move, lighting, style, rhythm); say which.### detailed_description-The shot list. Open each shot with `[Shot 1]`, `[Shot 2]`, ... and describe, in the present tense, the camera movement, the subject action, the setting, and the lighting. Use a single shot unless the user asked for more.+The shot list. Open each shot with `[Shot 1]`, `[Shot 2]`, ... and describe, in the present tense, the camera movement, the subject action, the setting, and the lighting. Keep each shot to two to four sentences, and use a single shot unless the user asked for more.### overall_soundscapeThe diegetic sound — what is audible within the scene itself. Write `N/A` if the video should be silent.diff --git a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_09_add_system_prompt_max_tokens.py b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_09_add_system_prompt_max_tokens.pyindex 8243fecabc..da2d1f6228 100644--- a/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_09_add_system_prompt_max_tokens.py+++ b/invokeai/app/services/shared/sqlite_migrator/migrations/migration_2026_09_09_add_system_prompt_max_tokens.py@@ -3,7 +3,7 @@Expand Prompt asks the text LLM for at most ``EXPAND_PROMPT_MAX_TOKENS_DEFAULT`` (300) newtokens. That suits the one-paragraph rewrites the original seeded prompts produce, but truncatesprompts that are structurally longer by design -- the MiniMax H3 Ref2VA prompt emits six labelled-sections and routinely needs more.+sections and routinely needs three to five times as much.The cap therefore becomes a property of the system prompt: ``max_tokens`` is NULL for everyexisting row (meaning "use the default"), and is set to 500 for the Ref2VA prompt.@@ -16,8 +16,17 @@ from invokeai.app.services.shared.sqlite_migrator.migrations.migration_2026_09_0)from invokeai.app.services.shared.sqlite_migrator.sqlite_migrator_common import Migration-MINIMAX_H3_REF2VA_MAX_TOKENS = 500-"""Headroom for the six-section structured prompt, measured against the seeded example."""+MINIMAX_H3_REF2VA_MAX_TOKENS = 1000+"""Headroom for the six-section structured prompt.++Measured with the Qwen BPE tokenizer these models use, a realistic output costs roughly+75 tokens of fixed structure, +55 per reference (a `subject_definitions` bullet plus a+`retention_analysis` bullet) and +155 per shot, so three references and one shot land near 470+and five references with two shots near 745. The two audio sections come last and are cheap+(~45 combined), which is why a cap sized off the prompt's own terse worked example (187 tokens)+truncated them first. `max_new_tokens` is a safety stop rather than a target -- generation ends+at EOS -- so this is sized for the worst realistic request, not the median one.+"""class AddSystemPromptMaxTokensCallback:diff --git a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.pyindex 8b414b9142..44b925fbfb 100644--- a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py+++ b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_09_07_add_minimax_h3_ref2va_system_prompt.py@@ -73,6 +73,12 @@ def test_prompt_teaches_every_required_section() -> None:assert "[TO FILL]" in MINIMAX_H3_REF2VA_PROMPT_CONTENT+def test_the_shot_list_is_length_bounded() -> None:+ # detailed_description is the section that grows without limit, and it sits ahead of the two+ # audio sections -- unbounded, it crowds them out of the token budget entirely.+ assert "two to four sentences" in MINIMAX_H3_REF2VA_PROMPT_CONTENT++def test_migration_id_matches_its_module_name() -> None:assert build_migration().id == "2026_09_07_add_minimax_h3_ref2va_system_prompt"assert build_migration().depends_on == "2026_07_10_create_system_prompts"