<Loop until={done} maxIterations={5}>…</Loop> re-runs its children each frame until until evaluates true or maxIterations is reached.
async function body, no agent) as well as agent tasks. Canonical
non-agent case: a retry-until-green test loop.
Notes
- Give every
<Loop>an explicitid. An auto id derives from tree position, so a conditionally mounted/unmounted sibling shifts the path, re-keying the loop and resetting its iteration state from 0; an explicitidis immune. onMaxReachedhas two values:"return-last"(default) ends the loop cleanly atmaxIterations, keeping the last output;"fail"throwsRALPH_MAX_REACHEDand fails the run. Use"fail"when hitting the cap means the work never converged (tests never went green), the default when the best-so-far result is acceptable.ctx.latest(table, nodeId)reads the highest-iteration output;untilmust usectx.outputMaybe(), since output is absent on iter 0.- Direct nesting of
<Loop>in<Loop>throws; wrap the inner loop in<Sequence>. - Custom Drizzle tables for loop tasks require
iterationin the primary key. Ralphremains a deprecated alias ofLoop; new code should useLoop.