| 21 | type_key = "do-while" |
| 22 | |
| 23 | def execute(self, config: dict[str, Any], context: StepContext) -> StepResult: |
| 24 | max_iterations = config.get("max_iterations") |
| 25 | if max_iterations is None: |
| 26 | max_iterations = 10 |
| 27 | nested_steps = config.get("steps", []) |
| 28 | condition = config.get("condition", "false") |
| 29 | |
| 30 | # Always execute body at least once; the engine layer evaluates |
| 31 | # `condition` after each iteration to decide whether to loop. |
| 32 | return StepResult( |
| 33 | status=StepStatus.COMPLETED, |
| 34 | output={ |
| 35 | "condition": condition, |
| 36 | "max_iterations": max_iterations, |
| 37 | "loop_type": "do-while", |
| 38 | }, |
| 39 | next_steps=nested_steps, |
| 40 | ) |
| 41 | |
| 42 | def validate(self, config: dict[str, Any]) -> list[str]: |
| 43 | errors = super().validate(config) |