Skip to main content
A workflow is a script with a name and JSON Schemas for its input, its output and the signals it accepts. See Workflows for the model behind them. The complete program of this page is in examples/workflows.

Register a workflow

The script is checked against the toolset and the schemas: main must take the input and return the output, and signal() only takes the declared names. Inside it, signals are typed by the declaration:
The workflow's script
Saving the same workflow again returns the version saved first. Each different save is a new immutable version:

Let scripts start it

A toolset lists the workflows its scripts may start. Derive one from the toolset you already have, without listing its servers again:
Its declarations now tell the model how to use the workflow:
A script of this toolset fans out over the workflow:
result() rejects with a WorkflowError when the child failed, was cancelled or aborted: error.status says which, and error.runId names the run. The runs a script starts run in its namespace and inherit its labels; list them with runs.list({ startedBy: parent.id }).

Start it from your harness

workflow: "repo_check" starts its latest version; "repo_check@9fbd13f4bb9b" one version (12 hexadecimal digits at least). An input that does not match the schema is refused with invalid-input, and a signal the workflow does not declare, or whose payload does not match, with invalid-signal.

Workflows the model writes

Give the model the agent tool save_workflow, and it saves procedures it wrote as workflows of its own. The agent tools then derive a toolset that pins the new version, and its later scripts import it from rewind:workflows. See Agent tools.