Workflow patterns
Prompt chaining, parallelization, routing, orchestrator-worker and evaluator-optimizer.
The five workflow patterns as LangGraph graphs: fixed code paths with model calls inside. Prompt chaining runs one call after another with a check between steps; parallelization runs independent calls at the same time and merges them; routing classifies the input and sends it to the step built for it; orchestrator-worker lets a model plan the subtasks at run time and starts one worker per subtask with Send; evaluator-optimizer loops a writer and a grader until the work passes. Each lesson builds its pattern on a small story, joke or report task, explains how LangGraph runs it, and shows what goes wrong and how to bound it; the last lesson compares the five and combines two of them in a report writer, one script with Gemini. Run the notebook cells in order, and try each practice task before you open its solution.
Lessons
- 1Prompt chainingWhere prompt chaining fits among the workflow patterns, why several small prompts beat one big one, gates, the story chain as a graph, what each step sees, the retry loop the gate creates and how to bound it, prompt chaining compared with an LCEL chain, interview questions and two practice tasks.
- 2ParallelizationSectioning and voting, when parallel steps pay off, the story-elements graph, how LangGraph runs a fan-out (super-steps, a thread pool, finish order), fan-in and the uneven-branch trap with waiting edges and defer, a failing branch, retries, rate limits and max_concurrency, interview questions and two practice tasks.
- 3RoutingWhat routing buys, routers made of rules, a model, embeddings or a classifier, the router graph with structured output, how a wrong route fails, routing from inside a node with Command, routing compared with a tool-calling agent, interview questions and two practice tasks.
- 4Orchestrator-workerWhen the subtasks can't be fixed in advance, the planner with structured output, the Send API and what each worker receives, the report graph, a run with stand-in workers, the shared key and its reducer, empty and oversized plans, the order of results, interview questions and two practice tasks.
- 5Evaluator-optimizerWhen a critique loop pays off, the joke graph with a structured grade, how the loop runs and what each round sees, the endless loop and its cost, round limits, evaluators made of code, a second model or a person, judge pitfalls, interview questions and two practice tasks.
- 6Combining the patternsThe five patterns side by side, how to choose one, how they nest, a report writer in one script with Gemini (orchestrator-worker plus evaluator-optimizer, structured output, Send, a review limit and max_concurrency), how to run it, which piece to swap, interview questions and a practice task without a model.