ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

Conductor Skills:让 AI 编码代理为 Conductor 构建、运行与管理工作流

Conductor Skills:让 AI 编码代理为 Conductor 构建、运行与管理工作流 Conductor Skills让 AI 编码代理为 Conductor 构建、运行与管理工作流【免费下载链接】conductorConductor is an event driven agentic workflow engine providing durable and highly resilient execution engine for applications and AI Agents项目地址: https://gitcode.com/GitHub_Trending/co/conductorConductor Skills 是官方提供的一套技能包它教会 Claude Code、Cursor、GitHub Copilot、Gemini CLI 等主流 AI 编码代理如何创建、注册、运行、监控和调优 Conductor 工作流与 Agent——你只需用自然语言描述需求代理即可完成从工作流定义到 Worker 代码的完整交付。本文完整讲解其安装、连接服务器、能力边界与一个订单处理系统的端到端实战流程并结合当前仓库源码剖析代理所操作的底层 REST API、任务执行与生命周期控制实现帮助你在掌握用法的同时理解其背后的运行时语义。前置条件一个可用的 Conductor 服务器Conductor Skills 本身不包含服务器它只是教你的代理怎么和服务器打交道。因此第一个前提是本地或云端有一台 Conductor 服务。如果手头没有可以用官方 CLI 快速起一个本地实例npm install -g conductor-oss/conductor-cli conductor server start也可以使用免费的托管 Developer Edition。连接相关的完整说明见仓库中的 Connect to Conductor。从仓库结构看本地服务器对应server模块Spring Boot 应用它把core核心执行引擎、各持久化模块redis-persistence、postgres-persistence等与restREST API 控制器装配在一起——这正是你的代理最终会调用的一组 HTTP 端点。安装一条命令适配所有编码代理Conductor Skills 提供统一的安装脚本自动检测本机已安装的 AI 编码代理并逐一安装macOS / Linuxcurl -sSL https://conductor-oss.github.io/conductor-skills/install.sh | bash -s -- --allWindows (PowerShell)irm https://conductor-oss.github.io/conductor-skills/install.ps1 -OutFile install.ps1; .\install.ps1 -All如果只想给某一个代理安装用--agent指定其标识例如 Claude Codecurl -sSL https://conductor-oss.github.io/conductor-skills/install.sh | bash -s -- --agent claude官方文档标注的安装耗时约为 2 分钟。安装后技能内容会以该代理约定的规则文件/技能目录形式落盘下文支持的代理一节列出了每个代理的全局与项目级安装路径。连接你的服务器安装完成后需要告诉代理 Conductor 服务器在哪里。有两种方式方式一直接用自然语言指令Connect to my Conductor server at http://localhost:8080/api方式二设置环境变量export CONDUCTOR_SERVER_URLhttp://localhost:8080/api这里http://localhost:8080/api是本地默认端口下的 REST 基地址。该地址最终会命中rest模块中的控制器——例如 WorkflowResource、TaskResource 与 MetadataResource它们分别承载了执行控制、任务更新/信号与元数据注册工作流定义、TaskDef等端点。代理能做什么九类能力一览装好之后你可以直接给编码代理下达以下类型的提示每条提示对应的结果如下表原文档中的能力矩阵完整继承能力提示词示例实际结果创建工作流Create a workflow that calls the GitHub API and sends a Slack notification代理生成含 HTTP 任务、输入表达式与输出参数的完整工作流定义运行工作流Run my-workflow with input userId 123代理启动执行并返回执行 ID监控执行Show me all failed workflows from the last hour代理按状态、时间或关联 ID 搜索执行记录调试失败What went wrong with execution abc-123?代理拉取执行详情定位失败任务并展示错误重试与恢复Retry all failed executions of order-processing代理批量重试失败执行生命周期管理Pause execution xyz-456代理暂停、恢复、终止或重启工作流信号任务Approve the payment wait task in execution abc-123代理向 WAIT/HUMAN 任务发信号以推进工作流编写 WorkerWrite a Python worker that validates email addresses代理使用对应语言的 SDK 生成 Worker 代码可视化Show me a diagram of the order-processing workflow代理将工作流渲染为 Mermaid 图值得注意的是这些能力并不是代理的魔法而是它按约定调用 Conductor REST API 的结果。例如生命周期管理背后是 WorkflowExecutorOps 中的pauseWorkflow、resumeWorkflow、retry、terminateWorkflow、restart等方法最终经由 WorkflowServiceImpl 暴露给 REST 层信号任务则对应TaskResource中的信号端点见下文实战 Step 5 的源码剖析。实战演练用自然语言构建订单处理系统以下示例完整展示了如何用自然语言提示让编码代理构建一个 Conductor 应用。流程为创建工作流 → 创建补偿工作流 → 编写自定义 Worker → 运行 → 人工审批 → 监控与调试 → 可视化。Step 1创建工作流提示词Create an order processing workflow with these steps: validate the order, check inventory, charge payment, and fulfill the order. If payment fails, compensate by releasing the inventory hold. Add a HUMAN task before payment so a human can review high-value orders.代理会生成如下工作流定义这是 Conductor 标准 JSON 定义格式可直接通过元数据接口注册{ name: order_processing, description: Process customer orders with inventory check, payment, and fulfillment, version: 1, schemaVersion: 2, inputParameters: [orderId, customerId, items, totalAmount], tasks: [ { name: validate_order, taskReferenceName: validate, type: HTTP, inputParameters: { http_request: { uri: https://api.example.com/orders/${workflow.input.orderId}/validate, method: POST, body: { items: ${workflow.input.items} } } } }, { name: check_inventory, taskReferenceName: inventory, type: HTTP, inputParameters: { http_request: { uri: https://api.example.com/inventory/hold, method: POST, body: { items: ${workflow.input.items} } } } }, { name: review_gate, taskReferenceName: review_gate, type: SWITCH, evaluatorType: graaljs, expression: $.totalAmount 500 ? needs_review : auto_approve, inputParameters: { totalAmount: ${workflow.input.totalAmount} }, decisionCases: { needs_review: [ { name: human_review, taskReferenceName: review, type: HUMAN, inputParameters: { orderId: ${workflow.input.orderId}, amount: ${workflow.input.totalAmount} } } ] }, defaultCase: [] }, { name: charge_payment, taskReferenceName: payment, type: HTTP, inputParameters: { http_request: { uri: https://api.example.com/payments/charge, method: POST, body: { customerId: ${workflow.input.customerId}, amount: ${workflow.input.totalAmount}, holdId: ${inventory.output.response.body.holdId} } } } }, { name: fulfill_order, taskReferenceName: fulfillment, type: HTTP, inputParameters: { http_request: { uri: https://api.example.com/fulfillment/ship, method: POST, body: { orderId: ${workflow.input.orderId}, items: ${workflow.input.items}, paymentId: ${payment.output.response.body.paymentId} } } } } ], failureWorkflow: order_processing_compensation, outputParameters: { orderId: ${workflow.input.orderId}, paymentId: ${payment.output.response.body.paymentId}, trackingNumber: ${fulfillment.output.response.body.trackingNumber} } }这段定义里值得对照源码理解的三个关键点schemaVersion: 2在 WorkflowDef 中该字段被 Bean Validation 注解约束为Min(2)且Max(2)即服务端当前只接受 schemaVersion 2 的定义。代理生成定义时若填错版本号注册POST /metadata/workflow会被拒绝。SWITCHevaluatorType: graaljs分支判断由 GraalVM JavaScript 求值器执行对应源码 GraalJSEvaluator 与 Switch 任务实现。decisionCases中的键如needs_review必须与表达式求值结果完全一致才会命中对应分支。failureWorkflow工作流失败时自动触发补偿工作流order_processing_compensation。该字段同样是 WorkflowDef 中的一等字段另有failureWorkflowVersion可固定补偿工作流版本这正是本例 Saga 式补偿的实现基础。代理生成定义后还应自动完成注册——即调用元数据接口POST /metadata/workflow见 MetadataResource。仓库中的 schemas/Workflow.json 提供了字段级 JSON Schema可供校验代理生成的定义结构。Step 2创建补偿工作流提示词Create the compensation workflow for order_processing. It should release the inventory hold and refund the payment if it was charged.代理会创建名为order_processing_compensation的工作流内容是与主流程逆序执行的逆向操作释放库存占用、已扣款则退款。它与主流程通过failureWorkflow字段绑定任何主流程任务在重试耗尽后失败Conductor 都会自动启动这个补偿定义。Step 3编写自定义 Worker提示词Write a Python worker that validates orders by checking that all items exist and quantities are positive代理使用 Conductor Python SDK 生成 Worker 代码from conductor.client.worker.worker_task import worker_task worker_task(task_definition_namevalidate_order) def validate_order(task): items task.input_data.get(items, []) for item in items: if not item.get(productId): return {valid: False, reason: fMissing productId} if item.get(quantity, 0) 0: return {valid: False, reason: fInvalid quantity for {item[productId]}} return {valid: True, itemCount: len(items)}worker_task装饰器会注册一个轮询服务器任务队列的后台循环领取任务、调用回调函数、把返回字典作为任务输出上报。Java 侧对应的模式是WorkerTask注解与 AnnotatedSystemTaskMapper见 AGENTS.md 中Worker tasks use theWorkerTaskannotation for automatic discovery。多语言 SDK 的完整列表见 Client SDKs。Step 4运行工作流提示词Run order_processing with orderId ORD-001, customerId CUST-42, items [{productId: SKU-100, quantity: 2}], totalAmount 750代理输出Workflow started. - Execution ID: f8a2b3c4-d5e6-7890-abcd-ef1234567890 - Status: RUNNING - The order total ($750) exceeds $500, so its waiting for human review.执行启动后状态为RUNNING但流程走到 SWITCH 分支判断totalAmount为 750 超过 500命中needs_review分支进入human_review这个HUMAN任务。HUMAN 任务会持久地挂起执行状态直到收到信号——这正是 Conductor durable execution可持久化执行语义的体现等待不消耗线程状态全部落在持久层。Step 5批准审批信号 WAIT/HUMAN 任务提示词Approve the review task in execution f8a2b3c4代理输出Task signaled: review → COMPLETED Workflow is now executing charge_payment.从源码看这条批准操作对应的是 REST 层的信号端点。TaskResource 中定义了POST /{workflowId}/{status}/signal异步与POST /{workflowId}/{status}/signal/sync同步两个端点内部调用taskService.signalTask(workflowId, status, output)服务器在当前执行中找到处于阻塞状态WAIT/HUMAN 等的目标任务将其置为 COMPLETED 并写入信号输出然后决策器Decider推进后续任务——本例即charge_payment。同步版本若找不到阻塞任务会抛出 Found no blocked task in workflow ... to signal 异常这一点在批量审批脚本中值得留意。Step 6监控与调试提示词Show me all failed order_processing executions from today代理输出Found 2 failed executions: 1. exec-abc — Failed at charge_payment (HTTP 402: Insufficient funds) 2. exec-def — Failed at check_inventory (HTTP 409: Item SKU-200 out of stock)接着可以批量或单个重试提示词Retry exec-abc代理输出Execution exec-abc retried. Status: RUNNING.按状态搜索执行依赖持久化后端的索引/查询能力redis-persistence、postgres-persistence、es7/es8-persistence等模块各自实现重试则落到 WorkflowExecutorOps 的retry(workflowId, resumeSubworkflowTasks)。注意重试的语义边界对已完成的任务不会重做失败任务按 TaskDef 的重试策略恢复如果工作流配置了failureWorkflow补偿流程与重试是两条独立的恢复路径代理在诊断时应当先确认失败是可重试的瞬时错误还是需要补偿的业务失败。Step 7可视化提示词Show me a diagram of order_processing代理把任务图渲染为 Mermaid支持的编码代理与安装位置Conductor Skills 覆盖 12 类主流 AI 编码代理各自的--agent安装标志、全局安装位置与项目级安装位置如下表代理安装标志全局安装位置项目级安装位置Claude Codeclaude原生 Skill—Codex CLIcodex~/.codex/AGENTS.mdAGENTS.mdGemini CLIgemini~/.gemini/GEMINI.mdGEMINI.mdCursorcursor~/.cursor/skills/.cursor/rules/Windsurfwindsurf~/.codeium/windsurf/.windsurfrulesGitHub Copilotcopilot—.github/copilot-instructions.mdClinecline—.clinerulesAmazon Qamazonq—.amazonq/rules/Aideraider~/.conductor-skills/.conductor-skills/Roo Coderoo~/.roo/rules/.roo/rules/Ampamp~/.config/AGENTS.md.amp/instructions.mdOpenCodeopencode~/.config/opencode/skills/AGENTS.md从表中可以看出Conductor Skills 的安装产物本质上是注入到各代理指令文件约定中的行为规范——AGENTS.md、GEMINI.md、.cursor/rules 等。这也解释了为什么本仓库自身的 AGENTS.md 文件里写着面向 AI 编码代理的工程规范构建命令、代码风格、测试要求Skills 让代理在生成工作流、调用 API 与编写 Worker 时遵循同样的约定而不是自由发挥。给任意 AI 助手的机器可读文档除 Skills 之外仓库还内置了一组专为 LLM/Agent 准备的入口代理或你手动可以把它们直接喂给任意 AI 助手Conductor for AI assistants规范页面定义了 Conductor 的权威词汇表、安全编写规则如外部副作用必须幂等有后果的写入前要求 HUMAN 审批不要把凭据放进工作流输入与任务选型指引llms.txt机器可读的文档索引列出各主题页面的规范入口并声明当文档与实现不一致时以工作流定义、Java 源码与 SDK 源码为准llms-full.txt将完整文档合并为单文件的版本适合一次性灌入上下文。这意味着即使你的编码代理不安装 Skills也可以把llms.txt指给它作为检索地图达到类似效果。升级技能更新后用带--upgrade标志的同一条安装命令刷新所有代理curl -sSL https://conductor-oss.github.io/conductor-skills/install.sh | bash -s -- --all --upgrade小结与延伸阅读Conductor Skills 把Conductor 怎么用好这件事从人工查文档变成了代理可执行的自然语言操作创建工作流定义、注册元数据、启动执行、信号 HUMAN 任务、监控搜索、批量重试、生成 Worker 代码与 Mermaid 图全部通过约定好的 REST API 完成——而这些 API 与任务语义都可以在本仓库源码中逐一对应验证rest控制器、WorkflowExecutorOps、GraalJSEvaluator、Switch等。掌握本文之后你可以继续深入从零动手构建第一个工作流与 WorkerYour First Workflow Worker构建持久化 AI Agent 工作流Your First Agent 与 Agents overview编写 Worker 所用的各语言 SDKClient SDKs工作流定义全部字段的参考Workflow definition reference。【免费下载链接】conductorConductor is an event driven agentic workflow engine providing durable and highly resilient execution engine for applications and AI Agents项目地址: https://gitcode.com/GitHub_Trending/co/conductor创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表