Same Saavi narration, smaller file. Opus 48k preferred — auto-selected by your browser.
Scenario anchor
Aap Aaranya IT BFSI ke ek senior architect hain — Mumbai ke ek large private bank
ka trade-reconciliation pipeline Claude pe migrate ho raha hai. Claude se
JSON output aa raha hai, lekin har tenth response mein ek malformed field
aa jaata hai aur downstream Kafka consumer crash ho jaata hai. Production
mein yeh acceptable nahi hai. Is lesson mein hum dekhenge ki validation-retry
loop kaise design karein — taaki Claude ka output har baar JSON Schema ke
against pass ho, aur agar na ho toh system gracefully retry kare bina
infinite loop mein phase ke.
Key Takeaways
Always enforce JSON Schema validation programmatically — never rely on Claude's self-reported confidence that output is valid; treat Claude like an external service whose contract must be verified at the adapter layer.
Inject the precise schema-diff error (field name, type mismatch, missing required key) back into the retry prompt so Claude has actionable signal, not just a generic failure notice — this mirrors structured fault messages in service-mesh circuit breakers.
Cap retries at 2-3 attempts with a fallback to a human-review queue or a simpler deterministic template; infinite loops are a budget and availability risk identical to an uncapped DB connection pool exhaustion.
Memory anchor — treat validation-retry like a schema-validation circuit breaker: validate at the boundary, feed back precise fault data, open the circuit after N failures.