Parse the output before you use it
Structured output still needs validation at the application boundary.
A response can be valid JSON and still be wrong for the application. Validate field types and the rules the application depends on before saving it.
const result = ResultSchema.safeParse(response);
if (!result.success) {
return { ok: false, reason: 'invalid_result' };
}
Keep parsing failures separate from network failures. They need different recovery steps.