-
Notifications
You must be signed in to change notification settings - Fork 7
支持循环与条件控制流 #95
Copy link
Copy link
Open
Labels
area:backendBackend / Python / FastAPI relatedBackend / Python / FastAPI relatedarea:docsDocumentation, guides, and contributor docsDocumentation, guides, and contributor docsarea:frontendFrontend / React / UI relatedFrontend / React / UI relatedstatus:backlogValid and recorded, but not currently scheduledValid and recorded, but not currently scheduledtype:researchTechnical investigation or feasibility research before implementation scope is knownTechnical investigation or feasibility research before implementation scope is known
Milestone
Metadata
Metadata
Assignees
Labels
area:backendBackend / Python / FastAPI relatedBackend / Python / FastAPI relatedarea:docsDocumentation, guides, and contributor docsDocumentation, guides, and contributor docsarea:frontendFrontend / React / UI relatedFrontend / React / UI relatedstatus:backlogValid and recorded, but not currently scheduledValid and recorded, but not currently scheduledtype:researchTechnical investigation or feasibility research before implementation scope is knownTechnical investigation or feasibility research before implementation scope is known
Discussed in #79
Originally posted by keting May 1, 2026
背景
当前流程模版只能描述静态 DAG:一组任务、每个任务的 assignee、depends_on 和 expected_output。用户在创建项目时选择模版,系统把模版一次性展开为 final plan 和 tasks。
但有一类常见协作流程更像运行时循环,例如:
也就是:实现 -> 评审 -> 如果不通过则修改 -> 再评审,直到通过。
问题
目前流程模版不支持这种结构。需要讨论:
当前架构判断
现有架构不能直接支持真正的 while/if 流程,主要原因:
因此当前只能表达固定轮数的流程,例如:
但不能表达“评审不通过就继续追加下一轮修改和评审”。
可选方案
方案 A:固定展开 N 轮
在现有 DAG 模型内,把循环预展开成有限轮数。
优点:实现成本最低,现有架构可直接支持。
缺点:不是真正的循环;如果第一轮通过,后续任务仍然存在,需要人工放弃或不派发。
方案 B:结构化评审结果 + 人工决策门
约定评审任务 result.json 输出类似:
{ "task_code": "REVIEW-001", "summary": "评审完成", "decision": "approved", "review_comments": [] }系统展示 decision,由负责人点击“结束流程”或“创建下一轮修改任务”。
优点:符合 HALF human-in-the-loop 定位,不需要一步到位做全自动工作流引擎。
缺点:需要新增 result schema、UI 展示、以及从评审结果创建下一轮任务的机制。
方案 C:真正的 workflow engine
引入新的 workflow template / workflow run 模型,支持 task node、condition node、loop edge、max_iterations 等。
优点:表达能力完整。
缺点:改动大,会影响数据模型、状态机、任务码生成、输出目录、审计、UI 和现有 plan/task 关系。它已经超出当前静态流程模版的能力边界。
初步建议
不建议直接在当前流程模版 JSON 里增加 while/if 语法。
更稳妥的路径可能是:
需要讨论