Fix Invalid JSON from AI
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Run 40 looks nothing like run 1: sections reordered, one came back empty. Detect the drift, repair the run, keep the pipeline honest.
Format drift is the recurring-workflow disease: the same prompt that produced perfect output in week one starts reordering sections and leaving them empty by week six. This setup validates a drifted incident summary — Timeline and Root Cause swapped, Impact present but empty — the two drift signatures that presence-only checks miss completely. The repair prompt fixes the specific run; the validation history tells you when the underlying prompt needs a strictness upgrade.
Validate a sample of runs
Drift is statistical — one validation catches the run, a pattern of warnings catches the trend.
Note the drift signatures
Reordered sections and empty-but-present sections are drift; missing sections are breakage. Different fixes.
Repair the run, harden the prompt
The repair prompt fixes today's output; recurring warnings mean the generator prompt needs Strict consistency.
Presence-only checks pass because the 'Impact' header exists — this setup flags it as a distinct drift signature: 'Section Impact is empty or nearly empty'. The Fix instruction is to fill it or state explicitly there is nothing to report. The ai-output-validator surfaces that emptiness alongside order problems, catching what a header-exists check waves through.
So the output drops straight back into a position-sensitive parser or reader without cleanup. The OUTPUT RULES state 'Return only the corrected summary — no explanations, no commentary, no code fences' and 'Keep everything that was already correct unchanged'. Explanations or ``` fences would break the same downstream consumer the repair is meant to protect, and you run this through your own assistant.
Repair the run when it is an occasional slip; harden the generator prompt when 'Root Cause appears before Timeline' or an empty Impact shows up as a recurring warning across sampled runs. The repair prompt fixes today's output, but a pattern of the same drift signatures is your signal to raise the generator to Strict consistency — that prevention lives in the tools, not here.
The JSON won't parse and you can't see why. Deterministic cause-sniffing — trailing commas, single quotes, unclosed brackets — and the repair prompt that fixes it.
Paste the response, get the verdict: real JSON parsing, missing-field detection, and a repair prompt for everything found.
Grade agent output the same way every time — a rubric scoring correctness, grounding, safety, tone, and completeness, with a pass threshold instead of a gut call.
Stop getting 'Sure, here is the JSON…' — the output-contract pattern that forces models to return only parseable JSON: schema, example, and a strict rule block.
Free text in, named fields out. The extraction prompt pattern that turns any unstructured text into consistent, parseable records.
Billing, Technical, Account, How-To, Feature Request — ticket triage with definitions that decide the borderline cases for the model.
Paste an AI's output and validate it against the expected format — with a repair prompt for every failure found.
The AI nails your format once, then the next output adds a "Sure, here's…" wrapper, renames a field, turns the table into bullets, and drops a section. Here's how to write the format as a contract and catch the drift when it happens anyway.