A schema instead of text to re-parse
Asking an LLM to reply "in JSON" in the prompt isn't enough — it sometimes adds a sentence before the object, or drops a field. Validating every output against a structured schema eliminates that entire class of silent bugs: the response either conforms, or it's explicitly rejected — never half-interpreted.
What to do when the output fails anyway
A schema catches the failure, it doesn't fix it. That's where a reflection loop comes in: instead of blindly retrying, a dedicated agent diagnoses why the result failed — off-topic angle, wrong tone, unverified claim — and passes that diagnosis as an explicit constraint to the next attempt.
Always set a limit
Without a cap on attempts, a correction loop can run indefinitely on an edge case. In production, every loop has a maximum number of passes (3 for minor failures, 2 for strategic reflection on LuxenCrest) — beyond that, the system stops and surfaces the failure instead of silently burning budget.