Skip to content

Commit 27c22ea

Browse files
committed
修复: 并行调用子代理时全量显示最终结果
问题: 当并行调用子代理时,子代理的最终回复无法全量显示在UI中。 原因: useConversation.ts 中处理子代理消息的回调函数只处理了 tool_calls、tool_result、content 和 done 类型的消息, 但未处理 subagent_result 类型的消息。该类型消息由子代理 执行完成后发送,用于显示最终完整结果。 修复: 在子代理消息处理逻辑中添加对 subagent_result 类型的处理, 将子代理的完整结果以 subagent-result 角色添加到消息列表中, 确保UI能正确渲染并全量展示子代理的最终回复。 测试: 并行调用两个子代理(agent_general 和 agent_explore), 验证两者都能正确全量显示其最终回复。
1 parent 5eafaba commit 27c22ea

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- 现在项目已经实现了子代理的回复结果的全量显示
2+
但似乎当并行调用子代理(并行调用子代理和其他工具)时
3+
不会全量显示子代理的最终回复
4+
先调研下
5+
需求是 子代理的回复都是全量展示的 -->
6+
7+
已完成

source/hooks/conversation/useConversation.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,24 @@ async function executeWithInternalRetry(
11581158
return prev;
11591159
}
11601160

1161+
// Handle subagent_result - display full result
1162+
if (subAgentMessage.message.type === 'subagent_result') {
1163+
const resultMsg = subAgentMessage.message as any;
1164+
const uiMsg = {
1165+
role: 'subagent-result' as const,
1166+
content: resultMsg.content || '',
1167+
streaming: false,
1168+
subAgentResult: {
1169+
agentType: resultMsg.agentType || 'general',
1170+
originalContent: resultMsg.originalContent,
1171+
timestamp: resultMsg.timestamp || Date.now(),
1172+
status: resultMsg.status || 'success',
1173+
},
1174+
subAgentInternal: true,
1175+
};
1176+
return [...prev, uiMsg];
1177+
}
1178+
11611179
// Check if we already have a message for this agent
11621180
const existingIndex = prev.findIndex(
11631181
m =>

0 commit comments

Comments
 (0)