Deep Expertise Track · Lesson 5

Sequential Orchestration

Multi-agent Pattern 1: chaining agents in a fixed pipeline

Sequential Orchestration: The Pipeline Pattern

Lesson 5 — Multi-agent Pattern 1: chaining agents in a fixed linear order

What you'll learn
  1. What sequential orchestration is and when to use it
  2. How it maps to Anthropic's "Prompt Chaining" workflow
  3. How to build a 3-agent pipeline for contract analysis
  4. When NOT to use sequential (and what to use instead)

The Pattern

Sequential orchestration chains agents in a predefined, linear order. Each agent processes the output of the previous one. You — the developer — define the order. The agents don't decide the sequence.

┌──────────────────────────────────────────────────────┐ │ SEQUENTIAL ORCHESTRATION │ │ │ │ Input ──▶ Agent 1 ──▶ Agent 2 ──▶ ... ──▶ Agent N │ │ (draft) (review) (finalize) │ │ │ │ Each agent gets the FULL output of the previous. │ │ Order is FIXED by the developer. │ │ Agents cannot reorder, skip, or go back. │ └──────────────────────────────────────────────────────┘

Source: Microsoft Azure — AI Agent Orchestration Patterns

When to Use Sequential

Use whenAvoid when
Clear linear dependencies between stagesStages can run in parallel
Progressive refinement (draft → review → polish)Need backtracking or iteration
Each stage adds specific value the next depends onNeed dynamic routing based on results
Predictable workflow with fixed stepsTask is open-ended or unpredictable

Real-World Example: Contract Generation Pipeline

Microsoft's architecture guide describes a law firm using sequential orchestration for contract generation — 4 agents in a pipeline:

CONTRACT GENERATION PIPELINE (law firm) ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ Template │─▶│ Clause │─▶│ Regulatory │─▶│ Risk │ │ Selection │ │ Custom. │ │ Compliance │ │ Assessment │ │ Agent │ │ Agent │ │ Agent │ │ Agent │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ Selects base Modifies Reviews vs Analyzes template from clauses based applicable liability, library on terms laws risk ratings │ │ │ │ ▼ ▼ ▼ ▼ Template + Customized Compliance Risk + specs clauses check recommendations │ ▼ Final contract

Build It: BA Document Pipeline

Here's a 3-agent sequential pipeline for BA work — draft a BRD, review it, then polish it:

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
import os

llm = ChatOpenAI(model="deepseek-chat", api_key=os.getenv("DEEPSEEK_API_KEY"),
                 base_url="https://api.deepseek.com", temperature=0)

# Agent 1: Draft BRD from requirements
draft_prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a Business Analyst. Draft a BRD from the given requirements. "
               "Include: overview, scope, user stories, acceptance criteria."),
    ("user", "{requirements}"),
])

# Agent 2: Review the draft for completeness
review_prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a senior BA reviewer. Review the BRD for: missing user stories, "
               "vague acceptance criteria, unclear scope. List issues found."),
    ("user", "{draft}"),
])

# Agent 3: Polish the BRD based on review feedback
polish_prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a BA editor. Fix all issues identified in the review. "
               "Output the final polished BRD in markdown."),
    ("user", "Original draft:\n{draft}\n\nReview issues:\n{review}"),
])

# --- The Pipeline (sequential, fixed order) ---
def run_pipeline(requirements: str) -> str:
    # Step 1: Draft
    print("Step 1: Drafting BRD...")
    draft = (draft_prompt | llm).invoke({"requirements": requirements}).content
    
    # Step 2: Review
    print("Step 2: Reviewing draft...")
    review = (review_prompt | llm).invoke({"draft": draft}).content
    
    # Step 3: Polish
    print("Step 3: Polishing BRD...")
    final = (polish_prompt | llm).invoke({"draft": draft, "review": review}).content
    
    return final

result = run_pipeline("Build a login page with OTP, forgot password, and social login")

Notice: you define the order (draft → review → polish). The agents can't deviate. This is a workflow, not an agent — but it's a multi-agent workflow.

The one-sentence summary

Sequential orchestration is a fixed pipeline where each agent hands off to the next in a developer-defined order — best for progressive refinement like draft → review → polish.

Practice Drill

  1. Copy the code above into ba-work-agent/sequential_pipeline.py
  2. Add your DeepSeek API key
  3. Run it with different requirements inputs
  4. Try adding a 4th agent: "Format as PDF-ready markdown"
  5. Question: Could you do this with a SINGLE LLM call? What would you lose? (Answer: you'd lose the independent review perspective — the same LLM reviewing its own work is less effective)
⚡ Quick Check
Q1: Is the sequential pipeline an "agent" or a "workflow" by Anthropic's definition?
Show answer

It's a workflow. The developer defines the order — draft, then review, then polish. The LLMs don't decide the sequence. This is Anthropic's "prompt chaining" pattern. It's predictable and cost-efficient.

Q2: What's the main risk of sequential orchestration?
Show answer

Errors in early stages propagate. If the draft is bad, the review critiques a bad draft, and the polish fixes the wrong things. Consider adding quality gates between stages (check if the draft meets minimum criteria before passing to review).

Want to see these patterns in action?

Explore the live apps built with these agent architectures.

Explore the Lab →

← Back to Deep Expertise Track