Sequential Workflow

Chain agents one after another like an assembly line

Pass work from one agent to the next when each step depends on the previous output.

python
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")
flow = AgentFlow(steps=[researcher, analyst, writer])
flow.start("AI trends in 2024")

The user chains agents in order; each step receives the prior output until the final result is ready.

Diagram

Input

Agent

Output

Sequential Workflow

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

Diagram

📝 Request

🔍 Researcher

📊 Analyst

✍️ Writer

📋 Editor

✅ Result


How Context Flows

Diagram
WriterAnalystResearcherYouWriterAnalystResearcherYou“Write about AI trends”Research findingsKey insightsFinal article

Each agent receives the previous output automatically.


When to Use

Diagram

❌ Use Parallel

Independent tasks

Speed critical

✅ Use Sequential

Step depends on previous

Order matters

Quality review chain


Code

python
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

Diagram

📝 Topic

🔍 Research

📊 Analyze

✍️ Write

📋 Edit

✅ Published

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

With Callbacks

python
from praisonaiagents import AgentFlow, WorkflowHooksConfig

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

Related