feat(workflow): 增加会话级多智能体任务规划运行能力
提交范围聚焦于工作流编排新增:新增 workflow_planning 路由与前后端运行入口(workflow_planning.py、workflow_proposal_planner.py、workflow_deep_research_adapter.py),支持基于会话的提案-规划-执行流程,满足任务驱动式多智能体协作。 完成网关层运行时适配:扩展 workflow_resource_checks、workflow_executor、workflow_runs、workflow_agent_runner 与依赖注入,新增/更新配置(config.yaml、workflow_config),并补充 lead_agent 路径与节点实现,确保 Planner 与普通工作流运行态衔接一致。 补齐持久化与建模:新增 workflow_planning 持久化模块与 MySQL migration(20260831_01_workflow_planning_sessions),注册 SQL 与模型、内存 store,并扩展错误/表达式/validator/节点语义以承载新会话态输入输出。 增强文档与测试:新增会话式多智能体编排中文说明、更新开发文档与 AGENTS 指南、补充 workflow_engine/workflow_runs 回归测试,提高新路径的行为可验证性;同时留存 seed 资产(workflow-planner)便于一体化部署。
This commit is contained in:
1 parent
ac92f29db1
commit
1706a24182
39 files changed
+4896
-81
No files matched your search
@@ -188,6 +188,7 @@ def validate_workflow_graph(
|
||||
)
|
||||
)
|
||||
|
||||
predecessors = _predecessors(graph)
|
||||
for node in graph.nodes:
|
||||
if node.type == "condition":
|
||||
branches = node.config.get("branches") or []
|
||||
@@ -234,6 +235,104 @@ def validate_workflow_graph(
|
||||
)
|
||||
)
|
||||
|
||||
if node.type == "evidence_normalizer":
|
||||
raw_sources = node.config.get("sources")
|
||||
if raw_sources is not None and not isinstance(raw_sources, list):
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="证据归一化节点的 sources 必须是数组",
|
||||
node_id=node.id,
|
||||
details={"field": "config.sources"},
|
||||
)
|
||||
)
|
||||
source_ids: list[str] = []
|
||||
if isinstance(raw_sources, list):
|
||||
for item in raw_sources:
|
||||
source_id = str(item.get("nodeId") or item.get("node_id") or "").strip() if isinstance(item, dict) else ""
|
||||
if not source_id:
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="证据归一化 sources 的每项都需要 nodeId",
|
||||
node_id=node.id,
|
||||
details={"field": "config.sources"},
|
||||
)
|
||||
)
|
||||
continue
|
||||
source_ids.append(source_id)
|
||||
else:
|
||||
source_ids = [edge.source for edge in graph.edges if edge.target == node.id]
|
||||
if not source_ids:
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="证据归一化节点至少需要一个上游研究节点",
|
||||
node_id=node.id,
|
||||
details={"field": "config.sources"},
|
||||
)
|
||||
)
|
||||
ancestors = _ancestors(node.id, predecessors)
|
||||
for source_id in source_ids:
|
||||
if source_id not in graph.node_map():
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_NODE_NOT_FOUND",
|
||||
message=f"证据归一化引用了不存在的节点: {source_id}",
|
||||
node_id=node.id,
|
||||
details={"referencedNodeId": source_id},
|
||||
)
|
||||
)
|
||||
elif source_id not in ancestors:
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_EXPRESSION_INVALID",
|
||||
message=f"证据归一化只能引用上游节点,{source_id} 不在 {node.id} 的上游",
|
||||
node_id=node.id,
|
||||
details={"referencedNodeId": source_id},
|
||||
)
|
||||
)
|
||||
|
||||
if node.type == "deep_research_write":
|
||||
raw_evidence = node.config.get("evidenceBinding") or node.config.get("evidence_binding")
|
||||
if raw_evidence is None:
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="深度研究写作节点必须绑定 Evidence Pack",
|
||||
node_id=node.id,
|
||||
details={"field": "config.evidenceBinding"},
|
||||
)
|
||||
)
|
||||
elif not isinstance(raw_evidence, (str, dict)):
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="深度研究写作节点的 Evidence Pack 绑定格式无效",
|
||||
node_id=node.id,
|
||||
details={"field": "config.evidenceBinding"},
|
||||
)
|
||||
)
|
||||
raw_config = node.config.get("researchConfig") or node.config.get("research_config") or {}
|
||||
if not isinstance(raw_config, dict):
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="深度研究写作节点的 researchConfig 必须是对象",
|
||||
node_id=node.id,
|
||||
details={"field": "config.researchConfig"},
|
||||
)
|
||||
)
|
||||
elif raw_config.get("mode") == "multi_agent":
|
||||
issues.append(
|
||||
ValidationIssue(
|
||||
code="WORKFLOW_SCHEMA_INVALID",
|
||||
message="深度研究写作节点暂不支持 multi_agent;请在工作流中显式使用 human_input 节点",
|
||||
node_id=node.id,
|
||||
details={"field": "config.researchConfig.mode"},
|
||||
)
|
||||
)
|
||||
|
||||
if resource_checker is not None:
|
||||
verdict = resource_checker(node.type, node.config or {})
|
||||
if verdict:
|
||||
|
||||
Reference in new issue
Block a user