← 返回列表
全部 Skill›开发 Development›run-workflow

run-workflow

作者 @asgeirtj · 语言 en
How to write and run a dynamic workflow script with the `run_workflow` tool: a Python script that orchestrates many agents with `agent`, `parallel`, `pipeline`, and `phase`. Use when a task splits into many independent or staged pieces of agent work (fan out over files, modules, bugs, or review angles, then aggregate), or when the user asks for a workflow. Don't use for a single delegated task (use a subagent) or for legacy workflow files (see migrate-workflows).
开发 Development脚本编程通用待翻译
最近源活动
—
检测 SKILL.md 语言
en
星标 ★
72,578
分支 Fork
0
安装选项
提示
指令
使用 AI 助手安装
将下面的提示复制到你正在使用的 AI 助手中。
下载完整 Skill 目录(含全部配套文件)。 下载压缩包 ↓
SKILL.md 原文预览

Dynamic workflows with run_workflow

A workflow is a short Python script that the run_workflow tool executes. The

script decides which agents to start, in what order, and what to do with their

results. Use it instead of many manual subagent calls when the orchestration

itself is code: loops over a list, fan-out then aggregate, or staged pipelines.

Steps

  1. Pass the script inline as Script, or write it to a file (for example in

the conversation scratch directory) and pass its absolute path as

ScriptPath. Set exactly one of them; a file is easier to fix and rerun.

  1. Call run_workflow(Script="...", Description="...") or

run_workflow(ScriptPath="/abs/path/workflow.py", Description="...").

Description is a one-line goal shown in the UI.

The workflow runs in the background, and you are notified when it ends.

For a quick script, such as a call_tool fan-out, set

WaitMsBeforeAsync (up to 10000) to get the result in the same turn if it

finishes in time.

To pass inputs, set Args to a JSON object; the script reads it as the

args dict. When ScriptPath is a saved workflow's entry script, Args

is validated against the args schema in its workflow.json.

  1. Read the tool result: it contains the log() output (Logs:) and what the

script printed (Output:). Each agent is also linked from the workflow

step, so the user can open its conversation.

  1. If the tool returns an error, fix the script at the reported line and run

it again.

Script rules

The script runs in its own python3 process, which needs Python 3.8 or later

on PATH:

  • await works at the top level, and you can define async def helpers.
  • Installed library workflows are importable by name (import <library> or

from <library> import <name>); library modules see the same primitives as

the script.

  • What the script prints (print(), stderr, child-process output, and the

repr of a trailing expression) is returned in the tool result's Output:

section (and appended to the error when the workflow fails).

  • An uncaught exception stops the workflow and reports the script line.
  • CONVERSATION_ID and STEP_INDEX identify the run_workflow step.

WORKSPACES is a tuple of the workspace directories, primary first (empty

if there are none).

  • The working directory is Cwd if given, else WORKSPACES[0], so relative

paths resolve against it. Local modules are not importable.

Primitives

| Primitive | Behavior |

| --- | --- |

| log(*args) | Adds a line to the workflow output and the UI. |

| phase(name) | Starts a named phase; later logs and agents group under it. |

| agent(prompt=None, schema=None, role=None, type_name="self", workspace="inherit", model=None) | Defines an agent; nothing runs yet. await agent(prompt, schema) runs it once and returns its result. a = agent(...) then await a(prompt, schema) runs one turn in a conversation kept across calls. |

| parallel(items, fn) | Promise that calls fn(item) for each item and awaits all results concurrently; results are in item order. If one fails, the rest are cancelled. |

| pipeline(items, fn) | Promise that calls and awaits fn(item) one item at a time; results are in item order. |

| trajectory(last=None, types=None, tools=None, min_index=None, max_index=None) | await trajectory() returns steps before this run_workflow call started, oldest first. min_index and max_index bound step.index (inclusive); types and tools filter by step type or tool name; last keeps the last N matching steps. |

Arguments:

  • type_name: the agent type to run. "self" uses the current agent's

configuration; any available custom agent name also works.

  • workspace: "inherit" (the current workspace), "branch" (a new isolated

clone, for agents that edit code in parallel), or "share" (a new workspace

that shares the underlying repository). Other values are errors.

  • schema (required): a JSON schema (dict or string) for the agent's result.

The agent returns the result by calling its finish tool, which checks it

against the schema, and await agent(...) returns the parsed value. An

agent that ends without calling finish fails the workflow. Use

{"type": "string"} for a free-form answer.

  • role: an optional short title for the agent's card, such as

"Security reviewer".

  • model: the agent's model tier: "inherit" (default, your model),

"flash_lite", "flash", or "pro". Use a lighter tier for simple,

high-fan-out work.

  • fn: usually a lambda that returns agent(...), or an async def

helper that awaits several agents. It must return something awaitable:

an agent() or a call on one, a nested parallel() / pipeline(), or

an async def call. Build per-item prompts and roles with f-strings.

Awaiting the same agent twice runs it once and returns the same result. An

agent() that is never awaited or called never runs, so always await it, or

pass it to parallel / pipeline and await that.

The workflow step shows one card per agent, in the order agents start, titled

with its role, or else the first line of its prompt, so set a role or start

each prompt with a short line that names the job.

Agents that keep their context

When one agent should do several related turns, such as a reviewer that checks

the fixes f

评论
Aasgeirtj
asgeirtj
asgeirtj/system_prompts_leaks
查看 GitHub 仓库 查看作者的其他 Skill
来源信息
作者@asgeirtj
所属大类开发 Development / 脚本编程
国内可用性通用
最近源活动—
风险提示无
提示:风险标签为程序静态扫描结果,仅作提示,不代表安全认证。安装前请阅读 SKILL.md 及其引用的脚本、权限,自行判断是否可信。