# YAML reference

Every field a workflow file accepts. Names are PascalCase, durations are ISO 8601 (PT30S) or a TimeSpan (00:00:30), and a field the engine does not know is refused when the workflow is uploaded.

## Top-level fields

- `Workflow` (string, required): The workflow’s name. It can change; the workflow’s id does not.
- `Description` (string): What the workflow does, as a calling model reads it. Required for a workflow another workflow binds.
- `Triggers` (entry[], required): The requests the workflow accepts, each under New with a JSON Schema.
- `Mode` (string, default `Queue`): What a request does while a turn is live. Values: `Queue`, `Reject`, `Supersede`, `QueueThenSupersedeAfter`, `QueueThenRejectAfter`.
- `WaitTimeout` (duration): Required by the two modes ending in After, refused by the others.
- `Standalone` (boolean, default `true`): False leaves the workflow to be called by other workflows only; starting a run on it is refused.
- `Model` (model selector, default `auto`): The models the workflow’s model steps run on where they name none. Where absent, the steps ask for auto: the models the organization lists in Settings › Models, tried in order.
- `Instructions` (string): Instructions for every model step: raw text, or a reference to a prompt Momor holds.
- `Operations` (binding[]): Every tool, workflow and wait the steps may name.
- `Functions` (function[]): Reusable expressions, each with Name, Parameters and Body.
- `Budget` (object): What a turn of this workflow may spend. Declaring it requires OnExhausted.
  - `Calls` (integer): Operation calls.
  - `Rounds` (integer): Model requests.
  - `Duration` (duration): Working time, with time spent waiting left out.
  - `MemoryProbes` (integer): Memory reads. Declared on the workflow’s Budget only.
- `OnExhausted` (policy): What happens when the Budget runs out. Values: `BestEffort`, `Wait`, `Return: <value>`.
- `RecoveryMode` (string, default `Manual`): How a failed turn is resumed. Values: `Manual`, `Auto`.
- `Output` (output contract, required): What the workflow returns. Values: `Content`, `Structured: <schema>`, `ToolResult`.
- `Reply` (object): On a ToolResult workflow only: the field the closing reply is returned under, and its shape.
- `Steps` (step[], required): The steps, in order.
- `OnAfter` (hook[]): Hooks run after a turn ends.
- `Stream` (boolean, default `true`): Whether model text is sent live as it arrives. What is recorded is the same either way.
- `Gather` (string, default `AsNeeded`): The default for model steps. Always requires each reply to call an operation. Values: `AsNeeded`, `Always`.
- `Knowledge` (string, default `Open`): The default for model steps. ToolsOnly answers from results already in the conversation. Values: `Open`, `ToolsOnly`.

## Operation bindings

| Key | Locator | Binds |
| --- | --- | --- |
| `Tool` | `embedded://…, mcp://…, or *` | A tool. A trailing * binds every match; Locator: "*" binds every registered tool. |
| `ProviderTool` | `embedded://…` | A tool the model’s own provider runs inside its reply. |
| `Workflow` | `<workflow id>` | Another workflow. Trigger names its request where it accepts several. |
| `Wait` | `embedded://…` | A registered wait. The binding’s name is the registration’s name. |

```yaml
Operations:
  - Tool: Fetch
    Locator: embedded://momor.ai/services/tools/fetchPage
  - Workflow: Intent
    Locator: 85d12c16-c88a-47e5-94a9-28b16fa05436
    Trigger: Request
  - Wait: Clarification
    Locator: embedded://momor.ai/services/tools/clarification
```

## Step fields

Every step takes an optional name, as the value of its key or as `Name`. These are the fields each kind adds.

| Kind | Fields |
| --- | --- |
| [`ModelCall`](/docs/workflows/steps/ask-the-model/) | Instructions (required), Model, Operations, Output, Attempts, Gather, Knowledge, OnExhausted |
| [`ExecuteTool`](/docs/workflows/steps/call-a-tool/) | Operations (required), Input, Attempts, OnExhausted |
| `ExecuteModelToolCall` | Operations, Input, Attempts, OnExhausted |
| `DeliverResults` | Input |
| [`Branch`](/docs/workflows/steps/if/) | Cases (When, Then; required), Else, Output, Attempts, OnExhausted |
| [`ForEach`](/docs/workflows/steps/for-each/) | Items (required), Each, Operation or Steps, Input, Output, Attempts, OnExhausted |
| [`Wait`](/docs/workflows/steps/wait-for-approval/) | Operation (required), Question (required) |
| [`WorkflowCall`](/docs/workflows/steps/run-a-workflow/) | Operations (required), Input, Attempts, OnExhausted |
| `Repeat` | Rounds, Steps, Output, OnExhausted |
| `While` | When, Steps, Output |
| `Exit` | None. Last step of a Repeat, While or ForEach body. |
| `Guard` | Key, Around (one step), Scope (Tenant or User), Ttl |
| `RefineLoop` | Operation, ConfidenceScore, Rounds, OnExhausted, Model, Gather, Knowledge, Input, Attempts |
| `AgentCall` | Agents, Input, Attempts, OnExhausted |
| `Supervise` | Mode, Models, Instructions, Agents, Budget, OnExhausted, Input, Output, Attempts |
| `Debate` | Mode, Instructions, Models, Budget (Rounds), Attempts, OnExhausted |
| `Scope` | Budget, OnExhausted and Steps, all required |

## Model selectors

| Written as | Selects |
| --- | --- |
| `auto or *` | Any model. |
| `claude-sonnet-4-6` | That model. |
| `tier/high` | Any model in the tier: Free, Low, Medium, High or XHigh. |
| `anthropic/*` | Models the publisher published, whoever serves them. |
| `togetherai/anthropic/*` | That publisher’s models served by that provider. |
| `{ System: Decision }` | Models of one system: Chat, Decision, Transcribe or Ocr. |

The object form takes `Name`, `Tier`, `Publisher`, `Provider` and `System` together: `{ Name: Auto, Tier: High, Provider: Anthropic }`. Selectors work as they do in [Gateway](/docs/gateway/).

## Output contracts

```yaml
Output: Content
Output: ToolCall
Output: ToolResult
Output:
  Structured:
    type: object
    required: [Topic]
    properties:
      Topic: { type: string }
Output:
  OneOf: [Content, ToolCall]
```

`ToolCall` and `OneOf` apply to model steps; `ToolResult` to a workflow’s own `Output`.

## Diagnostics

An upload is compiled before anything is stored. A refused upload answers `422`, or `400` where the YAML does not parse, with one line per problem: where it is, a stable code, the field path and what is wrong.

```text
workflow.yaml(14,7): error MOMOR012: Steps[1].Operations: The step names the operation 'Refund', which Operations leaves undeclared.
```

| Code | Means |
| --- | --- |
| `MOMOR010` | The YAML does not parse. Answered with 400. |
| `MOMOR011` | The YAML parses, but a field or a step is not one the engine knows. |
| `MOMOR012` | The workflow is well formed but cannot be admitted: an undeclared operation, a locator that matches nothing, a limit above the deployment’s ceiling. |
