[PR #3803] [MERGED] Suppress the reference-image prompt line for local SD backends (ComfyUI/A1111/Draw Things) #6109

Closed
opened 2026-10-23 04:07:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3803
Author: @kh0p
Created: 7/19/2026
Status: ✅ Merged
Merged: 7/19/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/suppress-reference-line-local-sd


📝 Commits (4)

  • 697ec11 Suppress the reference-image prompt line for local SD backends
  • 22dcc90 Merge branch 'staging' into fix/suppress-reference-line-local-sd
  • e0ce68e Merge branch 'staging' into fix/suppress-reference-line-local-sd
  • f746c6f fix: address reference prompt review feedback

📊 Changes

6 files changed (+143 additions, -32 deletions)

View changed files

📝 packages/server/src/routes/gallery.routes.ts (+11 -8)
📝 packages/server/src/routes/generate.routes.ts (+11 -8)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+11 -8)
📝 packages/server/src/services/generation/conversation-selfie-command-runtime.ts (+11 -8)
📝 packages/server/src/services/image/illustrator-references.ts (+65 -0)
📝 scripts/regressions/prompt.regression.ts (+34 -0)

📄 Description

Problem

When avatar references are attached, the engine appends a prose line to the image prompt:

"Attached are reference images of X. Use them only to preserve character likeness and visual identity; the written scene prompt is authoritative for…"

For ComfyUI / AUTOMATIC1111 / Draw Things connections the reference images travel out-of-band (ComfyUI upload endpoint / img2img payload), and the CLIP text encoder cannot act on an instruction sentence — it just tokenizes it. On tag-trained SDXL checkpoints (Pony/Illustrious) this costs ~40 of the strongest prompt tokens and measurably dilutes tag adherence, especially with CLIP's 77-token chunking.

NovelAI connections already suppress this line (isNovelAiImageConnection) for the same underlying reason: the provider consumes references natively, so the sentence is invisible to the model.

Change

  • New suppressesReferencePromptLine() in services/image/illustrator-references.ts — returns true for NovelAI (delegating to the existing predicate) and for local SD backends, detected via explicit imageService/imageGenerationSource ids (comfyui, automatic1111, drawthings) plus the default local ports (:8188, :7860) in the base URL, mirroring the style of the NovelAI check.
  • The four suppressReferencePromptLine call sites (generate route, retry-agents route, gallery route, selfie command runtime) use the new function instead of isNovelAiImageConnection directly.

isNovelAiImageConnection remains exported and unchanged.

Notes

  • No behavior change for cloud image providers (OpenAI, Stability, Together, …) — multimodal providers that can actually read the reference line keep receiving it.
  • Reference images are still attached exactly as before; only the prose sentence is dropped for backends that can't use it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved character reference handling for selfie and illustration image generation.
    • Reference-image prompt details are now adjusted more consistently across supported image-generation services.
    • Updated retry-based image generation to apply the same reference prompt behavior as standard generation flows.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3803 **Author:** [@kh0p](https://github.com/kh0p) **Created:** 7/19/2026 **Status:** ✅ Merged **Merged:** 7/19/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/suppress-reference-line-local-sd` --- ### 📝 Commits (4) - [`697ec11`](https://github.com/Pasta-Devs/Marinara-Engine/commit/697ec11704e447886bc611000b46acf6dd15a605) Suppress the reference-image prompt line for local SD backends - [`22dcc90`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22dcc90f87a315a5b3edc488bf866ed6abd0776a) Merge branch 'staging' into fix/suppress-reference-line-local-sd - [`e0ce68e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e0ce68e824bf0a2cc5baf787ec42dcee2a5c0991) Merge branch 'staging' into fix/suppress-reference-line-local-sd - [`f746c6f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f746c6fdc07e507d0be8a7d9194c74029428fd9f) fix: address reference prompt review feedback ### 📊 Changes **6 files changed** (+143 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/gallery.routes.ts` (+11 -8) 📝 `packages/server/src/routes/generate.routes.ts` (+11 -8) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+11 -8) 📝 `packages/server/src/services/generation/conversation-selfie-command-runtime.ts` (+11 -8) 📝 `packages/server/src/services/image/illustrator-references.ts` (+65 -0) 📝 `scripts/regressions/prompt.regression.ts` (+34 -0) </details> ### 📄 Description ## Problem When avatar references are attached, the engine appends a prose line to the image prompt: > "Attached are reference images of X. Use them only to preserve character likeness and visual identity; the written scene prompt is authoritative for…" For ComfyUI / AUTOMATIC1111 / Draw Things connections the reference images travel out-of-band (ComfyUI upload endpoint / img2img payload), and the CLIP text encoder cannot act on an instruction sentence — it just tokenizes it. On tag-trained SDXL checkpoints (Pony/Illustrious) this costs ~40 of the strongest prompt tokens and measurably dilutes tag adherence, especially with CLIP's 77-token chunking. NovelAI connections already suppress this line (`isNovelAiImageConnection`) for the same underlying reason: the provider consumes references natively, so the sentence is invisible to the model. ## Change - New `suppressesReferencePromptLine()` in `services/image/illustrator-references.ts` — returns true for NovelAI (delegating to the existing predicate) and for local SD backends, detected via explicit `imageService`/`imageGenerationSource` ids (`comfyui`, `automatic1111`, `drawthings`) plus the default local ports (`:8188`, `:7860`) in the base URL, mirroring the style of the NovelAI check. - The four `suppressReferencePromptLine` call sites (generate route, retry-agents route, gallery route, selfie command runtime) use the new function instead of `isNovelAiImageConnection` directly. `isNovelAiImageConnection` remains exported and unchanged. ## Notes - No behavior change for cloud image providers (OpenAI, Stability, Together, …) — multimodal providers that can actually read the reference line keep receiving it. - Reference *images* are still attached exactly as before; only the prose sentence is dropped for backends that can't use it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved character reference handling for selfie and illustration image generation. * Reference-image prompt details are now adjusted more consistently across supported image-generation services. * Updated retry-based image generation to apply the same reference prompt behavior as standard generation flows. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:07:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6109
No description provided.