Skip to main content

agent_loop

agent_loop(...) builds an agent loop and returns it as a Step. Key parameters:
  • body(state, loop_state) -> state
  • stop_condition(state) -> bool
  • policy: LoopPolicy (iteration limits, checkpointing, budgets)
  • name: step/agent name (used in tracing)
  • agent_type: type string for agent events

LoopPolicy

Loop execution configuration:
  • max_iterations
  • timeout_seconds
  • checkpoint_store
  • checkpoint_policy
  • execution_policy (budgets)

LoopState

Per-run loop state passed into the loop body:
  • iteration
  • start_time
  • last_checkpoint_id
  • agent_run_id

simple_loop

Convenience wrapper when you don’t need LoopState inside the body.
from coevolved.prebuilt import simple_loop

loop_step = simple_loop(
    body=lambda s: {**s, "n": s["n"] + 1},
    stop_condition=lambda s: s["n"] >= 3,
)

Next steps