Orchestration Patterns: Sequential vs Hierarchical
How your agents work together matters as much as what they do individually. CrewAI offers different orchestration patterns for different types of workflows. Choosing the right pattern can mean the difference between elegant automation and a tangled mess.
Understanding Process Types
CrewAI supports two main process types:
SEQUENTIAL PROCESS
Tasks execute one after another in a defined order. Output from each task flows to the next.
HIERARCHICAL PROCESS
A manager agent delegates tasks to workers and coordinates their outputs.
Sequential Process Deep Dive
Sequential is the default and most common pattern. It's like an assembly line.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SEQUENTIAL PROCESS โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โResearch โโโโโถโ Write โโโโโถโ Review โโโโโถโ Publish โ โ
โ โ Agent โ โ Agent โ โ Agent โ โ Agent โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ
โ Each agent receives output from the previous agent โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
When to Use Sequential
- Clear linear dependency
- Each step builds on previous
- Order is predictable
- Pipeline-style workflows
- Tasks could run in parallel
- Dynamic routing needed
- Order depends on input
- Manager oversight required
Sequential E-commerce Examples
from crewai import Crew, Process
# Product Listing Pipeline - Classic Sequential
product_listing_crew = Crew(
agents=[researcher, copywriter, seo_specialist, reviewer],
tasks=[research_task, writing_task, seo_task, review_task],
process=Process.sequential # Default
)
# Order Processing Pipeline - Sequential
order_processing_crew = Crew(
agents=[validator, inventory_checker, payment_processor, fulfillment],
tasks=[validate_order, check_inventory, process_payment, create_shipment],
process=Process.sequential
)
# Customer Onboarding - Sequential
onboarding_crew = Crew(
agents=[welcome_agent, profile_agent, recommendation_agent],
tasks=[send_welcome, collect_preferences, generate_recommendations],
process=Process.sequential
)
Hierarchical Process Deep Dive
Hierarchical process adds a manager layer that dynamically delegates work.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HIERARCHICAL PROCESS โ
โ โ
โ โโโโโโโโโโโโโโโโ โ
โ โ MANAGER โ โ
โ โ Agent โ โ
โ โโโโโโโโฌโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโ โ
โ โผ โผ โผ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ Pricing โ โ Support โ โInventory โ โ
โ โ Expert โ โ Expert โ โ Expert โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโ โ
โ โ
โ Manager decides who to involve based on the situation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
When to Use Hierarchical
- Problem-solving, not pipeline
- Dynamic routing needed
- Complex coordination
- Specialist consultation
- Simple linear workflows
- Overhead isn't justified
- Fixed process required
- Predictability essential
Implementing a Hierarchical Crew
from crewai import Agent, Task, Crew, Process
# Define specialist agents
pricing_expert = Agent(
role="Pricing Specialist",
goal="Provide pricing expertise and recommendations",
backstory="Expert in e-commerce pricing strategies",
verbose=True
)
inventory_expert = Agent(
role="Inventory Specialist",
goal="Provide inventory status and availability information",
backstory="Expert in supply chain and inventory management",
verbose=True
)
support_expert = Agent(
role="Customer Support Specialist",
goal="Handle customer concerns with empathy and solutions",
backstory="Expert in customer satisfaction and issue resolution",
verbose=True
)
shipping_expert = Agent(
role="Shipping Specialist",
goal="Handle shipping and delivery inquiries",
backstory="Expert in logistics and delivery optimization",
verbose=True
)
# Define the manager agent
customer_service_manager = Agent(
role="Customer Service Manager",
goal="Coordinate specialist agents to resolve customer issues effectively",
backstory="""You are an experienced customer service manager who
knows how to route issues to the right specialists. You assess
each situation and delegate to the appropriate experts.
Your approach:
- Analyze the customer issue to identify required expertise
- Delegate to relevant specialists (one or multiple)
- Synthesize their inputs into a cohesive response
- Ensure the customer gets a complete resolution""",
verbose=True,
allow_delegation=True # Manager can delegate to others
)
# Define the task for the manager
resolve_customer_issue = Task(
description="""
Resolve the following customer issue:
{customer_issue}
Analyze the issue and delegate to appropriate specialists.
Synthesize their expertise into a complete resolution.
Ensure the customer receives a helpful, actionable response.
""",
expected_output="""
Complete customer response including:
- Acknowledgment of their concern
- Specific resolution steps
- Any relevant information from specialists
- Follow-up actions if needed
""",
agent=customer_service_manager
)
# Create hierarchical crew
customer_service_crew = Crew(
agents=[
customer_service_manager,
pricing_expert,
inventory_expert,
support_expert,
shipping_expert
],
tasks=[resolve_customer_issue],
process=Process.hierarchical,
manager_agent=customer_service_manager, # Explicit manager
verbose=True
)
# Example usage
result = customer_service_crew.kickoff(inputs={
"customer_issue": """
I ordered a laptop 5 days ago (Order #12345) and paid for express shipping.
The tracking still shows 'processing' and I need it for a presentation on Friday.
Also, I noticed you're now selling it for $50 less. Can I get the difference refunded?
"""
})
How Hierarchical Delegation Works
When the crew runs, the manager:
- Analyzes the issue - identifies shipping delay and pricing concern
- Delegates to shipping expert for order status
- Delegates to pricing expert for price match policy
- Synthesizes both responses into one cohesive reply
- Returns complete resolution to customer
Comparison: Side by Side
| Aspect | Sequential | Hierarchical |
|---|---|---|
| Control Flow | Fixed order, predetermined | Dynamic, manager decides |
| Best For | Pipelines, content creation | Problem-solving, support |
| Complexity | Simple, predictable | More complex, flexible |
| Token Usage | Lower (direct flow) | Higher (manager overhead) |
| Debugging | Easier (linear trace) | Harder (dynamic routing) |
| E-commerce Uses | Product listings, campaigns | Customer service, complex queries |
E-commerce Pattern Examples
Pattern 1: Product Launch (Sequential)
Perfect for sequential - each step builds on the previous:
# Research โ Copy โ SEO โ Design Brief โ Review โ Publish
product_launch_crew = Crew(
agents=[researcher, copywriter, seo, designer, reviewer, publisher],
tasks=[research, write, optimize, design_brief, review, publish],
process=Process.sequential
)
Pattern 2: Customer Support Ticket (Hierarchical)
Perfect for hierarchical - issue type determines routing:
# Manager analyzes ticket, routes to appropriate specialists
support_crew = Crew(
agents=[manager, billing, technical, shipping, returns],
tasks=[resolve_ticket],
process=Process.hierarchical,
manager_agent=manager
)
Pattern 3: Daily Operations Dashboard (Hybrid)
Some workflows benefit from combining patterns:
# Sequential for data gathering, Hierarchical for decisions
class DailyOperationsCrew:
def __init__(self):
# Sequential crew for gathering data
self.data_crew = Crew(
agents=[sales_tracker, inventory_tracker, support_tracker],
tasks=[get_sales, get_inventory, get_tickets],
process=Process.sequential
)
# Hierarchical crew for action decisions
self.decision_crew = Crew(
agents=[ops_manager, pricing_agent, restock_agent, support_escalation],
tasks=[make_daily_decisions],
process=Process.hierarchical,
manager_agent=ops_manager
)
def run_daily_ops(self):
# First, gather data sequentially
data = self.data_crew.kickoff()
# Then, make decisions hierarchically
decisions = self.decision_crew.kickoff(inputs={"daily_data": data})
return decisions
Choosing the Right Pattern
Use this decision framework:
Is there a clear
linear workflow?
โ
โโโโโโโโโโโโโดโโโโโโโโโโโโ
โ โ
YES NO
โ โ
โผ โผ
โโโโโโโโโโโโโโโโโโโ Does the next step
โ SEQUENTIAL โ depend on input?
โ โ โ
โ โข Product copy โ โโโโโโโโดโโโโโโโ
โ โข Order process โ โ โ
โ โข Campaigns โ YES NO
โโโโโโโโโโโโโโโโโโโ โ โ
โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ HIERARCHICAL โ โ Consider โ
โ โ โ PARALLEL โ
โ โข Support โ โ (Future) โ
โ โข Complex โ โโโโโโโโโโโโโโโโ
โ queries โ
โโโโโโโโโโโโโโโโ
Key Takeaways
- Sequential for pipelines - When step B always follows step A
- Hierarchical for problem-solving - When routing depends on the input
- Manager agents need allow_delegation=True - Required for hierarchical
- Hierarchical has higher token cost - Manager reasoning adds overhead
- Hybrid patterns work - Combine patterns for complex workflows
Next up: CrewAI E-commerce Assessment - Test your knowledge with a comprehensive quiz.