Prompt chaining: control intermediate results across calls
Prompt chaining connects multiple model calls in sequence so that one step’s output becomes the next step’s input. This lets an application inspect results, retry, branch, or stop between steps instead of sending one long request. The trade-off is more latency and cost, plus the risk that an early error will pass downstream; each stage needs a clear responsibility and check.
Prompt chaining connects multiple model calls in sequence so that one step’s output becomes the next step’s input. This lets an application inspect results, retry, branch, or stop between steps instead of sending one long request. The trade-off is more latency and cost, plus the risk that an early error will pass downstream; each stage needs a clear responsibility and check.
How is chaining different from task decomposition?
Task decomposition plans a complex request as smaller pieces. Prompt chaining implements those pieces as separate calls and data handoffs. Writing “first do A, then B” inside one request does not create an application checkpoint between API calls. Separate calls let the application inspect A’s result before deciding whether to run B, revise, or stop.
Anthropic’s prompting guidance describes explicit chaining as sequential API calls and says it is useful when intermediate outputs need inspection or a pipeline structure must be enforced. One common pattern is three calls: generate a draft, review it against criteria, and refine it using the review. This is a design option, not a guarantee of improved performance for every model or task.
How should you design the chain?
Give each call one purpose and a verifiable result. Define the input and output contract and conditions for refusal, review, or retry so a later stage does not blindly trust an earlier one.
| Stage | Input | Output contract | Check before continuing |
|---|---|---|---|
| 1. Extract | Source document and question | Evidence text, source location, uncertainty | Confirm the quotation exists in the source |
| 2. Classify | Verified evidence and category definitions | Category and reason | Allow ambiguous cases to remain unresolved |
| 3. Synthesize | Classification and source evidence | Patterns, exceptions, limits | Ensure conclusions do not exceed evidence |
| 4. Draft | Validated synthesis and format requirements | Final answer | Link claims to evidence and check format |
For a hypothetical pipeline answering employee questions from internal policy documents, the first call retrieves relevant policy passages and section locations. The application checks that passages exist in the source; if evidence is insufficient, it stops or asks for more information. A later call drafts an answer using only verified passages. A final review call checks whether each claim is supported and exceptions or scope are missing. This illustrates a design; no live policy system was tested.
What contract should intermediate results follow?
Instead of passing unrestricted prose, you can pass the minimum information the next stage needs in a structured result with identifiers, such as claim, source_id, quote, confidence, and needs_review. A schema can make output parseable, but does not make it true. Application code still needs to validate the structure and check evidence against the source.
Version each stage’s prompt and log its inputs, outputs, and failure types when appropriate; this helps locate where an error began. Consider whether logs contain personal or secret information, retain only what is necessary, and restrict access. Set retry limits, stop conditions, and a human-review path instead of retrying indefinitely.
When is chaining useful, and when is it excessive?
Chaining helps when a person must inspect intermediate work, a later step should run only after validation, or results need conditional routing. It also separates generation and review so they can be logged, evaluated, or revised independently.
For a simple question, multiple calls add delay, cost, and failure points. Errors can accumulate, and earlier information may be compressed or passed incorrectly. If one call can produce a sufficiently accurate and verifiable result, a single prompt is simpler. Compare both designs on the same evaluation cases to confirm that the checkpoints provide real value.
How should failures be handled?
Identify which output contract failed and whether only that stage can be retried safely. Do not pass unsupported output downstream. If sources are ambiguous or conflicting, request more input or escalate for human review. Repeating calls cannot guarantee correction of an error that retries do not address.
References
[Anthropic: Prompting best practices — Chain complex prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices) — sequential calls for inspecting intermediate output or enforcing a pipeline; draft-review-refine pattern. Read 2026-11-22.
[OpenAI API: Prompt engineering](https://developers.openai.com/api/docs/guides/prompt-engineering) — prompt evaluation, model variation, and validation recommendations. Read 2026-11-22.