diff --git a/packages/services/conversation-service/src/infrastructure/agents/coordinator/coordinator-agent.service.ts b/packages/services/conversation-service/src/infrastructure/agents/coordinator/coordinator-agent.service.ts index 428dbf4..ea0de2f 100644 --- a/packages/services/conversation-service/src/infrastructure/agents/coordinator/coordinator-agent.service.ts +++ b/packages/services/conversation-service/src/infrastructure/agents/coordinator/coordinator-agent.service.ts @@ -449,13 +449,17 @@ export class CoordinatorAgentService implements OnModuleInit { ): Promise { const messages: ClaudeMessage[] = []; - // Convert previous messages + // Convert previous messages (use text placeholders for historical attachments to save tokens) if (context.previousMessages) { for (const msg of context.previousMessages) { if (msg.attachments?.length) { - const contentBlocks = await this.buildAttachmentBlocks(msg.attachments); - contentBlocks.push({ type: 'text', text: msg.content }); - messages.push({ role: msg.role, content: contentBlocks }); + const placeholders = msg.attachments.map( + (att) => `[用户上传了${att.type === 'image' ? '图片' : '文件'}: ${att.originalName}]`, + ); + messages.push({ + role: msg.role, + content: placeholders.join('\n') + '\n' + msg.content, + }); } else { messages.push({ role: msg.role, content: msg.content }); }