Skip to content

Validate generated artifacts, then regenerate rather than discard

Problem

A model asked for a document returns the document wrapped in conversation:

Here's the updated documentation:

# Actual Content
...

I've also fixed the formatting in section 3.

Committed as-is, the preamble becomes part of the file. Two obvious responses are both wrong. Stripping known prefixes is an arms race against phrasing you have not seen. Discarding the output loses a generation that was mostly correct — the content between the wrappers is usually fine.

Technique

Validate for conversational leakage with concrete patterns, and on failure regenerate with the failure fed back, rather than discarding or repairing.

Detect the shapes, not one wording:

  • opening address — "Here's the…", "I've updated…", "Sure, …"
  • closing commentary — "Let me know if…", "I also…"
  • meta-description of the change rather than the change

Then re-ask, telling the model what was wrong. A regeneration prompted with "your previous output began with a conversational preamble; return only the document" usually succeeds, because the model can follow a correction it can see.

Regenerating rather than repairing matters: a stripped preamble leaves output nobody validated end to end, and the strip itself can eat a legitimate first line.

When it applies

Any pipeline committing model output as a file — documentation, configuration, code, structured data. Especially where a human reviews the result later, since leakage is exactly the artifact that makes a reviewer distrust everything else in the diff.

When it does NOT apply

Conversational surfaces, where the preamble is the product.

It is also the wrong layer for correctness. This catches output that is shaped wrong, not output that is wrong — a confidently hallucinated function name passes every check here. Do not let a validation layer that catches formatting stand in for review that catches facts.

Regeneration needs a bound. Without a retry cap, a model that consistently misunderstands the request will loop.

Evidence

A documentation writer committed generated content directly. Conversational preamble appeared in merged documents, and the reviewer that should have caught it had "no agent dialogue leakage" as an explicit criterion — and approved it anyway.

That is the finding worth carrying: the check existed at the review layer and did not fire. Moving it to the write path, where it is mechanical rather than a judgement, is what fixed it.

See also