AI pipelines that don't fall over: lessons from building Assembly Line

Calling a language model once is a ten-line script. Chaining five calls together, with branching, retries, validation, and a human in the loop, is a distributed systems problem wearing a trench coat.

I've spent a lot of time on the second kind of problem, including in a framework I built called Assembly Line. These are the lessons that keep showing up, regardless of tooling.

1. Treat every step as a job that can fail

Models time out. Providers rate-limit you. Outputs come back malformed. In a pipeline, each step needs to be an isolated unit with:

  • A clear input and output contract
  • A timeout
  • A retry policy with backoff
  • A defined failure state, not just an exception bubbling up

If step four fails, you shouldn't have to rerun steps one through three and pay for them again.

2. Persist state between steps

Keep the output of every stage durable. When something breaks at 2 a.m., you want to resume from the last good step, inspect what the model actually returned, and fix the problem without starting over. Persistent state also makes debugging, auditing, and cost tracking dramatically easier.

3. Validate outputs like they came from an untrusted user

Because they did. Parse model output against a schema. Check required fields, ranges, and formats. Reject and retry, or route to review, when it doesn't conform. "The model usually returns valid JSON" is a sentence that precedes incidents.

4. Make steps small and single-purpose

One giant prompt that does research, drafting, formatting, and fact-checking is hard to test and impossible to improve piece by piece. Smaller steps let you evaluate each one independently, swap models per step (cheap model for classification, stronger one for reasoning), and see exactly where quality drops.

5. Build in human checkpoints deliberately

Not every step needs review, but some should, especially early on. Design the pipeline so a person can approve, edit, or reject at defined points, and so their corrections get captured. Those corrections are your best source of evaluation data.

6. Observe everything

For each step, log inputs, outputs, latency, token usage, cost, and outcome. Without this you can't answer basic questions like "why did this run cost so much?" or "which step is producing most of the bad outputs?"

7. Control concurrency and cost

Pipelines multiply calls. A burst of work can slam a provider's rate limits or your budget. You need queues, concurrency caps, and spending guardrails, not hopeful optimism.

In my own pipelines the pattern is consistent: each stage is an isolated unit with its own inputs, outputs, and retry rules. State is saved after every step. Failed work gets a defined path instead of crashing the whole run. Whatever tooling you use, those three habits do most of the work.

A pattern worth stealing

The shape that keeps working is: queue, then step, then validate, then persist, then next step, with retries and a dead-letter path for work that can't succeed. It's the same shape as reliable job processing in any backend system, and that's the point. AI pipelines aren't magic. They're background jobs with unusually unreliable workers.

The takeaway

If you remember one thing, make it this: the model is the least reliable component in your system, so design everything around it to be boring, observable, and recoverable. The teams that ship dependable AI aren't the ones with the cleverest prompts. They're the ones with the best plumbing.

Previous
Previous

Why Elixir is quietly great for AI workloads

Next
Next

The $20k/month engineering team you don't need yet