diff --git a/packages/services/conversation-service/src/infrastructure/agents/tools/coordinator-tools.ts b/packages/services/conversation-service/src/infrastructure/agents/tools/coordinator-tools.ts index 1d7f491..28f0e93 100644 --- a/packages/services/conversation-service/src/infrastructure/agents/tools/coordinator-tools.ts +++ b/packages/services/conversation-service/src/infrastructure/agents/tools/coordinator-tools.ts @@ -298,23 +298,24 @@ export const DIRECT_TOOLS: ToolDefinition[] = [ name: 'save_user_memory', description: '直接保存用户信息到长期记忆。' + - '用于保存关键信息,无需启动完整的记忆管理 Agent。', + '用于保存关键信息,无需启动完整的记忆管理 Agent。' + + 'userId 不需要传,系统自动获取。', input_schema: { type: 'object', properties: { - userId: { type: 'string', description: '用户 ID' }, memoryType: { type: 'string', enum: ['FACT', 'PREFERENCE', 'INTENT'], - description: '记忆类型', + description: '记忆类型:FACT-用户事实,PREFERENCE-偏好,INTENT-意图', }, - content: { type: 'string', description: '记忆内容' }, - importance: { - type: 'number', - description: '重要程度 1-10', + content: { type: 'string', description: '要记住的内容' }, + category: { + type: 'string', + enum: ['QMAS', 'GEP', 'IANG', 'TTPS', 'CIES', 'TECHTAS'], + description: '相关移民类别(可选)', }, }, - required: ['userId', 'memoryType', 'content'], + required: ['memoryType', 'content'], }, isConcurrencySafe: false, }, @@ -346,20 +347,28 @@ export const DIRECT_TOOLS: ToolDefinition[] = [ { name: 'generate_payment', description: - '生成支付链接。仅在用户明确表示要付费或预约服务时使用。', + '生成支付二维码。仅在用户明确表示要付费或预约服务时使用。' + + '需要确认用户选择的服务类别和支付方式后调用。', input_schema: { type: 'object', properties: { - userId: { type: 'string', description: '用户 ID' }, serviceType: { type: 'string', - enum: ['assessment', 'consultation', 'full_service'], + enum: ['ASSESSMENT', 'CONSULTATION', 'DOCUMENT_REVIEW'], description: '服务类型', }, - amount: { type: 'number', description: '金额(HKD)' }, - description: { type: 'string', description: '服务描述' }, + category: { + type: 'string', + enum: ['QMAS', 'GEP', 'IANG', 'TTPS', 'CIES', 'TECHTAS'], + description: '移民类别', + }, + paymentMethod: { + type: 'string', + enum: ['ALIPAY', 'WECHAT', 'CREDIT_CARD'], + description: '支付方式(支付宝、微信、信用卡)', + }, }, - required: ['userId', 'serviceType'], + required: ['serviceType', 'category', 'paymentMethod'], }, isConcurrencySafe: false, }, diff --git a/packages/services/conversation-service/src/infrastructure/claude/tools/immigration-tools.service.ts b/packages/services/conversation-service/src/infrastructure/claude/tools/immigration-tools.service.ts index d489fd9..0236840 100644 --- a/packages/services/conversation-service/src/infrastructure/claude/tools/immigration-tools.service.ts +++ b/packages/services/conversation-service/src/infrastructure/claude/tools/immigration-tools.service.ts @@ -427,7 +427,8 @@ export class ImmigrationToolsService { * Check if question is off-topic - 调用 knowledge-service API */ private async checkOffTopic(input: Record): Promise { - const { question } = input as { question: string }; + // coordinator-tools.ts sends `query`, legacy getTools() sent `question` + const question = (input.query as string) || (input.question as string) || ''; console.log(`[Tool:check_off_topic] Checking: "${question}"`); @@ -456,19 +457,22 @@ export class ImmigrationToolsService { input: Record, context: ConversationContext, ): Promise { - const info = input as { - category: string; - age?: number; - education?: string; - university?: string; - yearsOfExperience?: number; - currentJobTitle?: string; - industry?: string; - annualIncome?: number; - hasHKEmployer?: boolean; - }; + // coordinator-tools.ts sends { userId, field, value } (single-field mode) + // Legacy getTools() sent { category, age, education, ... } (batch mode) + // Support both formats + let info: Record; - console.log(`[Tool:collect_assessment_info] User ${context.userId} - Category: ${info.category}`); + if (input.field && input.value) { + // Single-field mode from coordinator-tools.ts + info = { [input.field as string]: input.value }; + } else { + // Batch mode from legacy getTools() + const { userId: _userId, ...rest } = input; + info = rest; + } + + const category = (info.category as string) || ''; + console.log(`[Tool:collect_assessment_info] User ${context.userId} - Fields: ${Object.keys(info).join(', ')}`); // 保存收集到的信息到用户记忆 const memoryContent = Object.entries(info) @@ -482,7 +486,7 @@ export class ImmigrationToolsService { memoryType: 'FACT', content: `用户评估信息 - ${memoryContent}`, sourceConversationId: context.conversationId, - relatedCategory: info.category, + relatedCategory: category, importance: 80, }); }