The Self-Healing Content Pipeline: What Happens When Your AI Avatar Video Comes Back Wrong
Every weekday morning at 6am, a system I built writes, voices, and renders a short video with no human touching it. Most days it works. One day it didn’t, and the way it failed — and what I changed afterward — is a better explanation of what “production AI system” actually means than anything I could just tell you.
The setup
The pipeline researches a topic, drafts a script with Claude, sends that script to an AI avatar generator to render into video, and packages it for upload. The script has to land inside a duration window — an AI avatar speaks at a roughly fixed pace, so a script that’s too long produces a video that runs over, and a script that’s too short produces something that feels clipped and rushed.
So there’s a rule: the script has to fit under a word-count ceiling. Simple enough to write. Simple enough to be wrong.
Where it broke
One morning the script came back at 111 words against a 90-word cap. The system did exactly what I’d told it to do: it rejected the script and stopped. No video, no email, no output — just a failure sitting silently in a log until I noticed hours later.
The instinct here is to just raise the ceiling. That’s the wrong fix, and it’s worth saying why: a hard ceiling with no recovery path isn’t a rule, it’s a landmine. Somewhere down the line, a script will come in at whatever the new number is, and the exact same silent failure happens again, just later and more expensively.
The actual fix
The system needed a way to fail productively — to notice the problem and try to solve it before giving up. So instead of a hard reject, the pipeline now does this: if the script comes back too long, it goes back to Claude with the actual word count and a direct instruction to compress it to fit, preserving the core point. It gets two attempts at this before it finally throws an error and tells me. Two chances to self-correct, then an honest failure — not a silent one, and not an infinite retry loop either.
Stripped down, the check is this:
if word_count(script) > 105:
if attempts < 2:
script = claude.compress(script, target=90, attempts += 1)
recheck()
else:
fail_loudly("script still over length after 2 compression attempts")
else:
proceed()
Two self-correction attempts, then an honest failure that emails me — never a silent one, never an infinite loop. That’s the whole idea in five lines. Most of the actual engineering time went into deciding what those five lines should say, not writing them.
That’s a small change in the code. It’s a much bigger change in what the system is. A script that fits under a ceiling on the first try and a script that gets compressed twice before fitting produce the same output from the outside. But only one of those systems survives contact with a Tuesday where the topic happened to need a few more words to make sense.
A question worth stealing
Before you ship any step where an AI model produces something the next step depends on, ask three things about it:
What’s “wrong” output for this step, precisely? Not “bad” — a specific, checkable condition: too long, malformed JSON, empty, wrong type.
Can it self-correct, and how many tries does it get before that’s a red flag instead of a fix?
When it finally fails, does it fail loud — where a human finds out — or silent, where it just doesn’t happen and nobody notices until later?
Most AI automation skips straight to “it usually works” and never answers these three questions for a single step. Answering them for every step is, more or less, the actual job.

