Force <image1> on every Qwen Edit PE rewrite.

PE-I2I no longer bans tags for single-still edits, and the runner rewrites natural photo/image wording to <image1> so Start still stays bound.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-26 15:04:04 -05:00
co-authored by Cursor
parent a51118d92a
commit c46e827c68
4 changed files with 18 additions and 6 deletions
+11 -4
View File
@@ -15,12 +15,19 @@ export function ensureQwen21EditPrompt(prompt) {
}
/**
* After PE-I2I: if the rewrite dropped every <imageN> token, stitch the
* keep-identity line onto the rewrite (do not discard the rewrite).
* After PE-I2I: official PE told N=1 not to use tags, so rewrites often say
* "the photo" / "the image" with zero <image1>. Qwen Edit only binds Start still
* when the text contains the tag — force it onto every Edit rewrite.
*/
export function stitchQwen21PeEditPrompt(rewritten) {
const text = String(rewritten || '').trim()
let text = String(rewritten || '').trim()
if (!text) return text
if (/<image\d+>/i.test(text)) return text
// Prefer the tag over natural substitutes (do not invent <image2>).
text = text
.replace(/\bthe woman in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in <image1>')
.replace(/\bthe (?:person|man|subject) in the (?:input )?(?:photo|picture|image)\b/gi, 'the person in <image1>')
.replace(/\bin the (?:input )?(?:photo|picture|image)\b/gi, 'in <image1>')
.replace(/\bthe (?:input )?(?:photo|picture|image)\b/gi, '<image1>')
if (/<image1>/i.test(text)) return text
return `${QWEN21_EDIT_KEEP} ${text}`.trim()
}