product_name: Áo polo nam basic dáng suông. \
master_color: Đỏ/ Red. 
product_image_url: https://2885371169.e.cdneverest.net/pub/media/catalog/product/8/t/8tp24a003-sr190-xl-1-u.jpg. 
product_image_url_thumbnail: https://2885371169.e.cdneverest.net/pub/media/catalog/product/8/t/8tp24a003-sr190-xl-1-u.jpg. 
product_web_url: https://canifa.com/ao-polo-nam-8tp24a003?color=SR190&utm_source=chatbot&utm_medium=rsa&utm_campaign=ver1. 
description_text: Áo polo nam basic dáng regular với bảng màu đa dạng, dễ dàng lựa chọn cho nhiều đối tượng khách hàng. 
material: None. 
material_group: Knit - Dệt Kim. 
gender_by_product: men. 
age_by_product: adult.
 season: Year. 
 style: Basic. 
 fitting: Regular. 
 size_scale: S|XXL|L|M|XL|XS|XXXL. 
 form_neckline: Classic Collar. 
 form_sleeve: Short Sleeve. 
 product_line_vn: Áo Polo. 
 product_color_name: Red 190



026-02-05 17:09:02,421 [INFO] common.starrocks_connection: ✅ Pool created successfully with recycle=280s
2026-02-05 17:09:02,736 [INFO] agent.tools.data_retrieval_tool: _execute_single_search done, products=50, build_ms=978.50, db_ms=343.53, total_ms=1322.04
2026-02-05 17:09:02,739 [INFO] agent.tools.data_retrieval_tool: 🔍 [DEBUG] First product keys: ['internal_ref_code', 'magento_ref_code', 'product_color_code', 'product_name', 'master_color', 'product_image_url_thumbnail', 'product_web_url', 'sale_price', 'original_price', 'discount_amount', 'discount_percent', 'description_text_full', 'max_score']
2026-02-05 17:09:02,741 [INFO] agent.tools.data_retrieval_tool: 🔍 [DEBUG] First product price: 799000.000000, sale_price: 399500.000000
2026-02-05 17:09:02,745 [WARNING] agent.tools.data_retrieval_tool: 🔍 [POST-FILTER] Starting with 50 products from DB. SearchItem params: product_name='Váy liền', gender='women', age='adult', color='xanh navy'
2026-02-05 17:09:02,747 [INFO] agent.tools.data_retrieval_filter: 🎨 [COLOR FILTER] Trying exact match for: xanh navy
2026-02-05 17:09:02,748 [WARNING] agent.tools.data_retrieval_filter: ⚠️ [COLOR] No exact match for 'xanh navy' → Trying mapping fallback
2026-02-05 17:09:02,754 [INFO] agent.tools.data_retrieval_filter: 🔍 [COLOR TOKENS] Extracted: ['xanh', 'navy']
2026-02-05 17:09:02,755 [INFO] agent.tools.data_retrieval_filter: 📍 [COLOR MAPPING] Tokens ['xanh', 'navy'] → DB colors: ['Xanh da trời/ Blue', 'Màu xanh Jeans']
2026-02-05 17:09:02,758 [INFO] agent.tools.data_retrieval_filter: ✅ [COLOR FALLBACK] Found 11 products in colors: ['Xanh da trời/ Blue']
2026-02-05 17:09:02,759 [INFO] agent.tools.data_retrieval_filter: 📝 [RECOMMENDATION] Shop không có màu 'xanh navy'. Chỉ có màu 'Xanh da trời/ Blue'.
2026-02-05 17:09:02,761 [WARNING] agent.tools.data_retrieval_tool: 🎨 COLOR FALLBACK: 'xanh navy' → 'Xanh da trời/ Blue' (11 products)
2026-02-05 17:09:02,762 [INFO] agent.tools.data_retrieval_tool: 💡 Alternatives: Xanh da trời/ Blue
2026-02-05 17:09:02,764 [INFO] agent.tools.data_retrieval_tool: 🎨 Color filter done: 50 → 11 products
2026-02-05 17:09:02,765 [INFO] agent.tools.data_retrieval_tool: 📊 Post-filter summary: 50 → 11 products.
2026-02-05 17:09:02,773 [INFO] agent.tools.data_retrieval_filter: 📦 Formatted 11 products (all flat - 1 product = 1 màu)
2026-02-05 17:09:02,775 [INFO] agent.tools.data_retrieval_tool: ⚡ Optimization: Truncating results 11 -> 8 for stock check
2026-02-05 17:09:02,775 [INFO] agent.tools.data_retrieval_tool: 🎁 Final result: 8 products. Fallback used: True. Stock enriched: False
2026-02-05 17:09:02,781 [INFO] agent.controller: 📦 Event #2 at t=5.93s | Keys: ['retrieve_tools']
2026-02-05 17:09:10,470 [WARNING] agent.streaming_callback: 🎯 FOUND product_ids at 1046 chars!
2026-02-05 17:09:10,472 [WARNING] agent.streaming_callback: ✅ Extracted 3 SKUs: ['6DS25S017', '6DS25S003', '6DS25S007']
2026-02-05 17:09:10,473 [INFO] agent.streaming_callback: ✅ product_ids found → response can return early (stream continues)
2026-02-05 17:09:10,475 [INFO] agent.controller: ⚡ Response ready at t=13.63s (early return)
2026-02-05 17:09:10,479 [INFO] agent.controller: ℹ️ Extracted ai_response via regex from streaming content
2026-02-05 17:09:10,480 [WARNING] agent.helper: 🛠️ [EXTRACT] Extracted 8 products from tool
2026-02-05 17:09:10,481 [INFO] agent.controller: ✅ Extracted 8 products from 2 accumulated messages
2026-02-05 17:09:10,482 [WARNING] agent.controller: 🎯 AI mentioned 3 SKUs → Filtered 8 down to 3 products
2026-02-05 17:09:10,488 [INFO] agent.controller: 💾 [PROD] Scheduling background task for user_insight extraction (post-stream)
2026-02-05 17:09:10,493 [INFO] agent.controller: chat_controller finished: cached=False
2026-02-05 17:09:10,495 [WARNING] api.chatbot_route: 🔍 [DEBUG] usage_info = {'limit': 5, 'used': 2, 'total_used': 2, 'guest_used': 2, 'user_used': 0, 'remaining': 3, 'reset_seconds': 24649, 'is_authenticated': False}
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mPOST /api/agent/chat-dev HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m
2026-02-05 17:09:13,810 [INFO] agent.graph: 🏁 Agent finished
2026-02-05 17:09:13,813 [INFO] agent.controller: 📦 Event #3 at t=16.97s | Keys: ['agent']
2026-02-05 17:09:13,814 [INFO] agent.controller_helpers: 🔄 [Background] Starting user_insight extraction for cdcdc3dfef
2026-02-05 17:09:13,818 [INFO] agent.controller_helpers: 💾 Updated User Insight for cdcdc3dfef: {
  "USER": "Nam, Adult, xưng anh.",
  "TARGET": "...
2026-02-05 17:09:13,818 [WARNING] agent.controller_helpers: ✅ [user_insight] Extracted + saved in 0.00s | Key: cdcdc3dfef
←[32mINFO←[0m:     127.0.0.1:64945 - "←[1mGET /api/agent/user-insight HTTP/1.1←[0m" ←[32m200 OK←[0m


┌─────────────────────────────────────────────────────────┐
│  User: "phụ kiện nào hợp với áo này?"                   │
└───────────────────────┬─────────────────────────────────┘
                        ↓
┌─────────────────────────────────────────────────────────┐
│  LLM (thông minh): Hiểu "phụ kiện" →                   │
│  Tự điền product_name = "Khăn/ Mũ/ Túi xách/ Tất"      │
│  (tách ra từng loại cụ thể thay vì gửi chung "phụ kiện")│
└───────────────────────┬─────────────────────────────────┘
                        ↓
┌─────────────────────────────────────────────────────────┐
│  Code split "/":  ["khăn", "mũ", "túi xách", "tất"]    │
│          ↓                                              │
│  PRODUCT_TYPE_MAPPING:                                  │
│    "khăn"     → "Khăn"         (product_line_vn)        │
│    "mũ"       → "Mũ"          (product_line_vn)        │
│    "túi xách" → "Túi xách"    (product_line_vn)        │
│    "tất"      → "Tất"         (product_line_vn)        │
└───────────────────────┬─────────────────────────────────┘
                        ↓
┌─────────────────────────────────────────────────────────┐
│  Filter: Chỉ giữ products có product_line_vn           │
│  == "Khăn" OR "Mũ" OR "Túi xách" OR "Tất"             │
│                                                         │
│  ❌ "Áo Cổ Cao Tay Dài" → loại bỏ                      │
│  ✅ "Khăn" → giữ                                       │
│  ✅ "Mũ" → giữ                                         │
└─────────────────────────────────────────────────────────┘