From 5f54531f754a218162e32c32b49846e60e9928b8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Mar 2026 14:16:31 +0800 Subject: [PATCH] fix agent scene preset prompt merge --- app/(chat)/api/chat/route.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/(chat)/api/chat/route.ts b/app/(chat)/api/chat/route.ts index 5a17b32a5..27e938219 100644 --- a/app/(chat)/api/chat/route.ts +++ b/app/(chat)/api/chat/route.ts @@ -3115,6 +3115,7 @@ function buildAgentSlotPrompt(params: { function buildAgentSceneWorkflowPrompt(params: { workflowPrompt?: string | null; + slotPrompt?: string | null; userSupplementPrompt?: string | null; imageRolePrompt?: string | null; }) { @@ -3123,6 +3124,10 @@ function buildAgentSceneWorkflowPrompt(params: { if (workflowPrompt) { lines.push(workflowPrompt); } + const slotPrompt = String(params.slotPrompt || "").trim(); + if (slotPrompt) { + lines.push(slotPrompt); + } const imageRolePrompt = String(params.imageRolePrompt || "").trim(); if (imageRolePrompt) { lines.push(imageRolePrompt); @@ -7316,9 +7321,17 @@ export async function POST(request: Request) { productImageCount: sceneProductSlotCount, includeModelImage: sceneModelSlotEnabled, }); + const rawSceneSlotPrompt = + sceneSlot?.promptTemplate || selectedAgentPreset.promptTemplate || ""; + const dedupedSceneSlotPrompt = dedupeAgentSlotPromptAgainstWorkflow({ + workflowPrompt: hiddenPromptText || null, + slotPrompt: rawSceneSlotPrompt, + modeType: "scene_generation", + }); const scenePrompt = buildAgentSceneWorkflowPrompt({ workflowPrompt: hiddenPromptText || null, + slotPrompt: dedupedSceneSlotPrompt || null, imageRolePrompt: sceneImageRolePrompt, userSupplementPrompt: sanitizedUserSupplementPrompt || null, }) || @@ -7338,6 +7351,7 @@ export async function POST(request: Request) { includesWorkflowPrompt: Boolean(hiddenPromptText), includesUserSupplementPrompt: Boolean(sanitizedUserSupplementPrompt), includesModelImage: sceneModelSlotEnabled, + includesSceneSlotPrompt: Boolean(dedupedSceneSlotPrompt), productImageCount: sceneProductSlotCount, uploadedImageCount: sharedUploadedImageUrls.length, hasProductIdentityLock: sceneImageRolePrompt.includes("【产品锁定约束】"), @@ -7345,6 +7359,11 @@ export async function POST(request: Request) { hasModelClothingOverrideRule: sceneImageRolePrompt.includes( "只有当工作流设定或补充要求里明确要求修改模特衣服" ), + sceneSlotPromptPreview: dedupedSceneSlotPrompt + .split("\n") + .map((line) => line.trim()) + .filter(Boolean) + .slice(0, 10), imageRolePreview: sceneImageRolePrompt .split("\n") .map((line) => line.trim())