From 6592e727585c70d6b1995d8531f68c86243fae7e Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 7 Feb 2026 02:06:08 -0800 Subject: [PATCH] fix(agents): filter out internal strategy notes from followUp output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The model was putting internal notes like "引导回移民话题" in the followUp field instead of actual user-facing questions. Two fixes: 1. Schema: describe followUp as "必须以?结尾,禁止填写内部策略备注" 2. agent-loop: only yield followUp if it contains ?or ? (question mark) Co-Authored-By: Claude Opus 4.6 --- .../src/infrastructure/agents/coordinator/agent-loop.ts | 3 ++- .../agents/schemas/coordinator-response.schema.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/services/conversation-service/src/infrastructure/agents/coordinator/agent-loop.ts b/packages/services/conversation-service/src/infrastructure/agents/coordinator/agent-loop.ts index c9c2ba6..7add432 100644 --- a/packages/services/conversation-service/src/infrastructure/agents/coordinator/agent-loop.ts +++ b/packages/services/conversation-service/src/infrastructure/agents/coordinator/agent-loop.ts @@ -346,7 +346,8 @@ export async function* agentLoop( yield { type: 'text', content: answer, timestamp: Date.now() }; - if (parsed.followUp) { + // followUp 必须是面向用户的问题(含?),过滤掉内部策略备注 + if (parsed.followUp && /?|\?/.test(parsed.followUp)) { const followUp = smartTruncate(parsed.followUp, MAX_FOLLOWUP_LENGTH); yield { type: 'text', content: '\n\n' + followUp, timestamp: Date.now() }; } diff --git a/packages/services/conversation-service/src/infrastructure/agents/schemas/coordinator-response.schema.ts b/packages/services/conversation-service/src/infrastructure/agents/schemas/coordinator-response.schema.ts index bb7887a..8b06d5b 100644 --- a/packages/services/conversation-service/src/infrastructure/agents/schemas/coordinator-response.schema.ts +++ b/packages/services/conversation-service/src/infrastructure/agents/schemas/coordinator-response.schema.ts @@ -18,7 +18,7 @@ export const CoordinatorResponseSchema = z.object({ 'casual_chat', // 闲聊/打招呼:"你好" ]), answer: z.string().describe('直接回答用户的文本,简洁精准,默认100字以内'), - followUp: z.string().optional().describe('跟进引导问题(可选)'), + followUp: z.string().optional().describe('直接对用户提出的跟进问题(必须以?结尾,必须是用户能看到的自然语言问题,禁止填写内部策略备注)'), }); export type CoordinatorResponse = z.infer;