Lv.1 0 XP

Output Validation — Two Layers, Specific Feedback, Retry Logic

Core 8 min +30 XP
💡
THE ANALOGY

A bank's multi-layer transaction validation. Layer 1: format check (is this a valid transaction structure?). Layer 2: business rule check (does the customer have sufficient funds?). Each layer catches different error types — neither alone is sufficient.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Thinking JSON schema validation is sufficient for production quality. Schema catches syntax errors. Business rule validation catches semantic errors — values that are syntactically valid but factually wrong. Both layers are required.

KEY POINTS
1 Layer 1: Schema/syntax validation — catches wrong types, missing required fields, invalid enum values.
2 Layer 2: Semantic/business rule validation — catches wrong values that pass the schema.
3 Retry-with-error-feedback: original document + failed output + SPECIFIC errors → retry prompt.
4 Retry works for format errors. It does NOT work when source document lacks the information — that produces fabrication.
5 Cap retries at 2-3 before routing to human review — unlimited retries waste cost.