会议模式:判断/while 不再"没连分支就顺走另一条"(走错路改成就地停下 + 报出来)

用户反馈:"判断为假为啥要写变量?为假时不是应该重新循环吗"

【真 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 的对拍用例,是下一步。
This commit is contained in:
l
2026-10-11 00:20:43 +08:00
parent c354ea8449
commit 7bef765a8d
2 changed files with 46 additions and 11 deletions

View File

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

View File

@@ -778,7 +778,22 @@ export async function runMeeting({ meeting, settings, userInput, emit, runAgentF
}); });
const outs = execOut(edges, nodeId); const outs = execOut(edges, nodeId);
nextIds = outs.filter((e) => (e.branch || 'true') === (passed ? 'true' : 'false')).map((e) => e.to); 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') { } else if (nodeType === 'end') {
outputs[nodeId] = String(node.text || '').trim() || input; outputs[nodeId] = String(node.text || '').trim() || input;
finalOutput = outputs[nodeId]; finalOutput = outputs[nodeId];