Example Use-Cases: Quality improvement loops, retry mechanisms, iterative refinement Iterative workflows provide controlled repetition with deterministic exit conditions, ensuring consistent quality standards. Workflows loop steps diagram

Example

iterative_workflow.py
from agno.workflow import Loop, Step, Workflow

def quality_check(outputs) -> bool:
    # Return True to break loop, False to continue
    return any(len(output.content) > 500 for output in outputs)

workflow = Workflow(
    name="Quality-Driven Research",
    steps=[
        Loop(
            name="Research Loop",
            steps=[Step(name="Deep Research", agent=researcher)],
            end_condition=quality_check,
            max_iterations=3
        ),
        Step(name="Final Analysis", agent=analyst),
    ]
)

workflow.print_response("Research the impact of renewable energy on global markets", markdown=True)

Developer Resources

Reference

For complete API documentation, see Loop Steps Reference.