From 7bef765a8d98d068cbe0f776a00413c4444d9b1f Mon Sep 17 00:00:00 2001 From: l Date: Sun, 11 Oct 2026 00:20:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AE=AE=E6=A8=A1=E5=BC=8F=EF=BC=9A?= =?UTF-8?q?=E5=88=A4=E6=96=AD/while=20=E4=B8=8D=E5=86=8D"=E6=B2=A1?= =?UTF-8?q?=E8=BF=9E=E5=88=86=E6=94=AF=E5=B0=B1=E9=A1=BA=E8=B5=B0=E5=8F=A6?= =?UTF-8?q?=E4=B8=80=E6=9D=A1"=EF=BC=88=E8=B5=B0=E9=94=99=E8=B7=AF?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=B0=B1=E5=9C=B0=E5=81=9C=E4=B8=8B=20+=20?= =?UTF-8?q?=E6=8A=A5=E5=87=BA=E6=9D=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈:"判断为假为啥要写变量?为假时不是应该重新循环吗" 【真 bug:分支没连就悄悄走另一条】 判断节点里原来有这么一段"兜底": next_ids = [判成的那条分支] if not next_ids: next_ids = [e['to'] for e in outs][:1] # ← 没连就顺走第一条 用户只连了「真」分支。判成「假」时"假"没线,这段兜底就**顺走了真分支** —— 于是执行流拐进了写变量。用户看到的是: 4 判断 · 为空 [判断:假] 5 写变量 · r = 0 ← 判成假却走了真分支 而且**引擎不报错、链也没断**,图上明明连的是绿线(真),却按假的结果跑, 怎么查都查不出来。 **走错路比停下糟糕得多。** 现在改成:判成的那条分支没连线 → **就地停下**, 并发一条警告说清楚该补哪根线: 判断结果是「假」,但你没连假分支的线 —— 执行链在这里停了。 要么补上那根线,要么改用另一条分支。 while 节点有一模一样的兜底(条件为假却没连「结束」时,会顺走「循环体」—— 那是空转甚至死循环),一起改成停下 + 警告。 【实测】 只有「真」分支连线、内容判成假时: exec: ['ev', 'j'] 判断: False / false ⚠ 判断结果是「假」,但你没连假分支的线 —— 执行链在这里停了。 真分支跑了吗: False ← 不再悄悄走真分支 【验证】 - 引擎回归 40/40,Node 与 Python 16/16 逐用例一致 - 会议 HTTP 13/13 ×2、语音 41/41、Markdown 19/19 【欠账(记一下,免得忘)】 Node 侧引擎**还没有 while 节点** —— 所以对拍用例覆盖不到 while, 上面那个 while 兜底的修复只有 Python 侧生效(App 用的是 Python 侧,不影响使用)。 补 while 的 Node 镜像 + 加 while 的对拍用例,是下一步。 --- android/kernel/meeting.py | 40 +++++++++++++++++++++++++++++---------- server/src/meeting.mjs | 17 ++++++++++++++++- 2 files changed, 46 insertions(+), 11 deletions(-) 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];