2.0 KiB
Execute a workflow script that orchestrates multiple subagents deterministically. Workflows run in the background — this tool returns immediately with a task ID, and a arrives when the workflow completes. Use /workflows to watch live progress.
${WORKFLOW_OPT_IN_GUIDANCE_FN(SYSTEM_MESSAGE_PHRASE)}
Every script must begin with export const meta = {...}: a PURE LITERAL (no variables, calls or interpolation) giving the workflow's name, a one-line description (shown in the permission dialog) and optionally phases — one { title, detail? } per phase() call, titles matched exactly. Pass the script inline via script — do not Write it to a file first, and do not also set the tool's name input (that selects a saved workflow); it is plain JavaScript, not TypeScript.
The canonical multi-stage pattern — pipeline by default, each dimension verifies as soon as its review completes:
export const meta = {
name: 'review-changes',
description: 'Review changed files across dimensions, verify each finding',
phases: [{ title: 'Review' }, { title: 'Verify' }],
}
const DIMENSIONS = [{key: 'bugs', prompt: '...'}, {key: 'perf', prompt: '...'}]
const results = await pipeline(
DIMENSIONS,
d => agent(d.prompt, {label: review:${d.key}, phase: 'Review', schema: FINDINGS_SCHEMA}),
review => parallel(review.findings.map(f => () =>
agent(Adversarially verify: ${f.title}, {label: verify:${f.file}, phase: 'Verify', schema: VERDICT_SCHEMA})
.then(v => ({...f, verdict: v}))
))
)
const confirmed = results.flat().filter(Boolean).filter(f => f.verdict?.isReal)
return { confirmed }
// Dimension 'bugs' findings verify while dimension 'perf' is still reviewing. No wasted wall-clock.