Most structured output pipelines already retry on failure. The problem is that a plain retry sends the same prompt at the same temperature and hopes the model draws differently. The better move is a different second prompt: one that puts the validation error and the model's own bad output back into the next call and asks it to fix that specific thing. That turns a blind retry into a targeted correction, and the correction re-uses the parts the model already got right the retry write-up.
Two details do the work. The error is described for the model, not for a log: a helper turns the raw validation exception into a plain instruction ("field X must be an integer, you sent a string"), because the model is good at patching a concrete, named mistake and bad at guessing why an opaque retry keeps failing. And the model's previous output is handed back as the thing to correct, so it is editing rather than regenerating from scratch the retry write-up. Instructor and similar libraries implement the same loop: capture the validation errors, format them as feedback, add that feedback to the prompt context, and ask the model to try again with the new information Instructor's retry documentation.
The cost argument is worth stating with numbers, so you can decide whether the loop is worth building. Suppose your extraction endpoint runs 100,000 calls a day and fails validation on 2 percent of them, which is 2,000 failures. Each correction call carries the original prompt (say 400 input tokens), the prior output (say 300 tokens), and the repair instructions (say 250 tokens). That is roughly 950 input tokens per correction, or about 1.9 million input tokens a day spent on repairs. A blind retry spends about 400 input tokens and 300 output tokens and succeeds far less often, so the second attempt frequently becomes a third. The targeted prompt costs more per attempt and needs fewer attempts. Cap the attempts, because each one consumes tokens and time, and some errors are simply not fixable by the model Instructor's retry documentation.



