Prompt Chaining
Decompose a task into a fixed sequence of LLM calls where each step's output becomes the next step's input.
Intent & Description
🎯 Intent
Decompose a task into a fixed sequence of LLM calls where each step’s output becomes the next step’s input.
📋 Context
A team is building an agent for a task that decomposes cleanly into a fixed sequence of sub-tasks whose order is known before the request arrives — for example turning a meeting transcript into structured action items decomposes into cleaning the transcript, attributing speakers, extracting candidate actions, normalising dates and owners, and emitting validated JSON. Each sub-task has its own definition of done, its own preferred prompt, and its own shape of output. The team controls the orchestration code that runs between LLM calls.
💡 Solution
Define a fixed pipeline of prompts. Each step has its own system prompt, expected output shape, and validation. A failure at step k retries step k or aborts; downstream steps run only on success.
Real-world Use Case
- A task decomposes into a fixed sequence of LLM calls with clear handoffs.
- Each step has its own system prompt, expected output shape, and validation.
- Localised retries at a step are preferable to retrying a mega-prompt.
Source
Advantages
- Failures localise to a step.
- Each step’s prompt can be optimised independently.
Disadvantages
- Inflexible to inputs that do not match the assumed decomposition.
- Latency = sum of step latencies.