From 1768413eca710e925cee66a15c074eacd709ab20 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 26 Mar 2026 00:31:42 +0800 Subject: [PATCH] fix agent model identity guardrails --- app/(chat)/api/chat/route.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/(chat)/api/chat/route.ts b/app/(chat)/api/chat/route.ts index 7ce898814..5a17b32a5 100644 --- a/app/(chat)/api/chat/route.ts +++ b/app/(chat)/api/chat/route.ts @@ -3195,6 +3195,20 @@ function buildAgentSceneImageRolePrompt(params: { ? `如果当前场景有人物展示需求,只允许使用图片${resolvedProductCount + 1}里的模特;如果不需要人物,则不要强行加入人物。` : "当前没有固定模特图,不要凭空生成强人物主体。" ); + if (hasModelImage) { + lines.push( + "【模特锁定约束】固定模特图是人物身份锁定图。结果中出现的人物必须与模特图为同一人,不得换脸、换人、换性别、换年龄段,不得改变五官特征、脸型、发际线、发型主体、肤色、身材和辨识度。" + ); + lines.push( + "允许根据场景构图调整模特的站姿、坐姿、手势、视线和轻微表情,但必须让人一眼看出是同一个模特。" + ); + lines.push( + "只有当工作流设定或补充要求里明确要求修改模特衣服、穿搭或服装颜色时,才允许更换或调整服饰;如果没有明确要求,默认保持模特原有服装风格和穿搭关系一致。" + ); + lines.push( + "如果模特衣服被允许调整,也只能改衣服,不得借机改变模特本人;人物身份稳定性始终高于服装变化。" + ); + } return lines.join("\n"); } @@ -7316,6 +7330,27 @@ export async function POST(request: Request) { modeType: "scene_generation", }); const sceneGenerationStartedAt = Date.now(); + console.info("[Chat API] Agent scene prompt guardrails:", { + chatId: id, + agentPresetId: selectedAgentPreset.id, + agentPresetName: selectedAgentPreset.name, + agentExecutionSnapshotId: presetSnapshot.id, + includesWorkflowPrompt: Boolean(hiddenPromptText), + includesUserSupplementPrompt: Boolean(sanitizedUserSupplementPrompt), + includesModelImage: sceneModelSlotEnabled, + productImageCount: sceneProductSlotCount, + uploadedImageCount: sharedUploadedImageUrls.length, + hasProductIdentityLock: sceneImageRolePrompt.includes("【产品锁定约束】"), + hasModelIdentityLock: sceneImageRolePrompt.includes("【模特锁定约束】"), + hasModelClothingOverrideRule: sceneImageRolePrompt.includes( + "只有当工作流设定或补充要求里明确要求修改模特衣服" + ), + imageRolePreview: sceneImageRolePrompt + .split("\n") + .map((line) => line.trim()) + .filter(Boolean) + .slice(0, 12), + }); try { const mergedImageParams = {