Skip to main content
Workflows chain agents, conditions, and loops into powerful automation pipelines.

Quick Start

1

Linear Workflow

use praisonai::{Agent, workflow};

let writer = Agent::new().name("Writer").build()?;
let editor = Agent::new().name("Editor").build()?;

let flow = workflow()
    .then(writer)
    .then(editor);

flow.run("Write about AI").await?;
2

With Conditions

use praisonai::{workflow, when};

let flow = workflow()
    .then(researcher)
    .when(|result| result.len() > 100)
        .then(summarizer)
    .then(publisher);

Workflow Patterns

Research → Write → Edit

use praisonai::workflow;

let content_pipeline = workflow()
    .then(researcher)    // Research the topic
    .then(writer)        // Write the content
    .then(editor)        // Edit and polish
    .then(reviewer);     // Final review

With Validation Loop

use praisonai::{workflow, r#loop};

let validated_pipeline = workflow()
    .then(generator)
    .then(r#loop(validator)
        .until(|r| r.contains("approved"))
        .max_iterations(3));

Best Practices

Build linear workflows first, add branching later.
Name agents by their role in the workflow.