Workflow is a client-side built-in tool that starts a script workflow from the main model loop.
It is now the only entry point for script workflows — the /workflow run and /workflows
commands were removed on 2026-08-22 (docs/dynamic-workflow/launch.md). The tool accepts a
self-contained workflow script, a named workflow, a script path, or a prior run id to resume.
The model-visible description is derived from workflow.md. It must make explicit that the model
may only call Workflow after the user opted into multi-agent orchestration.
The Zod runtime schema is the source of truth and projects to provider-neutral JSON Schema:
script?: string up to 524288 bytes. A self-contained script beginning with
export const meta = { name, description, phases }.name?: string. A saved workflow name resolved from the allowlisted built-in registry, project
.zcode/workflows, then user ~/.zcode/workflows.args?: unknown. Exposed to the script as global args.scriptPath?: string. Path to an editable workflow script. This takes precedence over script
and name.resumeFromRunId?: string matching wf_[a-z0-9-]{6,}. Resumes an earlier run in the same
session lineage.At least one of scriptPath, script, name, or resumeFromRunId is required. Precedence is
scriptPath > script > name; resumeFromRunId may be combined with a script source to re-run the
same deterministic call prefix after edits.
The tool returns a small structured object:
status: backgrounded, completed, or failed. V1 returns backgrounded after launch.runId: durable workflow run id.scriptPath?: editable script path used for this invocation.name?: resolved workflow name when available.response: human-readable summary carrying the run id. It must NOT point at /workflows
(removed); runs are read back through the app capabilities / desktop workflow surface.traceId: propagated trace id.The full workflow tree, child session links, events, stats and failures are stored in workflow tables and read through the app's workflow capabilities (desktop surface / app-server queries); they are not embedded in the tool result.
When a background workflow reaches a terminal state, the runtime task tracker enqueues a
<task-notification> for the parent runtime. The notification uses the same runtime command queue
as Bash and background subagents, so the main agent can stop after launch and be woken when the
workflow completes.
Workflow is not read-only. Even though the tool handler only validates input, persists an editable
script copy, and launches a background workflow, child workflow agents run in yolo mode and may call
workspace-mutating tools. The tool therefore declares:
sideEffectScope: "workspace"riskLevel: "high"needsApproval: trueconcurrentSafe: falsedestructive: truePermission matching uses the tool name and input summary. Child agent tool calls still go through their own runtime/tool contracts inside their child sessions.
The core handler never reads files, writes files, starts processes, or touches SQLite directly. It
validates the input and delegates to WorkflowPort. Bootstrap implements the port by reusing the
script workflow runtime:
wf_... run in the workflow tables.The script itself still runs in the dedicated Node child process described in
../workflow-script.md. This is process isolation, not a sandbox.
WorkflowPort exposes an optional waitForTask completion boundary. Bootstrap wires this to the
background workflow run promise so terminal workflow snapshots can be observed without relying on
poll timing; getTask remains available for live status updates and UI projection.
The workflow run id is durable. The app's workflow capabilities list runs and read status, phase,
activities, child sessions and accumulated stats (the /workflows command that used to render this
is gone; the run store is unchanged). Resume starts a new runner process and replays the
script from the beginning; completed agent() calls with the same deterministic call path and input
hash return cached results.
backgrounded.Required coverage:
script, name, scriptPath, resumeFromRunId, and rejects empty input
or unknown fields.Workflow only when a WorkflowPort is configured.WorkflowPort with sessionId, turnId, toolCallId, cwd and trace.WorkflowPort fails closed..zcode/workflows and
~/.zcode/workflows, and returns a wf_... launch result.RuntimeTaskRegistry as local_workflow and queues a
parent <task-notification> only after terminal completion is observed.