Example
This illustrative procedure drafts the text of a nonpayment notice. It has a run title, an input with a default, an input with its own schema, a template, and the run’s own URL in its result.nonpayment-notice.procedure.md
File name and layout
Name the file<id>.procedure.md, such as nonpayment-notice.procedure.md. The suffix is the
convention tools look for; the procedure’s identity comes from id, not the file name.
The file has this order, with nothing in between:
- Front matter, starting on the first line with
---and ending with a line that is exactly---. - At least one blank line.
- One
#heading: the procedure’s title. It is the only title; front matter doesn’t repeat it. ##to######headings, prose and nodes.
Front matter
Effective ignores other top-level keys. Don’t write a
version: Effective numbers versions when
you publish.
Names
- Procedure id: one or more segments separated by dots. Each segment starts with a lowercase
letter and holds lowercase letters, digits and hyphens, such as
nonpayment-noticeorbilling.nonpayment-notice. At most 256 characters. - Input, output and value names: a lowercase letter followed by lowercase letters, digits and
underscores, such as
policy_number.inputs,runandprojectare reserved.
Inputs
Each input has exactly one oftype or schema, and may have a default:
typeis one ofstring,number,integer,boolean,object,arrayornull.schemanames aschemablock in the same document. Use it for anything more specific than a bare type, such as adate-timeordecimalstring.- An input without a
defaultis required when a run starts. A missing input with adefaultgets a copy of that value. The default must match the input’s type or schema. - An explicit
nullis a value, not a missing input.
Output
outputs names one output with one schema:
complete node that returns this output. A run that fails
or is cancelled returns no output.
Run title
run.title may use {{ }} templates, but only over $inputs. It is fixed when the run starts and
never affects what the run does.
Headings
## to ###### headings form a tree. Each heading owns the text and nodes up to the next
heading of the same or a higher level. Don’t skip levels: a #### must sit under a ###.
Every heading gets an address. choice targets headings by
address, and Markdown links such as [Deny](#deny-refund) can use it. By
default the address is derived from the heading text: lowercase it, replace each run of characters
other than a–z and 0–9 with -, trim leading and trailing -, and prefix #. So
## Deny the refund becomes #deny-the-refund.
To keep an address stable when you reword a heading, end the heading with a custom id:
# title heading takes no
custom id.
Headings don’t run. They don’t create scopes, hide values or guard entry.
Nodes
A node is a fenced code block whose first line names a language, a role and an id:- The fence uses backticks, starts in the first column, and isn’t inside a list, quote or HTML.
A fenced block with only a language, such as plain
yaml, is ordinary example code. id=comes first. Ids use lowercase letters, digits and hyphens, and are unique across the document, declarations included.- Every node sits under a
##or deeper heading. A node before the first##is an error. - Prose and ordinary Markdown never run.
value, call and the
other runtime nodes are yaml. Functions and effects
are ts.
Run order
Runtime nodes run in document order:- Take the top-level
##sections in order. - Within a section, run the nodes it owns directly, in order.
- Then do the same for each of its child sections, in order.
- Then continue with the next section.
choice claims the heading sections it targets as its
branches; a branch starts at the first node its section owns, or else at the first node in its
first child section that has one.
Declarations can go anywhere
schema, secret,
retry and the code declarations,
ts function and ts effect, are
declarations. They never run and take no place in the run order. Effective reads them all before
anything else, so a step can use a declaration that appears later in the file.
Put declarations beside their first use, or group them under a heading such as ## Resources.
The heading name is a convention, not a scope: moving a declaration doesn’t change what the
procedure does. It does change the source, so publishing the move creates a new version.
References
A reference reads a value. It starts with$ and follows required members with dots.
- Every member in the path must be required by its schema. There are no array indexes, wildcards,
arithmetic or function calls in a reference. Use a
valuenode, or a purets functionthroughcall, to compute anything more. - A value can be read only by steps that come after the step that binds it on every path.
- Values are immutable. Each step receives its own copy.
$run.userIdstill works but is deprecated. Use$run.principal.id.
$review.value.approved, not $review.result.approved.
Other nodes, such as value, call and wait, bind their result directly.
References in YAML
In a node’s data fields, an unquoted value that is exactly a reference is a reference. Quote it to get the literal text:Templates
A template inserts values into a string with{{ }}:
run.title, over$inputsonly;- the
titleandinstructionsoftaskandagentnodes; and - any string inside the
valueof avaluenode.
- Each placeholder holds exactly one reference, with optional spaces inside the braces. No
??and no expressions. - The value must be a string, number or boolean. Objects, arrays and
nullare errors. - A template always produces a string, even when it is only one placeholder. To keep a value’s type, use a plain reference instead.
- Inserted text is never read as a template again.
- To write literal
{{, escape it as\{{. In a double-quoted YAML string, write\\{{.
YAML rules
Front matter and node bodies use a strict form of YAML:- No anchors, aliases, merge keys, tags, directives or multiple documents.
- No duplicate keys.
- Only lowercase
true,falseandnull, and plain JSON numbers, are read as non-strings. Values such asyes,2026-11-01,0x1For+1are strings, or errors where a number is required. - Whole numbers must be between -9007199254740991 and 9007199254740991.
- Comments are allowed and have no meaning.
Limits
A file over a limit is refused, never cut short.
Run statuses
When you read a run, itsstatus is one of:
completed, failed, cancelled, terminated and timed_out are final. New statuses may be
added; treat one you don’t know as not final. A run also has paused, which is true while it is
paused.
A failed run’s failure.code says why, such as invalid_input, schema_mismatch,
operation_failed or poll_timeout. New codes may be added.
Common errors
See also
- Procedures overview: what procedures are for.
schema: the contracts inputs and outputs name.complete: return the output.choice: branch to heading sections.- Runs and versions: what a run records and how versions work.