fix: workflow engine reads node config from both "data" and "config" keys

Nodes created via some paths store configuration under "config" instead of
"data", causing agent/LLM/orchestrator nodes to run with default settings
(gpt-4o-mini/openai instead of the configured model). This caused 橙子 agent
scheduled tasks to fail with "节点 node-agent-1 执行失败: 未知错误".

Add normalize at execute_node entry + fallback reads in agent/LLM/orchestrator
handlers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
renjianbo
2026-05-07 23:32:34 +08:00
parent f30997c02a
commit 0220be27e3

View File

@@ -1347,7 +1347,11 @@ class WorkflowEngine:
node_type = node.get('type', 'unknown')
node_id = node.get('id')
start_time = time.time()
# 兼容处理:部分节点将配置存储在 "config" 而非 "data" 字段
if 'config' in node and 'data' not in node:
node['data'] = node['config']
# 记录节点开始执行
if self.logger:
self.logger.log_node_start(node_id, node_type, input_data)
@@ -1429,7 +1433,7 @@ class WorkflowEngine:
node_id=node_id,
)
# LLM节点调用AI模型
node_data = node.get('data', {})
node_data = node.get('data') or node.get('config', {})
logger.debug(f"[rjb] LLM节点执行: node_id={node_id}, input_data={input_data}, input_data type={type(input_data)}")
logger.debug(f"[rjb] LLM节点数据: node_id={node_id}, node_data keys={list(node_data.keys())}, api_key={'已配置' if node_data.get('api_key') else '未配置'}")
prompt = node_data.get('prompt', '')
@@ -1938,7 +1942,7 @@ class WorkflowEngine:
)
result = await run_agent_node(
node_data=node.get("data", {}),
node_data=node.get("data") or node.get("config", {}),
input_data=input_data,
execution_logger=self.logger,
user_id=self.trusted_model_config_user_id,
@@ -1957,7 +1961,7 @@ class WorkflowEngine:
return result
except Exception as e:
# fallback_agent 降级:主 Agent 失败时尝试备用 Agent
node_data = node.get("data", {}) or {}
node_data = node.get("data") or node.get("config", {}) or {}
fallback_agent_id = node_data.get("fallback_agent", "")
if fallback_agent_id and str(fallback_agent_id) != str(node_data.get("agent_id", "")):
if self.logger:
@@ -2021,7 +2025,7 @@ class WorkflowEngine:
)
result = await run_orchestrator_node(
node_data=node.get("data", {}),
node_data=node.get("data") or node.get("config", {}),
input_data=input_data,
execution_logger=self.logger,
user_id=self.trusted_model_config_user_id,