Skip to content

Commit 84d088a

Browse files
clucraftclaude
andcommitted
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>
1 parent f1a055c commit 84d088a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backend/src/services/ai-extractor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ Return a JSON object with:
6565
- confidence: number from 0 to 1
6666
- suggestedPrice: the correct price as a number (or null if scraped price is correct)
6767
- 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.
6969
- reason: brief explanation of your decision (mention both price and availability)
7070
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+
7173
Only return valid JSON, no explanation text outside the JSON.
7274
7375
HTML Content:
@@ -96,10 +98,12 @@ Signs the $VARIANT_PRICE$ variant is OUT OF STOCK:
9698
- A different price is shown as the main purchasable option
9799
98100
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.
100102
- confidence: number from 0 to 1
101103
- reason: brief explanation focusing on the $VARIANT_PRICE$ variant specifically
102104
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+
103107
Only return valid JSON, no explanation text outside the JSON.
104108
105109
HTML Content:

0 commit comments

Comments
 (0)