Skip to content

std.agent_loop

Generated by sema doc from stdlib/sema/agent_loop.sema. Import with from std.agent_loop import …. For a narrative introduction see std.agent_loop.

std.agent_loop — the agentic loop as a reusable combinator (design ④).

loop_until(init, max_iters, step, done) runs step (a pure state -> state function) until done(state) or max_iters. Replaces the ~300-line hand-rolled _run_deep while loop; the termination policy is data. step/done are pure lambdas over an immutable state (Sema forbids a lambda mutating captured state, which keeps the loop parallel-safe).

def loop_until(init: any, max_iters: int, step: fn, done: fn) -> any !{}

Parameters

nametype
initany
max_itersint
stepfn
donefn

Returns any

Effects !{}