feat:修复执行过程编排中初始分支删除单个节点bug
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user