From 84d088a8d196cfafbae5ef40a2fa54288e167e79 Mon Sep 17 00:00:00 2001 From: clucraft Date: Sun, 25 Jan 2026 20:39:30 -0500 Subject: [PATCH] Fix AI returning 'unknown' stock status for unavailable items Updated prompts to explicitly require 'out_of_stock' when the AI's reasoning mentions the product is not available, coming soon, pre-order, or has a future availability date. The AI was returning 'unknown' even when its reason clearly stated "not available for purchase right now" - now it must use 'out_of_stock'. Co-Authored-By: Claude Opus 4.5 --- backend/src/services/ai-extractor.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/services/ai-extractor.ts b/backend/src/services/ai-extractor.ts index 3245b75..c5a5b61 100644 --- a/backend/src/services/ai-extractor.ts +++ b/backend/src/services/ai-extractor.ts @@ -65,9 +65,11 @@ Return a JSON object with: - confidence: number from 0 to 1 - suggestedPrice: the correct price as a number (or null if scraped price is correct) - suggestedCurrency: currency code if suggesting a different price -- stockStatus: "in_stock", "out_of_stock", or "unknown" - based on whether the product can be purchased RIGHT NOW +- stockStatus: MUST be "in_stock" or "out_of_stock" - use "out_of_stock" if the product cannot be purchased RIGHT NOW (including pre-order, coming soon, future availability dates). Only use "unknown" if there is absolutely no availability information on the page. - reason: brief explanation of your decision (mention both price and availability) +IMPORTANT: If you mention in your reason that the product is "not available", "coming soon", "pre-order", or has a future date, you MUST set stockStatus to "out_of_stock", NOT "unknown". + Only return valid JSON, no explanation text outside the JSON. HTML Content: @@ -96,10 +98,12 @@ Signs the $VARIANT_PRICE$ variant is OUT OF STOCK: - A different price is shown as the main purchasable option Return a JSON object with: -- stockStatus: "in_stock", "out_of_stock", or "unknown" +- stockStatus: MUST be "in_stock" or "out_of_stock". Only use "unknown" if there is absolutely no availability information. - confidence: number from 0 to 1 - reason: brief explanation focusing on the $VARIANT_PRICE$ variant specifically +IMPORTANT: If your reason mentions the product is unavailable, coming soon, pre-order, or has a future date, set stockStatus to "out_of_stock". + Only return valid JSON, no explanation text outside the JSON. HTML Content: