SuperAPI AI 工具集

choosing-swarm-patterns

智能体与模型

查看项目

更新于 10-15 16:42

技能介绍

用途:当需要用 Agent Relay 的工作流引擎(@relayflows/core)协调多个 AI 智能体、又不确定该选哪种编排模式时,这份资料提供选择指南,覆盖 10 个核心模式及 14 个角色驱动模式。

主要能力:所有模式通过单一 swarm.pattern 字段声明,无独立的 fanOut(...) 等辅助函数。核心模式包括 fan-out(并行工作、枢纽汇总)、pipeline(线性链)、hub-spoke(枢纽与辐条双向协作)、consensus(全互联投票)、mesh(全对等协作)、handoff(顺序交接)、cascade(按能力递进的成本优化链)、dag(按 dependsOn 构图、可并行)、debate(对抗式全互联)、hierarchical(当前实现与 hub-spoke 边结构相同)。另有 map-reduce、scatter-gather、supervisor、reflection、red-team、verifier、auction、escalation、saga、circuit-breaker、blackboard、swarm、competitive、review-loop 等角色驱动模式。

使用方式:支持 YAML(runWorkflow('workflows/feature-dev.yaml', { vars: {...} }))与编程式 workflow() 流式构建器(.pattern()、.channel()、.agent()、.step({ dependsOn })),两者都走同一个 WorkflowRunner。步骤可用 verification 检查完成信号(output_contains、exit_code、file_exists、custom)。支持 resume 与 startFrom/previousRunId 复用缓存输出。反思通过 trajectories 块配置(如 reflectOnConverge)。

限制:hierarchical 目前实际是单层 hub,多级树未实现;consensusStrategy 不执行计票,只影响协调器自动选择;cascade 无跳过逻辑,上游失败会跳过下游;reflectOnBarriers 配置存在但运行时不调用;YAML 校验要求显式写 swarm.pattern,自动选择仅限编程 API;interactive: false 的智能体无 relay 连接,不能调用 MCP 工具。MCP 工具为扁平名称(send_dm、check_inbox、list_agents、post_message、reply_to_thread、add_agent、remove_agent)。资料中价格、费用等信息暂未提供。