360 Secure SkillHub
360 安全技能中心

Workflow Orchestrator

提供 Python 工作流编排库与示例,按依赖关系执行多代理步骤,支持条件分支、并行、超时、重试、失败回退和运行状态查询;示例展示抓取、提取、摘要、翻译和发布流程。

evezart
evezart
热度 25.84
最近更新 2026-05-12 19:21:12
分类:自动化依赖:代码执行应用场景:工作流 / 自动化脚本 / 任务管理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add workflow-orchestrator
Metadata
name
workflow-orchestrator
description
Visual workflow builder for orchestrating multi-agent systems with branching, parallel execution, error handling, and retry logic. Use when building agent pipelines, DAG-based task orchestration, multi-agent coordination, or complex automation workflows. Covers step definition, conditional branching, fan-out/fan-in, failure recovery, and live monitoring.

Workflow Orchestrator

Build and run multi-agent workflows with DAG execution, branching, and error handling.

Quick Start

from orchestrator import Workflow, Step, Branch, Runner

wf = Workflow("data-pipeline")
wf.add_step(Step("fetch", agent="scraper", action="fetch_url", params={"url": "https://example.com"}))
wf.add_step(Step("extract", agent="parser", action="extract_text", depends_on=["fetch"]))
wf.add_step(Step("summarize", agent="writer", action="summarize", depends_on=["extract"]))
wf.add_step(Step("translate", agent="writer", action="translate", depends_on=["extract"]))
wf.add_step(Step("publish", agent="publisher", action="send", depends_on=["summarize", "translate"]))

runner = Runner()
result = runner.execute(wf)

DAG Execution Model

fetch → extract → summarize → publish
                 → translate ↗

Steps run in parallel when their dependencies are met. The publish step waits for both summarize and translate.

Step Definition

Step(
    name="unique_step_name",
    agent="agent_id",          # Which agent executes this
    action="tool_name",        # What action to perform
    params={},                 # Input parameters
    depends_on=[],             # Wait for these steps first
    retry=3,                   # Max retries on failure
    timeout_sec=300,           # Step timeout
    on_failure="skip",         # "skip", "retry", "abort", "fallback"
    fallback_step="plan_b",    # Run this step on failure
    condition="$.fetch.status == 200",  # Conditional execution
)

Features

  • Parallel execution: Steps with satisfied dependencies run concurrently
  • Conditional branching: JSONPath conditions determine which branches execute
  • Retry with backoff: Configurable retry count and exponential backoff
  • Timeout handling: Steps that exceed timeout are killed and handled per on_failure
  • Fallback steps: Alternative steps run when the primary fails
  • Live status: Query workflow state at any point during execution
  • Error propagation: Configure whether failures bubble up or are contained

Monitoring

status = runner.status(workflow_id)
# {"running": 2, "completed": 3, "failed": 0, "pending": 1}