while
Repeats a block of commands while a condition stays true.
Fields
| Field | Type | Default | Description |
|---|---|---|---|
conditionrequired | Python expression | Boolean expression re-evaluated before each iteration. When false, the loop stops. | |
do | command block | Commands executed on every iteration while the condition is true. |
Example
"var": { "page": 1, "items": [] },
"while": {
"condition": "{ page <= 5 }",
"do": {
"api": {
"profile": "catalog",
"queryParams": { "page": "{ page }" }
},
"var": {
"items": "{ items + result['items'] }",
"page": "{ page + 1 }"
},
"break": "{ not result['hasMore'] }"
}
}Rules
- The condition is evaluated before every iteration, including the first.
- A loop may not run more than the max loop iterations set in Runtime limits. Exceeding the limit fails the agent. The count restarts each time the loop is entered.
- A long loop yields to other work from time to time, so that the agent's overall runtime limit can be enforced.
- Use
breakto leave the loop early andcontinueto skip to the next iteration.

