From 72ae71017fb4416f397435f0d56e1f7d5ddf292f Mon Sep 17 00:00:00 2001 From: Bilal Godil Date: Mon, 29 Jun 2026 16:45:17 -0700 Subject: [PATCH] fix(backend): default improvementSuggestions to avoid false QA failures Review of the structured-output change found that requiring improvementSuggestions reintroduced the failure-row problem: for good answers with nothing to suggest, the model omits the field, which would throw NoObjectGeneratedError and store a false 'needs human review' verdict. Verified live: the model omits it ~5/6 of the time on clean answers. Default it to "" so omission is tolerated, matching the old code's lenient handling. --- apps/backend/src/lib/ai/qa-reviewer.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/lib/ai/qa-reviewer.ts b/apps/backend/src/lib/ai/qa-reviewer.ts index fab3afbb6..d171efaff 100644 --- a/apps/backend/src/lib/ai/qa-reviewer.ts +++ b/apps/backend/src/lib/ai/qa-reviewer.ts @@ -40,7 +40,9 @@ const qaReviewSchema = z.object({ severity: z.string(), explanation: z.string(), })), - improvementSuggestions: z.string(), + // Optional in practice: the model omits this for good answers with nothing to suggest. + // Defaulting (rather than requiring) avoids turning those into structured-output failures. + improvementSuggestions: z.string().default(""), overallScore: z.number(), });