Sequential Multi-Agent Workflow
In a sequential multi-agent workflow, each agent completes its task before the next agent begins. The output of each agent becomes the input for the next.
8 min•By Priygop Team•Updated 2026
Sequential Pipeline
Sequential Pipeline
# Sequential multi-agent pipeline
class SequentialMultiAgentPipeline:
def __init__(self):
# Define the pipeline: ordered list of (agent_name, agent_fn)
self.pipeline = [
("researcher", self._research_step),
("analyser", self._analysis_step),
("writer", self._writing_step),
("reviewer", self._review_step),
]
def _research_step(self, context: dict) -> dict:
print(" [Researcher] Gathering information...")
return {
"findings": ["AI adoption increased 40%", "GPT-4 most used model", "Cost is main barrier"],
"sources": ["https://example.com/report-2024"],
"quality": 9
}
def _analysis_step(self, context: dict) -> dict:
findings = context.get("researcher", {}).get("findings", [])
print(f" [Analyser] Analysing {len(findings)} findings...")
return {
"top_insight": findings[0] if findings else "No data",
"trend": "upward",
"confidence": "high"
}
def _writing_step(self, context: dict) -> dict:
analysis = context.get("analyser", {})
print(f" [Writer] Creating report from analysis...")
return {
"report_title": "AI Market Report 2024",
"summary": f"Key insight: {analysis.get('top_insight')}",
"word_count": 500
}
def _review_step(self, context: dict) -> dict:
report = context.get("writer", {})
print(f" [Reviewer] Reviewing report: '{report.get('report_title')}'")
return {
"approved": True,
"score": 9,
"feedback": "Excellent clarity and structure"
}
def run(self, goal: str) -> dict:
print(f"Pipeline starting: {goal}")
context = {"goal": goal}
for agent_name, agent_fn in self.pipeline:
result = agent_fn(context)
context[agent_name] = result
print(f" ✓ {agent_name} complete")
# Stop if reviewer rejects
if agent_name == "reviewer" and not result.get("approved"):
return {"status": "rejected", "feedback": result.get("feedback"), "context": context}
return {"status": "approved", "final_report": context["writer"], "review": context["reviewer"]}
pipeline = SequentialMultiAgentPipeline()
result = pipeline.run("AI market trends 2024")
print(f"\nStatus: {result['status']}")
print(f"Report: {result['final_report']['report_title']}")