Validation Loop (Retry-with-Feedback)
PromptingDefinition
A pattern where structured output that fails validation is sent back to Claude with the specific error, requesting a correction. More effective than silent retries because Claude uses the error feedback to understand and fix the problem. Typically capped at 2-3 retries.
Example Usage
If JSON.parse() throws, send the error message back: 'Your output failed validation: {error}. Please correct and return valid JSON.'