The Iteration Trap
Why adding validators to a failing multi-step LLM pipeline is the wrong instinct, and what the architectural exit actually looks like.
There is a moment I hit about four months into building a multi-step LLM pipeline that I suspect every engineer in this space eventually finds. The cold-run fails. I trace the defect, write a validator to catch it, re-run. The validator catches that defect. But now there is a new defect - a different shape, same general territory. I write another validator. Re-run. Third defect. Different shape again.
Three sessions later I had a dense validator graph, a pipeline that ran twice as slow, and output that still did not render correctly. I had been making progress the whole time. I just had not been making the right progress.
This is the iteration trap. Here is the exit.
The Math That Breaks the Optimism
A single LLM call at 95% accuracy is fine. Users retry, adjust, accept. That is the normal interaction model.
A pipeline of eight steps where each step is 95% accurate gives you roughly 66% end-to-end correctness. And the failures are not random - they compound. An upstream defect becomes a downstream one. The wrong type name at step 2 becomes broken JSX at step 6. By step 8, the validator has no path back to the decision made at step 2.
The instinct is to add validators. They catch more defects, the pipeline retries more, the failure rate inches down. But it never reaches zero, because the LLM makes different choices on each retry. You are not improving the distribution. You are just sampling from it more aggressively.
The Actual Problem
When a validator fires on an LLM-generated value, the instinct is to treat that value as the problem. Catch it next time.
The actual problem is that the LLM was asked to make a decision it should never have been asked to make.
A multi-step pipeline makes dozens of small decisions: what to name things, what paths to use, how to wire props, what types to reference. For most of those, there is one correct answer - one that follows directly from the data and schema already in the system. The correct import path is deterministic. The correct type name is in the schema. The correct prop wire follows from the prop type and the available scope.
When you ask the LLM to figure those out, you are asking it to guess correctly every time. It will not. And every time it guesses differently, you have a new defect with a new shape - and your existing validators do not catch it.
The validator is a smell. The cure is upstream.
The Hierarchy That Matters
Every value flowing through a pipeline has a provenance. The ones you can fully trust are typed inputs - schema exports, type definitions, registry entries - and deterministic derivations from those inputs, which are pure functions of things you already trust. Below those sit LLM outputs with a deterministic postcondition, where you trust the validator, not the LLM. At the bottom is LLM output without any postcondition, which is not a value - it is a deferred bug.
The pipeline's job is to keep as many decisions as possible in the first two categories. Every value in the last category is a future validator you have not written yet.
What to Move Out of LLM Territory
Type names should be derived from the schema, not from the LLM's interpretation of it. Import paths should be derived from the registry - never let the LLM type a path string. Test IDs should follow from the component's kebab name. Prop wiring, given a prop type and available scope, has a correct answer; make it a function, not a prompt. File skeletons - interfaces, function signatures, import blocks - are pure functions of the intermediate representation; emit them as strings and let the LLM only fill the body.
Every time I moved one of these from the LLM's jurisdiction to a deterministic derivation, output stability went up. It never went down. That pattern has held without exception.
When the LLM Has to Decide
Some decisions are genuinely creative - JSX composition, copy, layout choices. For those, the fix is not choice-space reduction, it is working memory.
Without memory, retries are independent draws. The LLM has the same probability of getting it right on retry 3 as retry 1. You are rolling the same dice more times.
With working memory, each retry is a strictly easier problem. The validator fires, appends a structured record of what failed, where, and why, and the next attempt sees that record. Here is what failed last time. Produce output that does not exhibit this. The LLM is not guessing from scratch - it is correcting a specific, named error.
Three rules: every validator failure appends a record, records are structured not free-form, and records clear on success so stale context does not carry forward into later steps.
The Signal You Are in the Trap
Each defect is a new shape, not a regression of an old one. Validator V1 caught defect D1. Re-running surfaces D2, which V1 does not catch. You write V2. D3 appears.
The class of defect was never closed. The class survives because the LLM has freedom to generate new shapes within it. You can keep catching individual instances indefinitely. You will not close the class from the validator side.
A working heuristic: if you have shipped three validators across three sessions for the same pipeline step, that step's choice space is too wide. Reduce it.
The Diagnostic
Every error message that ends in rerun or try again is an architecture bug.
If a re-run would fix it, the self-healing loop should be fixing it. If a re-run would not fix it because the LLM keeps choosing wrong, the choice was at the wrong tier and needs to move up. There is no failure mode where asking the user to try again is the correct architectural answer.
The Exit
Multi-step LLM pipelines are a young architecture. Most of the published patterns assume one LLM, one task, one shot at correctness. Pipelines are different - they compose many LLM calls into something that needs to behave like a deterministic state machine, and every call is a place errors accumulate.
The iteration trap is easy to fall into because the validators do work. The pipeline does improve - until it plateaus and you cannot see why. The plateau is the trap. The exit is moving decisions upstream, not patching outcomes downstream.
- MG
