ContextLab / ContextLab/orchestrator
action_loop's until: condition is never evaluated — the loop always runs once
- Dominant language
- Python
- Stars
- 3
- Forks
- 2
- Avg merge
- 13m
- Merged PRs (30d)
- 1
Description
An `action_loop` step must declare `until:` or `while_condition:` — the compiler rejects it otherwise:
```
YAMLCompilerError: action_loop must have either 'until' or 'while_condition'
```
The condition is then never used. Run, hermetically:
```yaml
- id: loop
action_loop:
- action: filesystem
parameters: {action: write, path: "out/{{ iteration }}.txt", content: "x"}
until: "false"
max_iterations: 4
```
Expected: 4 iterations (`until` never satisfied, capped by `max_iterations`). Observed: **1** iteration, one file. `until: "{{ iteration >= 3 }}"` also gives 1. So does `until: "{{ zzz_nosuch_variable }}"` — a name that exists nowhere raises nothing, which is the giveaway: the string is never rendered or evaluated.
`_check_termination_condition` (`control_flow/action_loop_handler.py:392`) is written correctly — it builds an eval context from `loop_context.to_template_dict()` and calls the condition evaluator. Something above it is not reaching that path, or is terminating first.
Consequence for validation: templates in an `action_loop`'s `until:` are dead text. `core/loop_contracts.py` currently validates them in the loop's body scope, which is the right answer *if* the field is ever evaluated, and harmless (no false rejection) if it is not. That choice should be revisited once this is fixed.
Contributor guide
Assessment
This issue has not been assessed yet.