Prompt chaining, defined: the primitive between one call and a loop
In short
A prompt chain is a sequence of model calls whose order you wrote before anything ran, where the output of step N becomes an input to step N+1. Nothing in it branches at runtime and nothing selects a tool. That single property — the author fixed the path — is what separates it from a state machine, which branches, and from an agent loop, which chooses.
Key takeaways
- A chain is author-fixed: same steps, same order, every run, regardless of input.
- Splitting buys per-step instructions, per-step validation and a retry that costs 1 step.
- The seam between links is where information is lost, so type the handoff rather than passing prose.
- Persisting an intermediate creates a second copy of the truth, and copies go stale.
- The moment a step needs skipping or resuming on its own, the chain has become a state machine.
A prompt chain is a fixed sequence of model calls in which the output of one step is an input to the next. You decide the steps and their order while designing the system; at runtime nothing chooses a different path, skips a link or picks a tool. Extract, then classify, then draft — 3 calls, always those 3, always in that order.
Naming it precisely matters because the word covers 2 mistakes at once. Teams call chains agents and inherit an operational reputation they have not earned, and teams build loops for work a chain would have handled at a fraction of the cost.
One call, a chain, a state machine, a loop
The 4 shapes form a ladder, and each rung is distinguished by one question: who decides what happens next, and when.
| Shape | Who decides the next step | Distinguishing property |
|---|---|---|
| Single call | Nobody — there is only one. | No intermediate artefact exists to inspect or validate. |
| Prompt chain | The author, in advance, for every run. | Fixed sequence; step N's output is step N+1's input; no branching. |
| State machine | The author, but the path is picked at runtime from named transitions. | Branches, has a resumable position, and legal next moves are a finite list. |
| Agent loop | The model, at runtime, from a tool set. | The number and order of steps are unknown before the run starts. |
The bottom rung is defined in an agent loop and its 4 moving parts; the rung above the chain is the state machine behind a reliable AI feature. Note what the ladder does not describe: how much the system is permitted to do on its own. A chain can draft for review or act unattended, and that is a separate axis with its own vocabulary in the rungs between suggesting and acting.
What splitting buys that one long prompt does not
- Narrower instructions per step. A prompt asked to do 1 thing can be specific about that thing, instead of balancing 4 sets of rules that quietly compete.
- A place to validate. Between links you can assert a schema, check a value against a database, or reject and retry — none of which exists inside a single call.
- Cheap retries. A failure costs 1 step rather than the whole run, and the step that failed is named rather than inferred.
- Mixed model sizes. The classify link and the drafting link rarely need the same capability, and splitting is what makes that choice available at all.
- An inspectable middle. When the output is wrong you can see which link produced the wrong thing, which is the difference between a bug report and a shrug.
The first link of a chain is very often a classification, and its label set is not a cosmetic choice: it determines what the following links can be. That constraint is set out in the intent taxonomy you write before the model.
The seam between 2 links is where information goes missing
A chain's failures cluster at the joins, not inside the steps. Step 1 produces prose, step 2 has to re-read that prose to find the 3 fields it needs, and anything step 1 declined to mention is now unrecoverable. Every step can score well in isolation while the run still fails.
One more caution about intermediates. Persisting a link's output for reuse creates a second copy of a fact that lives somewhere else, and copies drift out of date — the mechanism behind a deleted record that still appears in answers. Keep intermediates scoped to the run unless you have decided to own them properly.
Signs you wrote a chain and needed something else
Three tells, in the order they usually appear. A link that runs only for some inputs — that is a branch, and a branch in a fixed sequence becomes a conditional nobody documented. A step that must be retried, skipped or resumed independently after a crash, which needs a resumable position a chain does not have. And a step count that varies by input, which is a loop wearing a chain's clothes. Where exactly the first of these should force a rewrite is answered in when a chain should become a state machine.
A chain is the shape you should have to be argued out of. It is the cheapest thing that still lets you check the work between the steps.
Most durable systems we build are chains with a validation step between links, wrapped in something that can retry — the shape of work we scope under MVP and product builds. It sits in choosing the shape of the system, part of the engineering library.
Frequently asked questions
Short answers to the follow-ups this page tends to raise.
What is prompt chaining?
It is running a fixed sequence of model calls where each step's output feeds the next. The author decides the steps and their order before anything runs, so every execution takes the same path. If the path can change at runtime, it is not a chain.
What is the difference between a prompt chain and an agent?
Who chooses the next step. In a chain the author fixed the order in advance; in an agent the model selects the next action at runtime from a tool set. That makes a chain's cost, latency and failure modes knowable before it runs, and an agent's knowable only in distribution.
Is a prompt chain better than one long prompt?
Usually, for anything with more than one distinct job. Splitting gives each step narrower instructions, a place to validate between steps, retries that cost 1 step instead of the run, and a visible middle when something goes wrong. The cost is more calls and more latency, which is real but usually smaller than the debugging you avoid.
Can a prompt chain include a branch?
Not without stopping being a chain in any useful sense. The moment some inputs take a different route, you have a state machine with undocumented transitions — which is worse than a state machine with documented ones. Make the branch explicit and give it a named state instead of hiding it in a conditional.
- prompting
- system design
- definitions
- pipelines
The work behind this page
Builds from our portfolio that this page draws on.
Read next
- An agent loop: a goal, a tool set, carried state and a stopping ruleFour mechanical parts decide whether a system is agentic. Remove one and you have a pipeline with a model in it — often the better system, and always cheaper to run.definition
- "Dedicated team" defined by what it does not promiseThe phrase commits a supplier to almost nothing on its own. What it usually means in practice, and the three artefacts that turn it into something you can verify.definition
- A freshness SLA is a promise about the worst case, not the averageFreshness is the age of the data behind an answer when it is served, held under a stated ceiling. Latency is how fast a run finishes, and the two can disagree by a week.definition
- A subset of the PDFs came through as gibberish and nobody lookedA chunk of mojibake embeds happily, indexes happily and retrieves for nothing. No stage errors, so the only defence is a screen that reads the text before it is indexed.diagnostic
- Adding one new source made unrelated answers worseNothing about the old passages changed. A new source ranks moderately well on a great many queries, and a fixed top-k has to give it those slots by taking them from something else.diagnostic
- An upstream field changed and the pipeline carried on regardlessA renamed source field does not raise an error. It returns nothing, coalesces to an empty string, and quietly hollows out every record ingested since — until someone plots completeness by day.diagnostic
Working on something in this space?
Tell us where you are in a sentence or two. We'll tell you honestly whether we're the right team, and what a sensible first slice of the work looks like.
Start the conversation