
ruflo-autopilot 自动驾驶协调器实战指南基于 /loop 与 MCP 的自主任务完成循环【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/ruflo导读autopilot-coordinator是 ruflo 生态中用于驱动自主任务完成循环autonomous task completion loop的 Agent 角色。它把 Claude Code 原生的/loop与ScheduleWakeup调度能力同 ruflo-autopilot 插件的 10 个autopilot_*MCP 工具组合在一起形成启用 → 配置 → 检查进度 → 预测下一步 → 执行 → 缓存友好地安排下次唤醒 → 收尾禁用的完整闭环。读完本文你将掌握 autopilot 协调器的完整工作流、决策逻辑、记忆与神经学习集成方式并能把这一模式复用到自己的多轮、跨会话任务自动完成场景中。一、协调器角色定位与插件全景1.1 这个 Agent 是什么在 autopilot-coordinator.md 中该 Agent 被定义为 autopilot coordinator agent职责是驱动自主任务完成循环。它的元数据frontmatter如下name: autopilot-coordinator description: Autonomous task completion coordinator using /loop and autopilot MCP tools model: sonnet三个关键信息nameAgent 的注册名供调度器/编排层引用description声明其能力边界——用/loop autopilot MCP 工具做自主任务完成model: sonnet推荐使用的模型档位适合长上下文、需要持续推理的循环场景。1.2 插件背景ruflo-autopilot协调器所依赖的 MCP 工具全部来自 ruflo-autopilot 插件。该插件Combines Ruflos 10 autopilot MCP tools with Claude Codes native/loopScheduleWakeupfor persistent, cache-aware task completion loops安装方式/plugin marketplace add ruvnet/ruflo /plugin install ruflo-autopilotruflo从源码看10 个工具全部定义在 autopilot-tools.ts 的autopilotTools导出数组中README 中给出了完整映射ToolPurposeautopilot_statusCurrent autopilot state learning statsautopilot_enableTurn autopilot on for the projectautopilot_disableTurn autopilot offautopilot_configRead/update configurationautopilot_resetClear learned patterns and progress (testing)autopilot_logAppend a structured log entryautopilot_progressProgress summary across team/swarm/file checklistsautopilot_learnTrain on a completed task; writes toautopilot-patternsautopilot_historyBrowse past iterationsautopilot_predictPredict the optimal next action from learned patterns从源码结构看autopilot_log实际同时承担写入结构化日志与读取事件日志两个方向autopilot_enable/autopilot_disable/autopilot_reset处理器内部都会调用appendLog落盘事件而autopilot_log工具通过loadLog读取支持last参数取最近 N 条见 autopilot-tools.ts。二、完整工作流七步自主完成循环协调器 Agent 的核心是如下七步工作流源自 autopilot-coordinator.md 的### Workflow一节启用 autopilot通过 MCP 调用autopilot_enable配置限制autopilot_config({ maxIterations: 50, timeoutMinutes: 30 })检查进度用autopilot_progress查看按来源拆分的任务进度预测下一步用autopilot_predict做智能任务选择执行任务必要时委派给专家 Agentspecialist agents安排下次迭代每完成一个任务后通过ScheduleWakeup以270 秒间隔调度下一轮收尾当所有任务完成或达到限制时调用autopilot_disable2.1 启用与配置阶段autopilot_enable的源码实现在 autopilot-tools.tsconst autopilotEnable: MCPTool { name: autopilot_enable, ... handler: async () { const state loadState(); state.enabled true; state.startTime Date.now(); state.iterations 0; saveState(state); appendLog({ ts: Date.now(), event: enabled, sessionId: state.sessionId }); return ok({ enabled: true, maxIterations: state.maxIterations, timeoutMinutes: state.timeoutMinutes }); }, };可以看到启用时会重置迭代计数器iterations 0、记录起始时间并写入事件日志。工具描述里也点明了设计初衷Claude Code has no native autonomous-loop scheduler——Claude Code 本身没有原生自主循环调度器因此需要 autopilot 层配合 cron 触发来推进长周期目标。autopilot_config的参数约束autopilot-tools.ts参数取值范围说明maxIterations1–1000最大重新接续迭代次数超限即触发终止分支timeoutMinutes1–1440超时上限分钟到点触发超时分支taskSources数组元素来自VALID_TASK_SOURCES任务发现来源见下文非法输入会被validateNumber/validateConfiguredTaskSources拦截并返回错误对象含validSources提示。2.2 任务来源task sourcesautopilot_progress的按来源拆分依赖任务发现逻辑。合法的任务来源在 autopilot-state.ts 中定义为export const VALID_TASK_SOURCES new Set([team-tasks, swarm-tasks, file-checklist]);对应 autopilot-loop/SKILL.md 中描述的三类任务发现渠道team-tasksClaude Code TaskList 条目swarm-tasksMCPtask_list条目file-checklist受跟踪文件中的 Markdown 复选框- [ ]条目。默认全开但可以通过autopilot_config({ taskSources: [...] })精确裁剪例如仅跟踪前两类mcp__plugin_ruflo-core_ruflo__autopilot_config({ taskSources: [team-tasks, swarm-tasks] })注意技能中 MCP 工具实际调用名为mcp__plugin_ruflo-core_ruflo__autopilot_*形式即插件的 MCP 前缀命名空间。autopilot_progress返回结构见 autopilot-tools.ts{ overall: { completed: 8, total: 10, percent: 80 }, bySource: { team-tasks: { completed: 3, total: 4, tasks: [] }, swarm-tasks: { completed: 4, total: 4, tasks: [] }, file-checklist: { completed: 1, total: 2, tasks: [] } } }2.3 预测下一步autopilot_predictautopilot_predict是智能任务选择的核心autopilot-tools.ts优先走学习路径若 AgentDB 学习模块可用调用predictNextAction(state)返回基于历史模式的预测启发式回退学习模块不可用时扫描未完成任务返回首个未完成任务作为action置信度固定为0.5reason: Heuristic (learning not available)全部完成返回{ action: none, confidence: 1.0, reason: All tasks complete }。这正是协调器决策逻辑中高置信直接执行、低置信回退到任务列表按优先级取最高的底层依据。2.4 缓存友好的唤醒调度Cache-Aware SchedulingScheduleWakeup的270 秒间隔不是随意取值README 明确解释了原因The recommended fallback heartbeat is270 seconds— under the 5-minute prompt-cache TTL so the next wake-up reads conversation context cached. Going past 300s pays a cache-miss; rounding to 5 minutes is the worst-of-both case.即270s 300s5 分钟 prompt cache TTL下次唤醒能直接命中缓存中的会话上下文一旦超过 300s 就会 cache-miss重新读上下文付出额外 token 成本整好 5 分钟反而是最差情形worst-of-both case——刚好卡在 TTL 边界上缓存大概率已失效。对于事件驱动型循环event-driven loops可以挂一个Monitor主动感知事件把 270s 唤醒当作安全网safety net。三、决策逻辑终止与执行分支协调器在每次迭代结束时的决策规则源自 autopilot-coordinator.md 的### Decision Logic条件动作所有任务完成禁用 autopilot输出总结报告达到最大迭代次数禁用并警告仍有剩余任务超时禁用列出未完成任务高置信度预测立即执行该预测低置信度预测检查任务列表选最高优先级任务前三条是终止条件对应源码中isTerminal(t.status)的判定与状态机的enabled开关后两条是执行选择策略。在 autopilot-predict/SKILL.md 中置信度阈值被明确为0.7调用autopilot_predict获取推荐动作若confidence 0.7→ 直接执行预测若confidence 0.7→ 调用autopilot_progress看任务拆分选最高优先级未完成任务完成后调用autopilot_learn更新模式无剩余任务 → 禁用 autopilot 并退出循环。/loop集成时预测技能在每个迭代内指导该次动作选择见同一 SKILL.md 的 Integration with /loop 小节。四、记忆集成模式存储与跨会话召回4.1 命令级记忆存储任务成功后协调器把什么方法奏效沉淀为模式写入命名空间patternsnpx claude-flow/clilatest memory store --namespace patterns --key autopilot-PATTERN --value WHAT_WORKED同时周期性地调用autopilot_learn发现跨任务的成功模式cross-task success patterns。4.2 AgentDB 命名空间协调从插件 README 的 Namespace coordination 一节可知插件独占autopilot-patterns命名空间kebab-case遵循 ruflo-agentdb ADR-0001 的命名空间约定。保留命名空间pattern、claude-memories、default不得被遮蔽。autopilot_learn通过agentdb_pattern-store语义写入该命名空间并进一步喂给 ruflo-intelligence ADR-0001 描述的 4 步流水线RETRIEVE → JUDGE → DISTILL → CONSOLIDATE。4.3 学习与历史工具的底层行为autopilot_learnautopilot-tools.ts依赖 AgentDB 的AutopilotLearning实例并发调用getMetrics()与discoverSuccessPatterns()若 AgentDB 未初始化则返回{ available: false, reason: AgentDB/AutopilotLearning not initialized }。autopilot_history同文件 L200-L224必填query可选limit默认 10上限 100内部走recallSimilarTasks(query, limit)做相似任务召回。autopilot_reset同文件 L121-L136清空迭代计数、历史与lastCheck重启计时器——注释标明主要用于测试。五、神经学习post-task 训练闭环协调器文档的### Neural Learning一节给出了任务完成后的神经训练命令npx claude-flow/clilatest hooks post-task --task-id TASK_ID --success true --train-neural true npx claude-flow/clilatest memory search --query TASK_TYPE patterns --namespace patterns第一条在任务成功后触发 post-task hook并开启神经训练--train-neural true第二条随后在patterns命名空间中按任务类型检索验证学习结果可被检索到从而闭环完成 → 学习 → 再检索。结合autopilot-predict技能每次完成任务后都应调用autopilot_learn更新模式库历史模式通过autopilot_history({ query: KEYWORD })搜索模式最终存储在 AgentDB 中用于跨会话召回cross-session recall。六、配套命令与技能协调器的操作入口6.1 两个斜杠命令/autopilot 提供子命令式操作子命令行为/autopilot enable启用 autopilot 并启动完成循环/autopilot disable禁用允许 Agent 停下/autopilot config --maxIterations 50 --timeoutMinutes 30设置限制参数名与autopilot_configMCP 工具签名一致/autopilot reset重置迭代计数并重启计时器/autopilot learn从已完成任务中挖掘成功模式/autopilot history KEYWORD搜索历史完成片段无参数时默认调用autopilot_status显示状态。启用后需配合autopilot-loop技能启动/loop进行自主迭代并用 270s 的ScheduleWakeup保持缓存温暖。/autopilot-status 提供快速进度总览展示启用/禁用状态、迭代数 vs 上限、已用时间 vs 超时、按来源team-tasks / swarm-tasks / file-checklist的任务完成情况、总体完成百分比。需要细节拆分时转向autopilot_progress需要事件日志时转向autopilot_log。6.2 两个技能一次迭代的解剖autopilot-loop/SKILL.md 定义了单次迭代的标准动作序列autopilot_status检查状态若全部完成或达上限 →autopilot_disable并停止autopilot_predict获取最优下一步执行预测任务spawn agent、改代码、跑测试等autopilot_log记录日志ScheduleWakeup({ delaySeconds: 270, reason: next autopilot iteration })安排下次唤醒。该技能的allowed-tools白名单是插件安全模型的一个实例无通配符授权autopilot_status、autopilot_predict、autopilot_log、autopilot_progress、autopilot_disable、ScheduleWakeup、Agent。autopilot-predict/SKILL.md 则聚焦下一步选什么即上文第三节的 0.7 置信度决策并强调学习流水线autopilot_learn→autopilot_history→ AgentDB 存储与/loop的配合。七、验证与契约smoke-as-contractruflo-autopilot 遵循 smoke as contract 的插件规范见 ADR-0001。结构冒烟测试 smoke.sh 包含 10 项检查plugin.json声明版本 0.2.1 且含prediction、progress-tracking、cache-aware、mcp关键词10 个autopilot_*MCP 工具全部被插件文档引用两个技能autopilot-loop、autopilot-predict存在且 frontmatter 含name:、description:、allowed-tools:两个命令文件/autopilot、/autopilot-status存在README 将claude-flow/cli固定到 v3.6README 遵循 ruflo-agentdb 命名空间约定README 记录 270s 缓存感知ScheduleWakeup声明autopilot-patterns命名空间归属ADR-0001 存在且status: Accepted技能中无通配符工具授权。运行方式bash plugins/ruflo-autopilot/scripts/smoke.sh # Expected: 10 passed, 0 failed该脚本同时是验证autopilot-coordinator所依赖插件契约是否完整10 个工具、命名空间、缓存调度、技能白名单的权威入口。八、端到端编排从协调器到一次完整循环综合上述所有部件一个协调器驱动的完整自主循环可归纳为┌─────────────────────────────────────────────────────────────┐ │ autopilot_enable │ │ │ │ │ ▼ │ │ autopilot_config({maxIterations, timeoutMinutes, taskSources})│ │ │ │ │ ▼ │ │ /loop 每次迭代: │ │ autopilot_status → autopilot_progress按来源拆分 │ │ autopilot_predictconfidence0.7 直行 / 0.7 按优先级 │ │ → 执行/委派专家 Agent → 完成 │ │ autopilot_log 记录 → ScheduleWakeup(270s) 缓存友好唤醒 │ │ 任务成功memory store / hooks post-task 沉淀模式 │ │ autopilot_learn 更新 autopilot-patterns │ │ │ │ │ ▼ │ │ 终止条件全完成/达上限/超时→ autopilot_disable 总结 │ └─────────────────────────────────────────────────────────────┘这套模式的两个设计要点值得在实践中沿用持久性autopilot 状态由loadState/saveState持久化见 autopilot-state.ts配合 cron 触发即可实现跨会话自动恢复弥补 Claude Code 无原生自主循环调度器的缺口缓存经济学所有ScheduleWakeup严格使用 270s既保证推进节奏又始终踩在 5 分钟 prompt cache TTL 之内避免每次唤醒重读上下文的额外成本。参考与延伸协调器定义agents/autopilot-coordinator.md插件总览与安装README.md10 个 MCP 工具源码v3/claude-flow/cli/src/mcp-tools/autopilot-tools.ts状态管理与任务发现v3/claude-flow/cli/src/autopilot-state.ts技能autopilot-loop、autopilot-predict命令autopilot、autopilot-status契约ADR-0001 autopilot-contract、smoke.sh关联约定ruflo-agentdb ADR-0001命名空间约定、ruflo-intelligence ADR-00014 步学习流水线【免费下载链接】ruflo The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated项目地址: https://gitcode.com/GitHub_Trending/cl/ruflo创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考