Conditions
Execute steps conditionally based on expressions.
Basic Conditions
Skip steps based on expressions:
steps: - id: check llm: prompt: "Is it raining? Answer yes or no." - id: bring_umbrella condition: ${steps.check.output == "yes"} llm: prompt: "Remind me to bring an umbrella"The bring_umbrella step only runs if the condition is true.
Condition Syntax
Conditions use simple expressions:
# Equalitycondition: ${steps.step1.output == "expected"}
# Inequalitycondition: ${steps.step1.output != "skip"}
# Numeric comparisoncondition: ${steps.count.output > 10}
# Booleancondition: ${inputs.enabled == true}
# Containscondition: ${steps.check.output | contains("keyword")}Multiple Conditions
Combine conditions with logical operators:
# ANDcondition: ${steps.check1.output == "yes" && steps.check2.output == "yes"}
# ORcondition: ${steps.check1.output == "yes" || steps.check2.output == "yes"}
# NOTcondition: ${!(steps.check.output == "skip")}Input-Based Conditions
Conditionally execute based on inputs:
steps: - id: production_deploy condition: ${inputs.environment == "production"} shell: command: ./deploy-production.sh - id: staging_deploy condition: ${inputs.environment == "staging"} shell: command: ./deploy-staging.shDefault Values
Handle missing data with defaults:
steps: - id: optional_step condition: ${inputs.runOptional | default(false)} llm: prompt: "This runs if runOptional is true"Condition Functions
Available functions:
contains(substring)- Check if string contains substringstartsWith(prefix)- Check if string starts with prefixendsWith(suffix)- Check if string ends with suffixdefault(value)- Use default if undefinedlength()- Get array/string lengthisEmpty()- Check if empty
# Length checkcondition: ${steps.items.output | length() > 0}
# Empty checkcondition: ${!(steps.result.output | isEmpty())}Skipped Steps
When a step is skipped by a condition:
- Its output is undefined
- Steps depending on it are also skipped
- The workflow continues with other steps
Error Handling
Use conditions for error recovery:
steps: - id: try_api http: method: GET url: https://api.example.com/data - id: fallback condition: ${steps.try_api.error != null} file: action: read path: cached-data.jsonPerformance
Conditions are evaluated before step execution. Skipped steps don’t consume resources.