if
Runs one block of commands or another, based on a condition.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
conditionrequired | Python expression | Boolean expression, evaluated once: true runs 'then', false runs 'else'. | |
then | command block | Commands to execute when the condition evaluates to true (the 'then' branch). | |
else | command block | Commands to execute when the condition evaluates to false (the 'else' branch). |
Example
"if": {
"condition": "{ location['country_code'] != 'US' }",
"then": {
"fail": "{ f'This agent supports only locations in the USA. You are in {location['country_name']}.' }"
},
"else": {
"progress": "Location looks good"
}
}Rules
- The condition is evaluated once, as a boolean.
thenandelseare ordinary command blocks. Any command may appear in them, including anotherif.breakandcontinueinside a branch act on the enclosing loop.return,endandfailleave the function or the agent as usual.

