feat:修复执行过程编排中初始分支删除单个节点bug

This commit is contained in:
liailing1026
2026-03-16 14:37:14 +08:00
parent f411dc0e20
commit a4b94f43c1
3 changed files with 354 additions and 22 deletions

View File

@@ -2807,14 +2807,39 @@ def handle_delete_task_process_node(data):
nodes = branch.get('nodes', [])
tasks = branch.get('tasks', [])
# 找到删除节点
for i, node in enumerate(nodes):
# 找到删除节点
node_to_delete = None
for node in nodes:
if node.get('id') == node_id:
nodes.pop(i)
if i < len(tasks):
tasks.pop(i)
node_to_delete = node
break
if node_to_delete:
# 从 nodes 中删除
nodes = [n for n in nodes if n.get('id') != node_id]
# 从 tasks 中删除:使用 originalIndex 精确匹配
# nodes 包含 root 节点,所以 agent 节点的 originalIndex 对应 tasks 的索引
node_data = node_to_delete.get('data', {})
original_index = node_data.get('originalIndex')
if original_index is not None and 0 <= original_index < len(tasks):
tasks.pop(original_index)
else:
# 降级方案:使用 agentName + actionType 匹配
agent_name = node_data.get('agentName')
action_type_key = node_data.get('actionTypeKey', '').lower()
action_type_map = {
'propose': 'Propose',
'review': 'Critique',
'improve': 'Improve',
'summary': 'Finalize'
}
target_action_type = action_type_map.get(action_type_key, action_type_key)
tasks = [t for t in tasks
if not (t.get('AgentName') == agent_name
and t.get('ActionType') == target_action_type)]
# 更新分支数据(包括 nodes, tasks, edges
branch['nodes'] = nodes
branch['tasks'] = tasks