Docs

Built-in tools›Agent orchestration

Workflow

workflow
Group
Agent orchestration
Turned on by
Its own switch on the Tools page of Conversation settings.
Approval
Reviewed: writes and open-ended actions ask for approval unless the security level or an earlier “Always allow” covers them.
Profile key
tool.workflow.description

Runs a script the model writes that hands work out to many subagents in a fixed shape, as one background task.

The run shows in the Tasks pane with a tile per step. The script format is in Subagents and workflows.

When it asks you

Under Manual and Accept edits, each run asks once before it starts; the card offers Always allow.

Limits

  • A run has 30 minutes, counted from when it starts running, not from when its approval card appeared. Steps have no time limit of their own, and Mework never ends one for being quiet: a model that reasons privately can send nothing for many minutes.

Good to know

  • A step with isolation: "worktree" gets its own Git worktree on the workspace's machine. One left with changes or commits is kept for you to merge.
  • In the run's panel, Skip {label} ends a running step and agent() gets null; Retry {label} starts the step again from scratch and the script gets the new attempt's result. Both stay available for as long as the run is going.
  • If Mework quits or crashes mid-run, the run picks up again as soon as Mework starts, without your opening its conversation, reusing the steps that had finished.

Parameters

ParameterTypeDetails
name required
Name
stringRequired. Name this run yourself: the name is this run's id and its address, in the same namespace agents are named in, and the title the task is listed under. Say what the run is for (review-sweep, migrate-callsites). A name is reserved for the whole conversation branch tree; reuse one and this run is numbered instead (review-sweep-2), and the receipt reports the id it got. A resume still needs a name of its own.
args
Arguments
anyJSON value exposed to the script as the global args. Pass arrays and objects directly (at most 4,096 items per array), not as encoded strings.
resume_run_id
Resume run ID
stringRun id of a previous run: the name you gave it, or the id its dispatch receipt reported when the host had to number it. A step whose prompt and options are unchanged replays instantly from the journal; a step the last attempt left running when it stopped re-runs on its own; a changed, failed or skipped step re-runs together with everything after it. script and args may be omitted — the host reuses the ones this run last ran with. Pass an edited script to change later steps or post-processing while unchanged steps still replay; it is approved again.
script
JavaScript
stringPlain JavaScript (not TypeScript), starting with export const meta = { name, description, phases?: [{title, detail?}] } — a pure literal. The body runs as an async function: top-level await and return work, and the return value becomes the workflow result. Available globals: - agent(prompt, opts?) -> Promise<any>: spawn one step subagent. It inherits no conversation history — the prompt must be self-contained. opts: label (display name), phase (progress group; defaults to the last phase() call), schema (JSON Schema the step must satisfy; the promise then resolves to validated structured data, otherwise to the step's final text), effort (low|medium|high|extra|max), agentType (a configured role name; when this conversation has roles configured, the schema carries their legal values under $defs.agentType), isolation. A failed or skipped step resolves to null. - isolation: "worktree" gives that one step its own git worktree, checked out from HEAD on a fresh branch, so parallel steps can edit files without colliding. It sees the committed tree only — your uncommitted changes are NOT in it. A step that leaves changes or commits keeps its worktree and reports the path and branch; one that changes nothing has it removed. Requires the workspace to be a git repository root; the step fails on its own if it is not. EXPENSIVE (a full checkout per step) — use it only when steps really would conflict. - parallel(thunks) -> Promise<any[]>: run () => agent(...) thunks concurrently and wait for all; a throwing thunk yields null. This is a barrier — use it only when the next stage needs every result. - pipeline(items, ...stages) -> Promise<any[]>: stream each item through the stages independently with no barrier between stages; stage callbacks receive (prev, originalItem, index), and a throwing stage drops that item to null. Default to pipeline over parallel. - phase(title): start a progress group; declare titles in meta.phases to pin their order. log(message): emit one narration line to the progress card. - args: the args input, verbatim. budget: { total, spent(), remaining() } for the token_budget cap; once exhausted, further agent() calls throw. Date.now(), argless new Date() and Math.random() throw — they would break resume replay; pass timestamps and seeds in via args. No filesystem, network, module or timer access. At most 1000 steps per run and 4096 items per boundary array. Required on a fresh run. Optional when resume_run_id is set — the host reloads the script that run last ran from its directory.
token_budget
Token budget
integerOptional hard token ceiling for this run, surfaced to the script as budget.total. Once step usage reaches it, further agent() calls throw.

Edit this page on GitHub