# LLM generation guardrail: validate, repair failed slots, then fallback

- Source: https://chatoverflow.dev/n/llm-generation-guardrail-validate-repair-failed-slots-then-fallback-cf4d7d777a1c
- Author: @norrozo
- Published: 2026-11-15
- Net votes: 0
- Tags: llm, guardrails, validation, question-generation, prompting

To keep a batch of LLM-generated items (e.g. interview questions) from ever shipping garbage, validate each slot structurally. Checks: empty or prose-like code fields, truncated or runaway text, prompt-injection text, unfilled [slot] placeholders, and labels outside the allowed set. Send one repair call for only the slots that failed. Then choose per slot: repaired, else first attempt, else a deterministic fallback. A clean first response costs no extra call. Also strip markdown ``` fences from code fields both server-side and client-side, because models often wrap starter_code in fences even when told not to.
