diff --git a/android/kernel/meeting.py b/android/kernel/meeting.py index e532847..2a30a23 100644 --- a/android/kernel/meeting.py +++ b/android/kernel/meeting.py @@ -1006,10 +1006,18 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str, else: done = [e['to'] for e in outs if (e.get('branch') or 'body') == 'done'] next_ids = done + # ★ 和判断节点同一个道理:**不在"结束"上就连"循环体"**, + # 那是要走错路的 —— 条件已经为假了还去跑循环体, + # 要么空转要么死循环,而且看不出为什么。 + # 停下 + 说清楚该补哪根线。 if not done and outs: - # 没连"结束"那条:顺走剩下的第一条,免得链断在这儿 - next_ids = [e['to'] for e in outs if e['to'] not in - [b for b in next_ids]][:1] + emit({ + 'type': 'node_warn', + 'nodeId': node_id, + 'warn': '循环条件是「假」、该走「结束」那条出线,' + '但你只连了「循环体」—— 执行链在这里停了。' + '把「结束」连到循环后面的节点上。', + }) if keep: continue @@ -1089,13 +1097,25 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str, # 判断节点走 true / false 两条 **exec** 出边; # 没标分支的那条当默认(true) outs = _exec_out(edges, node_id) - next_ids = [ - e['to'] for e in outs - if (e.get('branch') or 'true') == ('true' if passed else 'false') - ] - if not next_ids: - # 没连对应的分支就顺走第一条,免得执行链直接断在这儿 - next_ids = [e['to'] for e in outs][:1] + want = 'true' if passed else 'false' + next_ids = [e['to'] for e in outs if (e.get('branch') or 'true') == want] + # ★ 判成的那条分支没连线 → **就在这儿停**,不要顺走另一条。 + # + # 原来这里有个"兜底":没连就走第一条。结果判成「假」而用户只连了 + # 「真」时,执行流会**悄悄拐进真分支** —— 用户看到的是 + # "判断为假为啥要写变量?",图上明明是绿的(真)却按假的结果跑, + # 而且引擎不报错、链也没断,怎么查都查不出来。 + # + # 走错路比停下糟糕得多。停下 + 说清楚,用户一眼知道该补哪根线。 + if not next_ids and outs: + emit({ + 'type': 'node_warn', + 'nodeId': node_id, + 'warn': '判断结果是「' + ('真' if passed else '假') + + '」,但你没连' + ('真' if passed else '假') + + '分支的线 —— 执行链在这里停了。' + '要么补上那根线,要么改用另一条分支。', + }) elif node_type == 'end': outputs[node_id] = (node.get('text') or '').strip() or incoming diff --git a/server/src/meeting.mjs b/server/src/meeting.mjs index 7848f06..cf8453a 100644 --- a/server/src/meeting.mjs +++ b/server/src/meeting.mjs @@ -778,7 +778,22 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF }); const outs = execOut(edges, nodeId); nextIds = outs.filter((e) => (e.branch || 'true') === (passed ? 'true' : 'false')).map((e) => e.to); - if (!nextIds.length) nextIds = outs.slice(0, 1).map((e) => e.to); + // ★ 判成的那条分支没连线 → **就在这儿停**,不要顺走另一条。 + // + // 原来这里有个"兜底":没连就走第一条。结果判成「假」而用户只连了「真」时, + // 执行流会**悄悄拐进真分支** —— 用户看到的是"判断为假为啥要写变量?", + // 图上明明是绿的(真)却按假的结果跑,而且引擎不报错、链也没断,怎么查都查不出来。 + // + // 走错路比停下糟糕得多。停下 + 说清楚,用户一眼知道该补哪根线。 + if (!nextIds.length && outs.length) { + emit({ + type: 'node_warn', + nodeId, + warn: `判断结果是「${passed ? '真' : '假'}」,但你没连` + + `${passed ? '真' : '假'}分支的线 —— 执行链在这里停了。` + + '要么补上那根线,要么改用另一条分支。', + }); + } } else if (nodeType === 'end') { outputs[nodeId] = String(node.text || '').trim() || input; finalOutput = outputs[nodeId];