tasks.md 2.83 KB

1. 统一消息入口实现 (Steward Agent)

  • 1.1 定义消息入口 POST /api/v1/chat/completions 的请求参数结构:
    • session_id (string, required): 会话唯一标识
    • user_id (string, required): 企微员工 ID
    • channel (string, required): 渠道来源(如 wechat_group)
    • query (string, required): 用户对话内容
    • mentioned_agent_code (string, optional): 被@的 Agent 编码
    • file_url (string, optional): 关联的文件地址
  • 1.2 实现路由决策树逻辑(Mention > Inheritance > Default)
    • Mention: 检查 mentioned_agent_code,直接路由至该 Agent,routing_reason="mention"
    • Inheritance: 无@且会话中存在 current_agent_id,路由至该 Agent,routing_reason="inheritance"
    • Default: 路由至管家 Agent(code="steward"),routing_reason="default"
  • 1.3 集成 LLM 意图识别服务,返回标准意图
    • 当前实现: InMemoryLLMClient(关键词匹配),LLMClient Protocol 可替换为真实 LLM
    • Mention 路由跳过意图识别(优化延迟),仅 Inheritance 和 Default 路径调用 LLM
  • 1.4 实现响应体结构封装,包含 routing, intent, handoff, response_content 等字段
    • routing: agent_id, agent_code, agent_name, routing_reason
    • handoff: from_agent_id/name, to_agent_id/name, handoff_message(自动生成转交话术)

2. 多模态文件处理

  • 2.1 定义文件上传接口 POST /api/v1/files/upload (multipart/form-data):
    • file (binary, required): 文件对象
    • session_id (string, required): 关联会话 ID
    • 支持格式: pdf, png, jpg, jpeg, doc, docx, xls, xlsx
    • 大小限制: 10MB
  • 2.2 集成 OSS 上传功能(OSSClient Protocol + InMemoryOSSClient 占位实现)
  • 2.3 集成 OCR/文本提取服务(FileParser Protocol + InMemoryFileParser 占位实现)
    • PDF/Word/Excel 文件自动调用文本提取
    • 图片文件仅上传不提取
  • 2.4 将提取出的文本关联至会话上下文实体中(待与 SessionService 集成)

3. 辅助功能与联调

  • 3.1 实现 Agent 切换时的转交话术自动生成逻辑
    • 当 prev_agent_id 与 target_agent.id 不同时,自动生成 "收到,已转交给{agent_name}处理。"
    • 首次消息无 prev_agent_id,不生成 handoff
  • 3.2 异步记录对话路由日志及处理耗时埋点(待日志基础设施就绪)
  • 3.3 编写路由逻辑的单元测试,覆盖各种优先级场景(17 个测试用例)
  • 3.4 模拟多模态输入,验证文件解析到意图识别的完整链路(FileService 4 个测试)

基础设施抽象层(可替换为真实实现)

  • LLMClient Protocol + InMemoryLLMClient(关键词匹配意图识别)
  • OSSClient Protocol + InMemoryOSSClient(内存文件存储)
  • FileParser Protocol + InMemoryFileParser(可注入 OCR 结果)