会议模式:修复判断/while 结论不显示(node_done 没带 nodeType)+ 标题写上参数和状态
用户反馈"还是没有结果,节点标题要把运行状态、具体参数写出来"。
【根因:node_done 事件根本没带 nodeType】
在设备上直接跑了一遍,把事件流和落盘的运行记录对着看:
EV node_done j verdict=True branch='true' ← 结论有 ✓
STEP j nodeType=None verdict=True branch='true' ← 但 nodeType 是 None ✗
`node_start` 带 nodeType,`node_done` 没带。于是运行记录里每一步的
nodeType 都是空的,结果界面那个 `when (nodeType == "judge" && ...)`
一个分支都进不去 —— **标签代码是对的,数据没送到**。
(上一版我只改了历史记录的渲染,还以为是渲染条件的问题,其实卡在这儿。)
修:两份引擎的 node_done / node_error 都带上 nodeType。
【顺便按用户要求把标题写全】
用户原话:"节点标题要把运行状态、具体参数写出来"。
只写"判断"两个字的话,图上有五个判断节点就完全分不清是哪个、
更不知道它当时在判什么,回看运行记录等于白看。
现在每一步的标题是「节点名 · 第 N 轮 · 具体参数 → 运行状态」:
4 判断 · 第 1 轮 · 包含「苹果」 [判断:真]
8 while 循环 · 第 3 轮 [条件为真 → 继续循环]
3 写变量 · isRun = 2
9 智能体 · 第 1 轮 你好呀~我是豆包…
参数按节点类型取:
judge 包含「x」/ 不含「x」/ 字数 > n / 为空 / 不为空 / 让模型判断
var isRun = 2(写死的值)或 isRun ← 上游
readvar 变量名
value 那个常量
老记录里没存 nodeType 的,从图里按 id 找节点补上。
【实测(模拟器截图确认)】
7 判断 · 第 1 轮 · 为空 [判断:假]
8 while 循环 · 第 3 轮 [条件为真 · 继续循环]
9 智能体 · 第 1 轮 你好呀~我是豆包…
10 判断 · 第 1 轮 · 为空 [判断:假]
...
【顺带】
- exec 线中间的方向箭头也验证了:开始事件→判断 中间一个 ▶,走向一目了然
- 修掉一个重复:轮次同时进了标题和旁边,界面上出现"第 3 轮 第 3 轮"
【验证】
- 引擎回归 40/40,Node 与 Python 16/16 逐用例一致
- 会议 HTTP 13/13 ×2
- 模拟器实测:判断/while 的结论标签、标题参数全部正确显示
【另外发现(不是 bug,是演示图的问题)】
while 的循环体里如果"写变量"每次都把变量写回同一个值,条件永远为真,
会一直转到 MAX_LOOP_ITERS=200 才停。轮次上限兜住了,但图本身应该让条件收敛。
This commit is contained in:
@@ -945,7 +945,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
# 否则循环回来的内容会被起点覆盖掉,重复就没意义了
|
||||
text = incoming or (node.get('text') or '').strip() or (user_input or '')
|
||||
outputs[node_id] = text
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'output': text,
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': text,
|
||||
'run': run_index, 'note': '用的初始输入'})
|
||||
next_ids = [e['to'] for e in _exec_out(edges, node_id)]
|
||||
|
||||
@@ -965,7 +965,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
keep = False
|
||||
|
||||
outputs[node_id] = cond_text
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'output': cond_text,
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': cond_text,
|
||||
'run': run_index, 'verdict': keep,
|
||||
'branch': 'body' if keep else 'done',
|
||||
'note': (f'第 {used + 1} 轮:条件={cond_text[:30]!r} → '
|
||||
@@ -1023,7 +1023,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
# 压根覆盖不到(真发生过:引擎测试全绿,一上 HTTP 就漏出 [[SET]])。
|
||||
cleaned, changed = apply_sets(raw, variables, node.get('writeVars'))
|
||||
outputs[node_id] = cleaned
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'output': cleaned, 'run': run_index})
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': cleaned, 'run': run_index})
|
||||
if changed:
|
||||
# 改了哪些变量要让用户看见,不然就是"背地里改了我的东西"
|
||||
emit({'type': 'node_vars', 'nodeId': node_id, 'vars': changed,
|
||||
@@ -1064,7 +1064,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
raise ValueError('读变量节点没填变量名')
|
||||
value = variables.get(name, '')
|
||||
outputs[node_id] = value
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'output': value, 'run': run_index,
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': value, 'run': run_index,
|
||||
'note': f'读到 {name}' + ('' if value else '(还没设过,是空的)')})
|
||||
next_ids = [e['to'] for e in _exec_out(edges, node_id)]
|
||||
|
||||
@@ -1080,7 +1080,7 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
# 这个错误是验证脚本抓到的(输出是"真 收到[true]")。
|
||||
# 判断结论走 verdict 字段,不占 output。
|
||||
outputs[node_id] = incoming
|
||||
emit({'type': 'node_done', 'nodeId': node_id,
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type,
|
||||
'output': incoming,
|
||||
'run': run_index,
|
||||
'verdict': passed,
|
||||
@@ -1100,16 +1100,16 @@ def run_meeting(*, meeting: dict, settings: dict, user_input: str,
|
||||
elif node_type == 'end':
|
||||
outputs[node_id] = (node.get('text') or '').strip() or incoming
|
||||
final_output = outputs[node_id]
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'output': final_output, 'run': run_index})
|
||||
emit({'type': 'node_done', 'nodeId': node_id, 'nodeType': node_type, 'output': final_output, 'run': run_index})
|
||||
next_ids = []
|
||||
|
||||
else:
|
||||
emit({'type': 'node_error', 'nodeId': node_id, 'error': f'不认识的节点类型:{node_type}'})
|
||||
emit({'type': 'node_error', 'nodeId': node_id, 'nodeType': node_type, 'error': f'不认识的节点类型:{node_type}'})
|
||||
next_ids = []
|
||||
|
||||
except Exception as exc: # noqa: BLE001
|
||||
# 单个节点出错不该让整场会议停摆:记下来,继续跑下游
|
||||
emit({'type': 'node_error', 'nodeId': node_id, 'error': str(exc), 'run': run_index})
|
||||
emit({'type': 'node_error', 'nodeId': node_id, 'nodeType': node_type, 'error': str(exc), 'run': run_index})
|
||||
outputs[node_id] = ''
|
||||
next_ids = [e['to'] for e in _exec_out(edges, node_id)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user