Prompt Chaining in Practice: Why the Schema Between Steps Matters More Than the Steps
Prompt chaining splits one overloaded LLM prompt into small steps. Here is why the schema between steps, not the step count, makes a chain reliable.

If your single "do everything" prompt works most of the time, the failures are the ones you can't predict. Prompt chaining splits that overloaded request into a sequence of small LLM calls, each feeding the next. I built a three-step chain for the first chapter of my Agentic Design Patterns study repo, and what stuck with me was how much of the reliability came from the typed handoff between steps.
TL;DR
- One prompt that extracts, transforms and writes at once tends to drop instructions, lose context and invent values.
- Prompt chaining gives each LLM call one narrow job; step N's output becomes step N+1's input.
- Most of the reliability comes from structured output (a Pydantic schema) at the boundaries, so bad data fails early instead of poisoning later steps.
- Plain code between LLM calls (validation, conversion, math, retries) is part of the pattern, not a hack.
- Core idea in one sentence: chain small prompts, and put a contract on every handoff.
Core Concept
Prompt chaining, also called the Pipeline pattern, breaks one complex task into a sequence of focused prompts. Each step has its own prompt, sometimes its own role, and passes its result forward. Ordinary code can sit between steps to check, reshape or branch on what came back.
Picture an assembly line. One worker who cuts, welds, paints and inspects every car will skip something on a bad day. Give each station one job and put an inspector between welding and painting, and the defect gets caught before the paint goes on.
Here's a real chain, with the inspector in place.
Key Building Blocks
The example is chain.py, a LangChain LCEL pipeline on Gemini. It turns one sentence of laptop marketing copy into a product announcement email.
You could ask one prompt to "pull out the specs and write an email". The chain does it in three LLM steps with code in between.
1. Extract: a narrow prompt gets a narrow answer
The first step only extracts. It has no idea an email is coming, so it can't trade extraction accuracy for email style. A prompt with one job asks less of the model at once.
Its output is still free text. That's fine for one hop, and the next step deals with it.