From ada29cee1204efbf41c5ffb34ef0e6f69ab1fe7b Mon Sep 17 00:00:00 2001 From: liangxu Date: Wed, 8 Jul 2026 16:18:11 +0800 Subject: [PATCH] refactor(agent): make emoji optional and sparse in agent replies Loosen the creative agent guidance so emoji are used only as sparse category markers rather than forced on every list item, and tighten the frontend emoji section-break normalization to only split before short labelled headings. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/ui/components/MarkdownContent/index.tsx | 2 +- .../infrastructure/piagent/creative_agent.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/ui/components/MarkdownContent/index.tsx b/frontend/src/ui/components/MarkdownContent/index.tsx index e3b94ae..a70043f 100644 --- a/frontend/src/ui/components/MarkdownContent/index.tsx +++ b/frontend/src/ui/components/MarkdownContent/index.tsx @@ -41,7 +41,7 @@ export function MarkdownContent({ content, streaming = false }: { content: strin } function normalizeEmojiSectionBreaks(content: string) { - return content.replace(/([^\s\n])\s*((?:[\p{Extended_Pictographic}\p{Emoji_Presentation}]\uFE0F?(?:\u200D[\p{Extended_Pictographic}\p{Emoji_Presentation}]\uFE0F?)*)+)(?=[\p{L}\p{N}])/gu, "$1\n$2"); + return content.replace(/([^\s\n])[ \t]*((?:[\p{Extended_Pictographic}\p{Emoji_Presentation}]\uFE0F?(?:\u200D[\p{Extended_Pictographic}\p{Emoji_Presentation}]\uFE0F?)*)+(?=[^\s\n]{1,12}[::]))/gu, "$1\n$2"); } function parseMarkdownBlocks(content: string) { diff --git a/server/internal/infrastructure/piagent/creative_agent.go b/server/internal/infrastructure/piagent/creative_agent.go index e50721e..1f0f628 100644 --- a/server/internal/infrastructure/piagent/creative_agent.go +++ b/server/internal/infrastructure/piagent/creative_agent.go @@ -94,8 +94,8 @@ func (c *CreativeAgent) Respond(ctx context.Context, req design.AgentConversatio "For greetings, reply briefly and invite a concrete next step. For capability questions, answer with image-only capabilities: brand/site visuals, ecommerce product images, posters/banners/social images, reference-based generation, image edits, background removal, vectorization, mockup placement, and multi-round canvas iteration.", "When a current project exists, connect capabilities to the canvas instead of giving a generic product brochure.", "When the task plan indicates missing requirements or contains user response questions, ask those questions directly and stop; do not pretend generation has started.", - "Use a few purposeful emoji in visible replies to make scanning warmer: put a relevant emoji at the start of capability or next-step bullets, for example šŸŽØ design direction, šŸ“¦ packaging, šŸ–¼ļø canvas. Keep the tone professional and avoid empty bullet labels such as '• :'.", - "Format emoji lists as short separate lines: intro sentence, then one emoji-led item per line, for example šŸŽ­č§’č‰²č®¾å®šć€\\nšŸ“¦ē³»åˆ—åŒ…č£…ć€\\nšŸ§©å±•ē¤ŗå°/蓓纸、\\nšŸ“£å‘å”®ęµ·ęŠ„ć€‚ Do not put a hyphen after the emoji. Do not chain items like šŸŽØ-设讔...-ē”Ÿęˆ..., do not start continuation lines with bare hyphens, and never end with empty choices such as 1. 2. 3.", + "Emoji are optional. Use them only when they improve scanning, especially as sparse category markers in capability or next-step replies, for example šŸŽØ å›¾ē‰‡ē”ŸęˆäøŽē¼–č¾‘, šŸ–¼ļø ē”»åøƒčæ­ä»£, šŸ” å‚č€ƒę”¶é›†, āŒ äøåœØčŒƒå›“å†….", + "When an emoji introduces a category or list item, start that emoji-led marker on its own line. Do not force every item into emoji lines, do not insert emoji inside dense prose, do not stack several emoji in one sentence, do not put a hyphen after emoji, and never end with empty choices such as 1. 2. 3.", }, " "), }, { @@ -118,8 +118,8 @@ func (c *CreativeAgent) StreamRespond(ctx context.Context, req design.AgentConve "For greetings, reply briefly and invite a concrete next step. For capability questions, answer with image-only capabilities: brand/site visuals, ecommerce product images, posters/banners/social images, reference-based generation, image edits, background removal, vectorization, mockup placement, and multi-round canvas iteration.", "When a current project exists, connect capabilities to the canvas instead of giving a generic product brochure.", "When the task plan indicates missing requirements or contains user response questions, ask those questions directly and stop; do not pretend generation has started.", - "Use a few purposeful emoji in visible replies to make scanning warmer: put a relevant emoji at the start of capability or next-step bullets, for example šŸŽØ design direction, šŸ“¦ packaging, šŸ–¼ļø canvas. Keep the tone professional and avoid empty bullet labels such as '• :'.", - "Format emoji lists as short separate lines: intro sentence, then one emoji-led item per line, for example šŸŽ­č§’č‰²č®¾å®šć€\\nšŸ“¦ē³»åˆ—åŒ…č£…ć€\\nšŸ§©å±•ē¤ŗå°/蓓纸、\\nšŸ“£å‘å”®ęµ·ęŠ„ć€‚ Do not put a hyphen after the emoji. Do not chain items like šŸŽØ-设讔...-ē”Ÿęˆ..., do not start continuation lines with bare hyphens, and never end with empty choices such as 1. 2. 3.", + "Emoji are optional. Use them only when they improve scanning, especially as sparse category markers in capability or next-step replies, for example šŸŽØ å›¾ē‰‡ē”ŸęˆäøŽē¼–č¾‘, šŸ–¼ļø ē”»åøƒčæ­ä»£, šŸ” å‚č€ƒę”¶é›†, āŒ äøåœØčŒƒå›“å†….", + "When an emoji introduces a category or list item, start that emoji-led marker on its own line. Do not force every item into emoji lines, do not insert emoji inside dense prose, do not stack several emoji in one sentence, do not put a hyphen after emoji, and never end with empty choices such as 1. 2. 3.", }, " "), }, { @@ -139,7 +139,7 @@ func (c *CreativeAgent) StreamPlanNarration(ctx context.Context, req design.Agen "Write one concise localized sentence that tells the user what the agent is preparing to do next.", "If web research results are present, mention that references have been collected and how they will guide the visual direction.", "Do not use markdown, numbering, or generic canned wording. Use the user's language and locale automatically.", - "A single fitting emoji at the beginning is welcome when it improves the live status; do not overuse emoji.", + "Emoji are optional in live status text. Use one only when it makes a short status clearer; otherwise write plain prose.", }, " "), }, { @@ -180,7 +180,7 @@ func (c *CreativeAgent) PlanAgentTask(ctx context.Context, req design.AgentTaskP "Image tasks must be concrete, ordered, and aligned with the count. For character/design work, separate views, detail sheets, palette/style sheets, and final composite boards when requested.", "Do not expose hidden chain-of-thought. The userFacingResponse is a short planning summary, not a long explanation.", "If intent is chat for clarification, userFacingResponse should be the exact concise questions to ask and imageCount must be 0.", - "For userFacingResponse, use a few purposeful emoji in visible questions or summaries, especially as list markers. Use newline-separated emoji items, for example šŸŽ­č§’č‰²č®¾å®šć€\\nšŸ“¦ē³»åˆ—åŒ…č£…ć€\\nšŸ§©å±•ē¤ŗå°/蓓纸、\\nšŸ“£å‘å”®ęµ·ęŠ„ć€‚ Do not put a hyphen after the emoji, do not chain items like šŸŽØ-设讔...-ē”Ÿęˆ..., do not use bare continuation hyphens, and never output empty numbered choices such as 1. 2. 3. Do not put emoji in image task titles or briefs.", + "For userFacingResponse, emoji are optional. Use them only as sparse category/list markers when they help scan multi-part questions or summaries, following the style šŸŽØ å›¾ē‰‡ē”ŸęˆäøŽē¼–č¾‘, šŸ–¼ļø ē”»åøƒčæ­ä»£, šŸ” å‚č€ƒę”¶é›†, āŒ äøåœØčŒƒå›“å†…. If an emoji-led marker is used, start it on a new line; otherwise write plain prose. Do not force emoji into every item, do not chain several emoji inline, do not put a hyphen after emoji, and never output empty numbered choices such as 1. 2. 3. Do not put emoji in image task titles or briefs.", "Use the user's language and locale automatically.", }, " "), }, @@ -241,7 +241,7 @@ func (c *CreativeAgent) SummarizeImage(ctx context.Context, req design.AgentImag "Do not invent exact visual details you cannot see. Tie the response to the prompt and canvas goal.", "When the user authorized your judgment or asked for an iteration, state the main change you attempted and what constraint it preserves. Mention a next step only when it is useful or required by the workflow.", "Sound like a professional art director, not a template.", - "Use one fitting emoji or a short emoji-led phrase when it improves the completion message; keep it sparse.", + "Emoji are optional. Use one sparse emoji-led phrase only when it improves the completion message; otherwise write plain prose.", }, " "), }, {