Claude Code Dynamic Workflows 新的agent执行模式
Workflow 与 Agent SDK(Python/TypeScript)的关系:何时用 Agent SDK 自行编排、何时用 workflow?:workflow 可达 1000 agent/run,单次 run token 消耗显著高于 conversation,文档仅给出"meaningfully more tokens"定性描述。(包括"无 CLI 命令/配置 API"、"workfl
Claude Code Dynamic Workflows 是 Anthropic 于 2026 年 5 月 28 日通过 Claude Code v2.1.154 首次发布的 research preview 特性,由工程师 ashwin-ant 引入。
其本质是 Claude 编写、运行时执行的 JavaScript 脚本,可在后台编排数十至数百个 subagent(硬上限 1000 / 并发 16)。
关键判断:Workflows 不替代 subagents——它编排 subagents。研发团队的合理定位是"补充"而非"替换"现有 subagent/agent team 栈。
一、起源与版本信息
| 项目 | 值 |
|---|---|
| 首发版本 | Claude Code v2.1.154 |
| 发布日期 | 2026 年 5 月 28 日 18:00 |
| 引入作者 | Anthropic 工程师 ashwin-ant |
| 状态 | research preview |
| 关键字变更 | v2.1.160 (2026-06-02) 将触发关键字从 workflow 重命名为 ultracode |
官方 release notes 原文:
"Introducing dynamic workflows: ask Claude to create a workflow and it orchestrates work across tens to hundreds of agents in the background"
来源:
二、可用性与配置方法
平台覆盖
| 项目 | 详情 |
|---|---|
| 最低版本 | v2.1.154+ |
| 付费方案 | Pro / Max / Team / Enterprise(仅付费) |
| Provider | Anthropic API、Amazon Bedrock、Google Cloud Vertex AI、Microsoft Foundry |
启用方式
-
Pro 用户:必须在
/config的Dynamic workflows行手动开启 -
Max/Team/Enterprise:默认可用
-
组织级禁用:
-
managed settings 中
disableWorkflows: true -
环境变量
CLAUDE_CODE_DISABLE_WORKFLOWS=1
-
机器可读元数据
plan-availability: feature=workflows plans=pro,max,team,enterprise providers=all
来源:
三、用法 — 触发与保存
三种触发方式
-
运行 bundled workflow:例如
/deep-research <question> -
Prompt 关键字:
-
关键字
ultracode(v2.1.160 前为workflow) -
自然语言:"use a workflow"
-
-
自动规划:
/effort ultracode让 Claude 为每个 substantive 任务自动规划 workflow(结合 xhigh reasoning)
保存与复用
-
运行后在
/workflows视图按s保存 -
保存路径:
-
项目级:
.claude/workflows/ -
用户级:
~/.claude/workflows/
-
-
支持通过
args参数传入结构化数据
v2.1.160 release notes 原文:
"Renamed the dynamic-workflow trigger keyword from
workflowtoultracode. The word workflow no longer triggers a run; asking for one in your own words still works."
来源:
四、运行时硬限制
| 约束 | 数值/规则 |
|---|---|
| 单次 run agent 上限 | 1000 |
| 最大并发 agent | 16(低 CPU 机器更少) |
| 用户中间输入 | 不接受(仅 agent permission prompt 可暂停) |
| 脚本本身能力 | 无文件系统/shell 访问权限 |
| Subagent permission | 始终以 acceptEdits 模式运行,继承用户 tool allowlist(不受会话 permission mode 影响) |
| Resume 范围 | 同一 Claude Code 会话内有效。退出后下次重启 fresh 运行 |
文档原文:
"Resume works within the same Claude Code session. If you exit Claude Code while a workflow is running, the next session starts the workflow fresh."
来源:Orchestrate subagents at scale with dynamic workflows - Claude Code Docs
五、与 Subagent / Skill / Agent Team 的核心架构差异
官方对比表
| 维度 | Subagent / Skill | Agent Team | Dynamic Workflow |
|---|---|---|---|
| 谁决定下一步 | Claude 逐 turn 判断 | Lead agent 逐 turn 判断 | 脚本驱动 |
| 中间结果存放 | Claude 的 context window | 共享任务列表 | 脚本变量 |
| 可复用对象 | worker 定义 | team 定义 | 编排本身 |
| 规模 | 每 turn 少量委派 | 少量长期 peer | 每次 run 数十至数百 agent |
| 中断处理 | 重启 turn | teammate 继续运行 | 同会话内可 resume |
配套散文(官方文档)
"A workflow moves the plan into code... A workflow script holds the loop, the branching, and the intermediate results itself, so Claude's context holds only the final answer."
质量模式差异化能力
Workflow 可作为 repeatable quality pattern 实现脚本驱动的对抗性交叉验证:
"Moving the plan into code also lets a workflow apply a repeatable quality pattern... it can have independent agents adversarially review each other's findings before they're reported."
bundled workflow /deep-research 即采用此模式:
"votes on each claim, and returns a cited report with claims that didn't survive cross-checking filtered out."
这一 script-driven verification 机制是与 agent team "lead 逐 turn 判断的辩论" 的根本区别。
来源:
-
Orchestrate subagents at scale with dynamic workflows - Claude Code Docs
-
Orchestrate teams of Claude Code sessions - Claude Code Docs
六、Subagent 能力边界
| 特性 | 说明 |
|---|---|
| 运行范围 | 单一 session 内 |
| 嵌套 | 不能 spawn 其他 subagent(防止 infinite nesting) |
| 通信 | 只能向调用者报告,互不通信 |
| Fork subagent | v2.1.117 引入,v2.1.161 起默认启用 |
Fork subagent 特性:
"A fork is a subagent that inherits the entire conversation so far instead of starting fresh... its first request reuses the parent's prompt cache."
继承完整 parent 对话上下文并共享 prompt cache,比 fresh spawn 更便宜。
来源:Create custom subagents - Claude Code Docs
七、Agent Team 能力边界
| 项目 | 详情 |
|---|---|
| 最低版本 | v2.1.32+ |
| 状态 | Experimental,默认禁用 |
| 启用方式 | CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1(settings.json 或环境变量) |
| 已知限制 | session resumption、task coordination、shutdown behavior |
架构组件
-
Task list:共享任务列表
-
Mailbox:teammate 间直接消息通信
与 subagent 对照
| 维度 | Subagent | Agent Team |
|---|---|---|
| Communication | Report results back to the main agent only | Teammates message each other directly |
| Context window | 单一 | 各自独立 |
| 用户交互 | 通过 main | 可绕过 lead 直接对话 teammate |
警告(官方):
"Agent teams are experimental and disabled by default... Agent teams have known limitations around session resumption, task coordination, and shutdown behavior."
来源:
八、Agent View(监控层)
| 项目 | 详情 |
|---|---|
| 最低版本 | v2.1.139+ |
| 状态 | research preview |
| 架构 | 每个 background session 是独立完整的 Claude Code 进程,由 per-user supervisor 管理 |
| 与 subagent 关系 | subagent 和 teammate 不会作为单独行显示——它们是 session 内派生的 worker |
| 自定义 dispatch | 通过 @<agent-name> 或 --agent flag(v2.1.157 加入)将自定义 subagent dispatch 为 background session 的 main agent |
| 工作目录 | session 派生的 subagent 继承 session 的 worktree |
定位:Agent view 是"编排 subagent"而非"替代 subagent"。
来源:Manage multiple agents with agent view - Claude Code Docs
九、适用场景与替换可行性判断
官方推荐场景
"Reach for a workflow when a task needs more agents than one conversation can coordinate, or when you want the orchestration codified as a script you can read and rerun."
具体举例:
-
代码库范围 bug sweep
-
500 文件迁移
-
需要跨源交叉验证的研究问题
-
需从多个独立角度起草的硬 plan
成本警示
"A workflow spawns many agents, so a single run can use meaningfully more tokens than working through the same task in conversation."
文档仅给出定性描述,无具体倍率 benchmark 数据。本次调研单次 run 消耗 3.46M token / 100 agent,可作粗略参考。
替换可行性结论
Workflow ≠ 替代品。官方文档将四种 primitive 并列于 "Related resources: Run agents in parallel":
-
Subagent
-
Agent View
-
Agent Team
-
Workflow
研发团队建议:
-
✅ 增量补充:用于单会话无法编排的大规模任务
-
❌ 完全替换:常规多步任务仍以 subagent/skill 为主,peer 协作仍用 agent team
-
⚠️ 试跑评估:先小切片试跑评估 token 成本
来源:
十、Caveats(重要警告)
-
时间敏感性高:Dynamic Workflows(v2.1.154)、Agent View(v2.1.139)均处于
research preview,接口/键位/配置项可能随版本变更。v2.1.160 已发生过关键字破坏性更名(workflow→ultracode),团队若依赖应锁定版本并跟踪 release notes。 -
替换可行性边界:官方文档将四种 primitive 并列定位,未推荐将 subagent 或 agent team 迁移到 workflow。
-
Agent Team 仍 experimental(disabled by default + 已知限制),生产环境采用前需评估稳定性风险。
-
9 条声明在 adversarial verification 中被 refuted(包括"无 CLI 命令/配置 API"、"workflow 完全替代 subagent"等臆测性 claim),表明该领域存在大量误解,团队需以官方 primary doc 为准。
-
成本不确定:workflow 可达 1000 agent/run,单次 run token 消耗显著高于 conversation,文档仅给出"meaningfully more tokens"定性描述。
十一、待解开放问题
-
Dynamic Workflows 是否计划从 research preview 转为 GA?时间线?API 稳定性承诺?
-
Workflow 脚本的 JavaScript 运行时具体支持哪些 Node.js API/npm 包?沙箱隔离强度?是否支持引入第三方依赖?
-
企业级生产环境中,workflow 的多用户并发、审计日志、成本归属、与 CI/CD 集成(如非交互模式
claude -p+ workflow)的最佳实践与已知限制? -
Workflow 与 Agent SDK(Python/TypeScript)的关系:何时用 Agent SDK 自行编排、何时用 workflow?两者在可观测性、可测试性、可版本化方面的 tradeoff?
十二、被驳回的 Claim(参考价值)
以下 claim 在 3-vote adversarial verification 中被 refuted,不应作为决策依据:
| Claim | Vote | 来源 |
|---|---|---|
| Dynamic Workflows 仅由自然语言 prompt 触发,无专门 CLI 命令、YAML/JSON 配置语法或 API | 0-3 | release notes |
/workflows 是 Dynamic Workflows 的唯一管理接口,无配置/监控/编排 API |
0-2 | release notes |
| Dynamic Workflows was first introduced in v2.1.154 (released May 28, 2025) | 0-3 | release notes(年份错) |
纠正:实际发布日期为 2026 年 5 月 28 日(与今日 2026/06/08 一致)。
十三、来源清单(共 18 个,均为 primary 或 secondary)
Primary(官方文档/release)
-
Orchestrate subagents at scale with dynamic workflows - Claude Code Docs
-
Orchestrate teams of Claude Code sessions - Claude Code Docs
-
Building a C compiler with a team of parallel Claudes \ Anthropic
Secondary
更多推荐


所有评论(0)