diff --git a/src/modules/ai/gateway/ai-gateway.service.ts b/src/modules/ai/gateway/ai-gateway.service.ts index bcf7c5e..d3ea50a 100644 --- a/src/modules/ai/gateway/ai-gateway.service.ts +++ b/src/modules/ai/gateway/ai-gateway.service.ts @@ -64,7 +64,7 @@ export class AiGatewayService { }); const safetyCheck = await this.contentSafety?.check(output.rawText, { contentType: 'ai_output' }).catch(() => ({ safe: true })); - if (!safetyCheck?.safe) throw new Error('AI output blocked by content safety'); + if (safetyCheck && !safetyCheck.safe) throw new Error('AI output blocked by content safety'); const parsed = this.parseJson(output.rawText, request.outputSchema); const estimatedCost = this.costCalculator.calculate(