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:
董宏凯 committed 2026-09-01 11:47:30 +08:00
1 parent ac92f29db1
commit 1706a24182
39 files changed
+4896 -81

No files matched your search

@@ -183,6 +183,68 @@ skills endpoint returns `skillId`, direct-call capability, and `createdBy`. Crea
from the immutable owner id at read time (falling back to the id if an account was removed), while
built-in resources explicitly return `系统内置`.
### Conversation-driven workflow planning
The Workflow Studio chat composer does not silently start a template. A normal user
message first creates a durable planning session with
`POST /api/workflows/{workflow_id}/planning-sessions/stream` (SSE; the legacy
non-streaming `POST /api/workflows/{workflow_id}/planning-sessions` remains for
integrations). The stream relays safe DeerFlow controller milestones—catalog read,
controller parsing, role selection, graph assembly and validation—before returning
the final session, so the UI never has to fabricate a progress bar. The constrained planner builds
two or three validated candidate graphs from the current draft and the visible business
agents the user can use. It is a dedicated built-in **工作流总控** (`workflow-planner`),
not the multi-agent roundtable coordinator: it only reads the user requirement and
catalog metadata, selects permitted agent ids, and ranks the supported strategies. It
does not dispatch a roundtable, use research tools, or execute a formal run. The server
constructs the executable graph from those selected, visible resources; a controller
failure returns an explicit planning error rather than a keyword/template fallback. The
controller call has no callable tools and disables model thinking, so it adds one bounded
planning inference without starting research or worker-agent costs. A
browser selects one candidate, automatically applies the editor's DAG layout when
it loads, then may explicitly save an edited graph through
`PATCH /api/workflows/planning-sessions/{session_id}/proposals/{proposal_id}/graph`,
then creates the one formal run through the existing
`POST /api/workflows/{workflow_id}/runs` endpoint with `planningSessionId` and
`proposalId`. The gateway rejects unselected or invalid candidates and makes a repeated
confirmation return the already-created run, so a double click cannot execute a second
workflow. Planning sessions are persisted separately from runs (migration
`20260831_01`); their parent row is flushed before candidate rows so the foreign-key
transaction works consistently across SQLite, MySQL, and PostgreSQL. A candidate is
not consuming execution resources until it is confirmed.
The development Studio proxy must not gzip `/api` responses: compressed SSE can hold
small planning and run-event frames until the response ends. The backend already marks
both streams `no-transform` and `X-Accel-Buffering: no`; `apps/coze-studio` also sets
its Rsbuild development server `compress: false`. Agent/skill nodes use the bounded
`workflows.agent_recursion_limit` (default `250`), rather than a chat-sized 60-step
limit, because a model-to-tool research turn consumes about two LangGraph super-steps.
The current planner is deliberately constrained: it can rank supported strategies and
focus resources, but the server builds the graph from the already configured agent
nodes. It cannot invent a node type, external target, or credential from chat text.
For a parallel-research candidate, the configured research agents first flow into the
deterministic `evidence_normalizer` node. It emits a bounded Evidence Pack with the
originating node, role label, explicit gaps, and no invented verification claim before
the synthesis agent sees it. The candidate then runs `deep_research_write`: its
app-layer adapter converts exactly that Evidence Pack into selected, provenance-tagged
Deep Research source rows, starts or reattaches to the existing durable Deep Research
job, forwards report deltas as workflow `node.output.delta` events, and exposes the
final Markdown as a run artifact. Cancellation is forwarded to the same research job;
the node never calls the Deep Research HTTP API or launches a second writer. The
session key includes the topic, evidence snapshot and writing configuration, so a retry
reuses the same job while a changed upstream pack cannot return stale report prose. `multi_agent` Deep Research is
intentionally not nested yet because its separate plan-review pause would conflict
with workflow `human_input`. A completed `agent` or `skill` node in a terminal,
acyclic run can now receive targeted feedback through
`POST /api/workflows/runs/{run_id}/feedback`: the original remains immutable, a
revision run reuses completed nodes outside the target's downstream closure, and
only the target prompt receives the bounded feedback block before it and its
downstream nodes stream again. The public revision run retains the affected and
reused node ids in its feedback summary for the conversation/history UI. Running and looped workflows deliberately continue
to use `human_input` or a new full run; they are not modified in place. See
`docs/WORKFLOW_CONVERSATIONAL_MULTI_AGENT_ORCHESTRATION_ZH.md` for the roadmap.
### Deep Research modes
Deep Research is a separate Gateway feature rather than part of AI Writing. Its