Steps inside this pattern inherit the same
max_retries, guardrails, and output_file policies as top-level steps. See Nested workflows → Retry, guardrails, and output_file.Quick Start
1
Define generator and stop condition
2
Run repeat workflow
API Reference
repeat()
Parameters
Condition Function
Theuntil function receives WorkflowContext and returns bool:
Result Variables
After repeat completion:Examples
Quality-Based Stopping
Counter-Based Stopping
With Agents
Evaluator-Optimizer Pattern
Classic pattern with separate generator and evaluator:With Early Stop
Use Cases
How It Works
Best Practices
Set a sensible max_iterations
Set a sensible max_iterations
Cap repeat loops to prevent runaway cost when exit conditions never trigger.
Write clear until conditions
Write clear until conditions
Evaluator functions should return explicit booleans — avoid ambiguous string matching.
Use repeat for refinement, loop for batches
Use repeat for refinement, loop for batches
Repeat improves a single artefact; loop processes many items — do not confuse the two.
Log each iteration in staging
Log each iteration in staging
Inspect intermediate outputs when tuning evaluator-optimiser workflows.
Comparison with Loop
Related
Workflow Patterns
Overview of routing, parallel, loop, and repeat
Workflow Loop
Iterate over lists and files
Workflow Routing
Decision-based branching
Workflow Parallel
Run independent steps concurrently

