fix(orchestrator): 修复多轮对话 3 个问题#254
Conversation
1. executor: 修复 task index 始终为 -1 导致前端无法更新状态 2. decomposer: 修复 LLM 未返回 task id 时为空的问题 3. handler: 修复 BlockSummary 信息缺失 + 添加消息持久化 - executor.go: sendTaskStartEvent/EndEvent 传入正确的 index - decomposer.go: parseTaskPlan 自动生成 task ID,fallbackPlan 添加默认 ID - handler.go: 添加 assistantContent 收集 + CompleteBlock 持久化 + 修复事件类型 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 添加 "answer" 和 "aggregation" 事件类型收集 - 修复 success_count=0 和 FinalResponse 为空的问题 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 将 EventWithMeta 的 Meta 信息序列化为 JSON 一起转发 - 修复前端显示 "unknown" 的问题(因为缺少 tool_name) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- expert_registry: 发送 JSON 格式 {"data": "...", "meta": {...}}
- handler: 解析 JSON 并设置 EventMeta 字段
- 修复 ToolCallsSection 显示 "unknown" 的问题
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 后端: 改进 JSON 格式事件处理,正确传递 tool_name/tool_id - 前端: 解析 JSON 格式事件内容,提取 metadata - 统计: 添加 ToolsUsed 跟踪和成本计算 - UI: 简化工具调用显示,修复表格样式 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
问题:tool_result 事件无法匹配到对应的 tool_use 事件,导致前端 extractToolCalls 无法找到结果,工具卡片一直显示"等待中"状态。 原因:Claude Code CLI 的 tool_result 块使用 tool_use_id 字段 (而非 id)来引用对应的 tool_use。 修复: - ContentBlock 结构添加 ToolUseID 字段 - case "user" 分支使用 tool_use_id 进行匹配 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code reviewFound 2 issues:
The divinesense/ai/agents/runner/runner.go Lines 849 to 858 in a432cc2
When divinesense/server/router/api/v1/ai/handler.go Lines 693 to 700 in a432cc2 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
1. runner.go: case "tool_result" 分支使用 ToolUseID 匹配工具调用 - 与 case "user" 分支保持一致 - 优先使用 ToolUseID,回退到 ID 2. handler.go: 添加工具事件持久化失败的警告日志 - 当 currentBlock 或 blockManager 为 nil 时记录警告 - 帮助诊断前端 "pending" 状态问题 Refs #254 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
修复 Orchestrator 模式多轮对话的 3 个问题:
Tool 面板显示 "unknown 等待中"
executor.go中sendTaskStartEvent/EndEvent始终传index: -1的问题decomposer.go中 LLM 未返回 task id 时为空的问题blockSummary 面板信息缺失
TotalDurationMs使用 token 数量而非实际耗时ToolCallCount、ToolsUsed、Status等字段Orchestrator 未持久化消息
assistantContent收集 AI 回复内容CompleteBlock持久化到数据库Changes
Test plan
Resolves #251
🤖 Generated with Claude Code