YAML Syntax Reference
Variable references, conditional expressions, agent preset, code_preamble - the complete and authoritative reference for Braidrun YAML.
Braidrun's Web DTO performs YAML byte-level round-trip, but uses a different field naming style: camelCase vs snake_case. This page explains clearly the mapping, variables, conditions, and preset rules you need to know.
Verification and YAML round-trip both use the platform parsing interface /api/workflows/parse , to avoid writing another set of rules on the browser side.
Naming: camelCase ↔ snake_case
Web JSON uses camelCase; execution YAML uses snake_case:
| Web DTO | YAML |
|---|---|
groupChat | group_chat |
agentBased | agent_based |
stateMachine | state_machine |
repeatUntil | repeat_until |
iterateOver | iterate_over |
manualApproval | manual_approval |
onSuccess / onFailure | on_success / on_failure |
Agent Presets And Overrides
It is recommended to use preset to declare Agent, and use overrides to cover any fields when necessary:
agents:
planner:
preset: universal
coder:
preset: coder
overrides:
max_iterations: 2000Variable Reference
- Workflow variables:
{{var:name}} - Step output:
{{steps.step_name.output}}
variables:
topic: workflow
workflow:
- step: plan
agent: planner
input: "Plan for {{var:topic}}"
- step: implement
agent: coder
input: "Implement based on {{steps.plan.output}}"
depends_on: [plan]Conditional Expression (Condition)
The basic form is "left operator right," and the operator must have spaces on both sides. Supported operators:
==/!=— Exact string comparison, case-sensitive><>=<=— Numeric comparison; if either side isn't a number, the condition is treated as falsecontains/contains_cs— Contains check, case-sensitivecontains_ci— Contains check, case-insensitive
Multiple comparisons can be combined at the top level with &&(and) and ||(or); && binds tighter and is grouped first. Example:
condition: route == coding
condition: score >= 8
condition: status == done && score >= 8
# && binds tighter — reads as (a == 1 && b != done) || retry == true
condition: a == 1 && b != done || retry == trueDon't write:
condition: "{{var:route}} == coding" # don't — write the variable name directly
condition: (a == 1 || b == 2) && c == 3 # don't — parentheses are not supportedParenthesized grouping isn't supported — when you need more complex grouping logic, use classifier to produce a routing variable or split it into multiple steps. Write variable names plainly; don't use template-variable syntax inside a condition. A condition that can't be parsed is treated as false, and the step is skipped.
code_preamble — Shared Code Preamble
When multiple code steps need to share imports or helper functions, use the top-level code_preamble. It's grouped by programming language and, at run time, automatically prepended to the scripts of code steps in the same language:
code_preamble:
python:
ref: ./lib/shared_utils.pyOr use the inline form:
code_preamble:
python:
inline: |
import json, os
def log(msg):
print(f"[workflow] {msg}")Transition Action(on_success / on_failure)
Use action object form instead of string array:
on_success:
- next: publish
on_failure:
- notify: slack
message: implementation failed
stop: trueWhen exported as Web DTO, it corresponds to:
{
"onSuccess": [{"next": "publish"}],
"onFailure": [
{
"notify": "slack",
"message": "implementation failed",
"stop": true
}
]
}Top-level workflow fields
Beyond the required name / description / version / variables / agents / workflow, the top level accepts a set of optional settings:
| Field | Purpose |
|---|---|
variable_types | The variable type table, a sibling of variables; connection variable types are declared here too. |
error_handling | Workflow-level error handling policy. |
timeout | Timeout for the whole workflow — a separate layer from the step-level timeout_seconds. |
concurrency | Configuration for automatic DAG concurrency. |
recovery | Automatic resume after a service restart: autoResumeOnRestart, policy, maxAutoResumeAttempts. |
code_preamble | Shared code prelude grouped by language — see below. |
knowledge_base | Workflow-level knowledge base configuration. |
directory_isolation | Working-directory isolation policy. |
proxy | Workflow-level HTTP proxy override: inherit, disable or custom. |
module | The module contract. Declaring it makes this workflow referenceable by sub_workflow. |
global_agent | This workflow's own agent configuration — unrelated to the AI assistant on your account. |
tags / category | Used for search and grouping. |
Steps have no type field
This is the easiest thing to get wrong: a step's primary execution mode is not declared with type — it is decided by which key is present.
| Primary mode | Key that determines it |
|---|---|
| Single Agent | agent + input |
| Multi-agent discussion | group_chat |
| Dynamic delegation | agent_based |
| Deterministic script | code |
| Classifier | classifier |
| Nested state machine | state_machine |
| Sub-Workflow | sub_workflow |
Combining code and agent in the same step makes parsing unpredictable. To chain two things, split them into two steps and link them with depends_on.
Stackable enhancer fields
These are not primary modes but modifiers you can attach to any step, and they combine freely:
| Field | Purpose |
|---|---|
condition | When the condition is false the step is marked SKIPPED, which is not a failure. |
depends_on | Declares execution order explicitly. Referencing another step's output does not create the dependency for you. |
retry | Retry count, backoff strategy and delay. |
timeout_seconds | Timeout for this step. |
idempotent | Marks the step as safe to replay, which auto-resume relies on. Do not mark steps with side effects. |
manual_approval | A human approval gate. |
extract | Pull values out of the output with a regex or JSON Path and write them into variables. |
structured_output / output_schema | Constrains the shape of this step's output. |
iterate_over | Runs once per item of a list. |
aggregate | Merges several sources into a single variable. |
repeat_until | Iterative refinement until a condition holds. |
parallel | Parallelism configuration inside the step. |
on_success / on_failure | Transition actions — see below. |
Verify Clause List
- Variable reference usage
{{var:name}} - Exported YAML still passes
/api/workflows/parseRead Back - The condition has no template variables, and the && / || combination uses no parentheses
manualApproval/onFailure/repeatUntilAfter the DTO field is exported, it has been converted into snake_case