Prompt Chaining (Sequential Workflow)
Decompose a task into a fixed sequence of LLM calls, each operating on the previous output, with programmatic gates between steps.
This page is the complete instruction page for one pattern called "Prompt Chaining (Sequential Workflow)." It explains the problem this pattern solves, the idea behind the solution, when you should (and should not) use it, and what happens afterward — both the good effects and the costs.
This matters because building AI agents is not just about making them clever. It is also about making them safe and predictable. Following a well-tested pattern like this one helps avoid common mistakes, and shows you exactly which safety rules and regulations it connects to, listed under "Standards Mesh" on this page.
Context
Many tasks have a natural pipeline: outline → draft → edit → format. Each step is simple and well-defined. A general agent adds unnecessary variability.
Problem
Agent autonomy is overkill for predictable pipelines; it adds cost and noise.
Forces
- Flexibility vs predictability
- Control vs capability
Solution
Express the pipeline as a code-driven sequence. Each step calls the LLM with a focused prompt; a programmatic gate validates output before passing to the next. No model-driven decisions about flow.
Applicability
- Content generation pipelines
- ETL-like LLM workflows
- Tasks with stable structure
Anti-Patterns
- Using a full agent where a chain would do
- Gates that only check presence, not validity
Consequences
- +Predictable cost and latency
- +Easy to debug
- −Cannot adapt to unexpected inputs
- −New steps require code change