Skip to main content

Sequential Workflow

Pass work from one agent to the next, like an assembly line.

How Context Flows

Each agent receives the previous output automatically.

When to Use


Code

from praisonaiagents import Agent, AgentFlow

researcher = Agent(name="Researcher", instructions="Research topics")
analyst = Agent(name="Analyst", instructions="Analyze research findings")
writer = Agent(name="Writer", instructions="Write based on analysis")

# Sequential: researcher → analyst → writer
flow = AgentFlow(steps=[researcher, analyst, writer])
result = flow.start("AI trends in 2024")

Example: Blog Post Pipeline

StepAgentReceivesOutputs
1ResearcherTopicFacts, data
2AnalystFactsKey insights
3WriterInsightsDraft article
4EditorDraftPolished post

With Callbacks

from praisonaiagents import AgentFlow, WorkflowHooksConfig

flow = AgentFlow(
    steps=[researcher, analyst, writer],
    hooks=WorkflowHooksConfig(
        on_step_complete=lambda name, r: print(f"✅ {name} done")
    )
)