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 no time limit; it ends when its script returns or you stop it. With a
token_budgeton the call,agent()calls fail once the steps have used that many tokens, and a run can start at most 1,000 steps. Steps have no time limit of their own, and Mewrk 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()getsnull; 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 Mewrk quits or crashes mid-run, the run picks up again as soon as Mewrk starts, without your opening its conversation, reusing the steps that had finished.
Parameters
| Parameter | Type | Details |
|---|---|---|
name requiredName | string | Run id, address and task title; same namespace as agent names. A taken name is numbered (review-sweep-2) and the receipt reports the id; a resume needs an unused name. |
argsArguments | any | Exposed as args. Pass JSON, not encoded strings; max 4,096 items per array. |
resume_run_idResume run ID | string | Earlier run's name or numbered id. Steps replay while agent() calls match the last attempt in order (prompt and options except label, phase); from the first changed, failed or skipped step on, all re-run. script and args default to the last used. |
scriptJavaScript | string | Plain JavaScript starting with export const meta = { name, description, phases?: [{title, detail?}] } as a pure literal. The body is an async function (await, return); its JSON-serialized return value is the result; steps still running at return are cancelled.
Globals:
- agent(prompt, opts?) -> Promise<any>: one step subagent, given only the prompt. opts: label, phase, schema (resolves to validated data), effort (low|medium|high|extra|max), agentType (role name; roles unreadable, checked when the step starts, unresolved fails it to null), isolation. A failed or skipped step resolves to null.
- isolation: "worktree": own git worktree of HEAD on a fresh branch (committed tree only, none of your uncommitted changes); kept if the step changed or committed anything, else removed; path and branch shown to the user, not returned. Needs a git repository root. Costs a full checkout per step.
- parallel(thunks): run () => agent(...) thunks concurrently, a barrier; a throw yields null.
- pipeline(items, ...stages): items flow independently; stages get (prev, item, index); a throw nulls the item.
- phase(title); log(message).
- args (verbatim; undefined if none); budget: { total, spent(), remaining() }, agent() throws once exhausted.
args and step results have a null prototype: use JSON.stringify. Date.now(), argless new Date() and Math.random() throw; no console, filesystem, network, modules or timers. Max 1000 agent() calls, 4096 items per array.
Required unless resume_run_id (reuses the last script). |
token_budgetToken budget | integer | Cap for steps (budget.total), checked per agent() call against finished steps, so running steps can overshoot; not carried over on resume. |