man@mndev:~/portfolio/notes/ai-dev
← portfolio

Putting an LLM in a publishing pipeline without trusting it

Structured outputs, schema validation, budget limits and a mandatory human review: guardrails for an AI editorial workflow.

AI dev··1 min read

In Simple Todo I added an AI editorial workflow: the Claude API, with web search, drafts content that eventually gets published. That’s useful, and also exactly the kind of feature that can go wrong in public. The design principle I kept coming back to: treat the model like an untrusted, very capable intern. Its work is welcome. Nothing ships without checks.

1. Ask for structure, then verify it

Free-form text is hard to validate. I ask for structured output that matches a schema, then validate it in code before anything else touches it:

const Draft = z.object({
  title: z.string().min(10).max(90),
  summary: z.string().max(280),
  body: z.string().min(400),
  sources: z.array(z.string().url()).min(1),
});

const parsed = Draft.safeParse(modelOutput);
if (!parsed.success) {
  // one retry with the validation errors, then give up and log it
}

The schema is the contract. If the output doesn’t fit, it doesn’t move forward.

2. Put a budget on everything

LLM costs and loops can run away quietly. Every run has:

3. Sources, not vibes

When web search is involved, the draft must include source URLs, and the reviewer checks them. A claim without a source gets cut or rewritten. This is the cheapest way to catch confident mistakes.

4. A human approves every publish

No auto-publish. The workflow produces a draft in a review state. A person reads it, checks the sources and approves it. The UI makes “reject” as easy as “approve”.

What this gives you

None of these guardrails are sophisticated. Together they turn “an LLM wrote this” into a workflow you can actually trust.