Show answerHide answer
Correct answer: C Treat validation failures as a recognized error path that triggers retry, repair, or fallback logic before failing the user request.
Explanation
ExplanationThe problem is that validation failures are being treated as terminal — one bad output kills the whole request. The fix is to make validation failure a recognized, handled error path with graceful recovery before giving up:
- Retry — re-invoke the model, optionally with error feedback (e.g., "your previous output failed schema X; correct it").
- Repair — programmatically fix or re-parse the output (e.g., coerce or extract valid JSON, or apply a corrective prompt).
- Fallback — if retry or repair fails, degrade gracefully (e.g., a safe default, a partial result, or a human-review queue) rather than producing a hard user-facing failure.
This is the standard resilience pattern for structured-output pipelines: treat validation as a control point, not a dead end. Many validation failures are transient or correctable, so retry and repair can recover a substantial portion of requests while reserving hard failure for the remaining cases. This also preserves the value of validation — catching malformed output — instead of removing it. ✅
Why the other options are incorrect
A — "Pass validation failures downstream and let each system decide": Pushes known-bad output into consumers, spreading the defect and shifting the burden to every downstream system. It also contradicts the purpose of validating output at the source.
B — "Disable validation until the cause is fixed": Removes the safety net entirely, allowing malformed output to reach users unchecked. You trade a handled failure for silent corruption.
D — "Tell users validation failures are unavoidable; do manual checks": Offloads an engineering problem onto users and accepts a broken experience. It is the opposite of graceful error handling.
References
- Anthropic structured-output and tool-use guidance — validate outputs and handle failures with retry and repair patterns.