You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: backend/src/services/ai-extractor.ts
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -65,9 +65,11 @@ Return a JSON object with:
65
65
- confidence: number from 0 to 1
66
66
- suggestedPrice: the correct price as a number (or null if scraped price is correct)
67
67
- suggestedCurrency: currency code if suggesting a different price
68
-
- stockStatus: "in_stock", "out_of_stock", or "unknown" - based on whether the product can be purchased RIGHT NOW
68
+
- 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.
69
69
- reason: brief explanation of your decision (mention both price and availability)
70
70
71
+
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".
72
+
71
73
Only return valid JSON, no explanation text outside the JSON.
72
74
73
75
HTML Content:
@@ -96,10 +98,12 @@ Signs the $VARIANT_PRICE$ variant is OUT OF STOCK:
96
98
- A different price is shown as the main purchasable option
97
99
98
100
Return a JSON object with:
99
-
- stockStatus: "in_stock", "out_of_stock", or "unknown"
101
+
- stockStatus: MUST be "in_stock" or "out_of_stock". Only use "unknown" if there is absolutely no availability information.
100
102
- confidence: number from 0 to 1
101
103
- reason: brief explanation focusing on the $VARIANT_PRICE$ variant specifically
102
104
105
+
IMPORTANT: If your reason mentions the product is unavailable, coming soon, pre-order, or has a future date, set stockStatus to "out_of_stock".
106
+
103
107
Only return valid JSON, no explanation text outside the JSON.
0 commit comments