Session 7· 01· 10 min

The 5 Workflow Patterns

What you'll learn
  • Name and describe each of the 5 workflow patterns
  • Know which pattern to use for a given scenario
  • Understand the complexity and parallelism trade-offs of each

Workflows sit in the sweet spot between chains and agents: the developer keeps control of the overall structure, but individual steps can involve LLM calls, branching, and even parallel execution. The LangChain documentation identifies five canonical patterns. Let's walk through each.

1. Prompt Chaining

The simplest workflow. Each step takes the output of the previous step as input. You add validation gates between steps so you can catch problems early instead of letting errors cascade. Think of it as a chain with quality checks.

Real use case: Generate a marketing email, then validate it against brand guidelines, then translate it into three languages.

Prompt Chaining
Sequential steps where each output feeds the next
Step 1
Gate
Step 2
Gate
Step 3
Output

2. Parallelization

When parts of a task are independent, run them at the same time and aggregate the results. This reduces latency dramatically — if three LLM calls each take 2 seconds, running them in parallel takes 2 seconds total instead of 6.

Real use case: Analyze a document for sentiment, extract key entities, and generate a summary — all simultaneously, then combine into a report.

Parallelization
Independent subtasks run simultaneously then merge
Input
Fan out
Task A | Task B | Task C
Merge
Output

3. Routing

A classifier examines the input and routes it to the appropriate specialized handler. Each handler can be optimized for its specific task with a tailored prompt, different model, or dedicated tools.

Real use case: A support ticket arrives. A classifier routes it to "billing", "technical", or "general inquiry" — each with its own prompt and knowledge base.

Routing
Classify input and dispatch to a specialist
Input
Router / Classifier
Agent A | Agent B | Agent C
Synthesize
Output

4. Orchestrator-Worker

A central LLM (the orchestrator) breaks a complex task into subtasks, dispatches them to specialized workers, and then synthesizes the results. Unlike parallelization, the subtasks are determined dynamically by the orchestrator rather than hardcoded.

Real use case: "Refactor this codebase" — the orchestrator identifies which files need changes, sends each to a worker, then verifies the combined result compiles.

Orchestrator-Worker
An orchestrator breaks down a task and assigns workers dynamically
Input
Orchestrator
Worker 1 | Worker 2 | Worker N
Orchestrator
Output

5. Evaluator-Optimizer

One LLM generates output, and another evaluates it. If the evaluation fails, the generator tries again with the feedback. This loop continues until the quality bar is met or a retry limit is hit. It's like having a writer and an editor working together.

Real use case: Generate code, then run unit tests against it. If tests fail, feed the errors back and regenerate. Repeat until all tests pass.

Evaluator-Optimizer
Generate → evaluate → refine in a loop until quality passes
Input
Generator
Evaluator
Pass? → Output | Fail? → Loop
These patterns compose
You can nest patterns. For example, an orchestrator-worker workflow might use parallelization for the workers and evaluator-optimizer for quality checking each result. Start with the simplest pattern that solves your problem and layer on complexity only when needed.

Comparison matrix

Here is how the five patterns compare across key dimensions:

 ComplexityParallelismDynamic controlWhen to use
ChainingLowSequential steps with validation
ParallelLowIndependent subtasks
RoutingMediumInput-dependent specialization
OrchestratorHighComplex tasks needing decomposition
EvaluatorMediumOutput quality must be verified

Check your understanding

Knowledge Check
You need to generate a blog post, then check it for factual accuracy, and regenerate with corrections if it fails. Which workflow pattern is this?
Knowledge Check
A support system classifies incoming tickets and sends each to a specialized handler. Which pattern is this?
Up next
You now know the 5 workflow patterns. But sometimes a single workflow is not enough — the next lesson covers when and why you might need to split work across multiple agents.