From 4c92da7183e730c68802ca6779f337f048b058b4 Mon Sep 17 00:00:00 2001 From: Eliezer Steinbock <3090527+elie222@users.noreply.github.com> Date: Tue, 11 Nov 2025 11:59:55 +0200 Subject: [PATCH 1/2] Fix no match found prompt --- apps/web/utils/ai/choose-rule/ai-choose-rule.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/web/utils/ai/choose-rule/ai-choose-rule.ts b/apps/web/utils/ai/choose-rule/ai-choose-rule.ts index 28d151e76e..3a68ab0647 100644 --- a/apps/web/utils/ai/choose-rule/ai-choose-rule.ts +++ b/apps/web/utils/ai/choose-rule/ai-choose-rule.ts @@ -47,6 +47,7 @@ export async function aiChooseRule< const rulesWithMetadata = aiResponse.matchedRules .map((match) => { + if (!match.ruleName) return undefined; const rule = rules.find( (r) => r.name.toLowerCase() === match.ruleName.toLowerCase(), ); @@ -163,6 +164,7 @@ ${stringifyEmail(email, 500)} .describe("The reason you chose the rule. Keep it concise"), ruleName: z .string() + .nullish() .describe("The exact name of the rule you want to apply"), noMatchFound: z .boolean() @@ -170,10 +172,15 @@ ${stringifyEmail(email, 500)} }), }); + const hasRuleName = !!aiResponse.object?.ruleName; + return { result: { - matchedRules: aiResponse.object ? [aiResponse.object] : [], - noMatchFound: aiResponse.object?.noMatchFound ?? false, + matchedRules: + hasRuleName && aiResponse.object.ruleName + ? [{ ruleName: aiResponse.object.ruleName, isPrimary: true }] + : [], + noMatchFound: aiResponse.object?.noMatchFound ?? !hasRuleName, reasoning: aiResponse.object?.reasoning, }, modelOptions, From 7c982e54d2bb6c084293d6d8a259a340d025eb5f Mon Sep 17 00:00:00 2001 From: Eliezer Steinbock <3090527+elie222@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:02:11 +0200 Subject: [PATCH 2/2] v2.18.18 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 10d32e5477..c0715acb5a 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v2.18.17 +v2.18.18