## Definition **Prompt chaining** is a prompting architecture in which a complex task is decomposed into a fixed sequence of smaller prompts, where the output of each prompt becomes a structured input to the next. Unlike [[Chain-of-Thought]], which asks a single prompt to reason step-by-step within one completion, prompt chaining forces the model to commit to one step at a time — each step's result is materialised and injected before the next step runs. ## The Structure A three-step chain takes the shape: ```text [goal] ──▶ Prompt 1: decompose ──▶ steps │ ▼ Prompt 2: calculate ──▶ intermediate results │ ▼ Prompt 3: synthesise ──▶ final answer ``` Crucially, each prompt is independent: it receives only what previous prompts produced, not the full original goal blended with prior reasoning. This prevents later prompts from inheriting earlier errors uncritically, and it makes each step auditable in isolation. ## Why It Works The core insight is that an LLM is better at each individual sub-problem when it cannot be distracted by other sub-problems. A single prompt asking for decomposition, calculation, *and* synthesis will conflate the three and optimise a blended objective; chaining forces a clean separation of concerns. Lanham demonstrates in *[[AI Agents in Action - Micheal Lanham]]* that even when the final answer remains imperfect, the intermediate outputs expose exactly where the reasoning went wrong — making debugging tractable. ## How It Differs from Related Techniques | Technique | Commitment | Branching | Evaluation | |---|---|---|---| | [[Chain-of-Thought]] | One completion | None | None | | Prompt Chaining | Step-by-step | None (linear) | Optional at end | | [[Self-Consistency]] | Multiple parallel | Flat | Majority vote | | [[Tree of Thought]] | Branch at each node | Explicit | Per-node | Prompt chaining is the linear, committed variant in this family. It trades the flexibility of ToT for simplicity and auditability. ## Relation to Agent Planners A prompt-based sequential planner (see [[Agent Planning]]) is essentially prompt chaining at the task level: a planning prompt generates a JSON plan whose steps are then fed one by one to execution prompts. Lanham's Nexus planner in chapter 11 implements exactly this: the planner prompt emits a subtask list, and each subtask's output is passed as context to the next. The `for-each` construct in that planner is prompt chaining over a dynamic list. ## Costs and Limits - **Latency multiplies with depth** — a ten-step chain requires ten sequential LLM calls with no parallelism. - **Error propagation** — a bad step-one output corrupts everything downstream; chaining does not self-correct. - **Verbosity** — chains tend to produce redundant output at each step if prompts are not tightly constrained. For tasks where errors are visible and steps truly independent, prefer [[Self-Consistency]] or [[Tree of Thought]] over a purely linear chain. ## Related - [[Chain-of-Thought]] - [[Self-Consistency]] - [[Tree of Thought]] - [[Agent Planning]] - [[Agentic Feedback Taxonomy]] ## Sources - [[AI Agents in Action - Micheal Lanham]]