Báo Cáo Trạng Thái AI Extractor Pod & Kế Hoạch Chuẩn Hóa WhatsApp Production AI Extractor Pod Corporate Status & WhatsApp Production Engineering Plan
Đồng bộ 100% với mã nguồn thực tế tại technext-edge (cập nhật 20/09/2026,
thay bản 18/09 đã cũ). Webhook hai chiều Meta WhatsApp Cloud API đã thông mạch thật, xác nhận lại bằng
hội thoại thật trên sandbox hôm nay; toàn bộ 212/212 tests xanh (tăng từ 72 hôm 18/09); phát hiện 1
known limitation ở trích xuất guests (đã thử sửa prompt, chưa thành công) và 1 sự cố hạ
tầng bên ngoài (gateway DeepSeek trên Railway đang sập) — cả hai đều không chặn demo, chi tiết ở Phần 5.
100% verified against live code records in technext-edge (updated
20/09/2026, supersedes the stale 18/09 version). 2-way Meta WhatsApp Cloud API verified again today via
a real sandbox conversation; 212/212 unit tests passing (up from 72 on 18/09); one known limitation
found in guests extraction (prompt fix attempted, did not resolve it) and one external
infrastructure incident (DeepSeek's Railway gateway is down) — neither blocks the demo, see Part 5.
Bản chất Pod: Vai trò Edge BFF & Pipeline Trích xuất AIPod Core: Edge BFF Role & AI Extraction Pipeline
Extractor Pod chịu trách nhiệm chuyển hóa các tin nhắn tự do từ khách hàng (WhatsApp,
Webchat) thành dữ liệu đặt phòng có cấu trúc nghiêm ngặt (Trip) theo chuẩn Odoo của Phillip,
đảm bảo Zero Hallucination và kiểm soát 100% chi phí:
The Extractor Pod transforms unstructured incoming guest messages (WhatsApp, Web) into
strict, verified Trip entities aligned with Phillip's Odoo API guide, ensuring Zero
Hallucination and preventing financial discrepancies:
claimMessage(wamid), và gửi phản hồi dạng hội thoại tự do trong cửa sổ
24h.Consumes Meta Graph API webhooks, validates signatures, enforces deduplication
via claimMessage(wamid), and sends replies within the 24h service window.enforceVerbatimEvidence đối chiếu từng trường
stated: bắt buộc phải có trích dẫn đúng từng ký tự trong tin nhắn khách. Với yêu cầu xe mơ hồ
("có xe đón không?"), bot tuyệt đối không tự gán roundtrip mà giữ missing để hỏi
lại.enforceVerbatimEvidence drops any stated field
lacking exact verbatim substring proof. Ambiguous transport inquiries are retained as missing
rather than hallucinating roundtrip.dates.ts) xử lý
ngày số, tháng chữ ("21 September"), ngày tương đối ("thứ 7 tuần sau", "10月12日") thuần bằng mã TypeScript,
tuyệt đối không giao việc tính ngày cho LLM.Deterministic Manila date
parser (dates.ts) processes calendar dates, named months ("21 September"), and relative
phrases ("next Saturday", "10月12日") in pure TypeScript, never offloading calendar math to LLM.
converse.ts) trích xuất lại transcript (tối đa
60.000 ký tự) theo trần ADR-005a, tự động chọn câu hỏi cần ưu tiên hỏi tiếp (Check-in $\rightarrow$ Guests
$\rightarrow$ Rooms $\rightarrow$ Meals) đa ngữ (Anh, Việt, Trung).Conversational
engine (converse.ts) re-extracts dialogue up to 60k chars per ADR-005a cap, deterministically
selecting follow-up questions by priority across EN, VI, and ZH.Hiện Trạng Kỹ Thuật & Năng Lực Đã Chuyển GiaoCurrent Technical Deliverables & Verified Modules
Bảng tổng hợp các thành phần mã nguồn đã hoàn thành, tích hợp và kiểm chứng qua hệ thống 72 unit tests cô lập: Inventory of implemented components, integrated and verified through 72 isolated unit tests:
| Module / Thành phầnModule / Component | Mô tả Chức năngFunctional Description | Trạng tháiStatus | Bằng chứng Kiểm chứngVerification Evidence |
|---|---|---|---|
WhatsApp Inbound Loop |
Xử lý Webhook Meta, trích xuất text, gửi qua AI Extractor và đẩy phản hồi Graph APIHandles Meta Webhooks, extracts text, invokes AI pipeline, and dispatches Graph API reply | VERIFIED LIVE | Runbook §6 (commit 3713b93) xác nhận qua statuses webhook
MetaRunbook §6 (commit 3713b93) confirmed via Meta
statuses webhook |
Turn Timeout & Claim Release |
Giới hạn thời gian turn 20s, nhả wamid claim khi LLM lỗi để Meta redelivery không bị nuốt tinBounds turn to 20s, releases wamid claim on error so Meta redelivery is processed | COMMITTED | Commit 7c07aeb, 29 test cases trong
test/whatsapp.test.tsCommit 7c07aeb, 29 test cases
in test/whatsapp.test.ts |
Calendar & Named Dates |
Phân giải đa định dạng: "21 September", "21/9", "thứ 7", "ngày 20 tháng 11"Resolves named months, day/month without year, Vietnamese weekdays, and Chinese dates | 72/72 PASS | 9 test cases trong test/dates.test.ts pass 100%9 test cases in test/dates.test.ts pass 100% |
Split TTL & Fencing Token |
Tách TTL claim in-flight (60s) với TTL thread (24h), kèm fencing token chống stale turnSplits in-flight claim TTL (60s) from thread TTL (24h), with fencing token protection | IMPLEMENTED | 9 test cases trong test/conversationStore.test.ts9 test cases in test/conversationStore.test.ts |
Odoo Schema Alignment |
Bổ sung guestType, transportType, diveFrom,
diveTo, diverAdded guestType,
transportType, diveFrom, diveTo, diver
fields |
ALIGNED | Khớp với hướng dẫn API Odoo của PhillipAligned with Phillip's Odoo API Guide |
Báo Cáo Cho Lead: Điều Kiện Tiên Quyết Lên Production WhatsAppBriefing for Lead: WhatsApp Production Prerequisites
Hiện tại hệ thống kết nối qua Sandbox / Test Mode cá nhân (chỉ nhắn được 5 số trong Allowed List). Để đưa lên Production cho khách thật của Casa Escondida, Lead & Ban Quản trị cần chuẩn bị 4 trụ cột: Currently connected via Personal Sandbox / Test Mode (limited to 5 Allowed List numbers). To launch Production for real resort guests, Lead and Management must coordinate 4 pillars:
| Trụ cộtPillar | Hiện trạng Test/SandboxCurrent Sandbox State | Yêu cầu Production ThậtProduction Requirement | Bên Phụ trách & Thời gianOwner & SLA |
|---|---|---|---|
| 1. Pháp lý & Định danh Meta1. Legal & Meta BM | Tài khoản cá nhân dev, test app sandbox Personal developer account, sandbox test app | Meta Business Verification: nộp Giấy phép kinh doanh + Sao kê tài khoản khớp tên pháp nhân TechNext/Casa Meta Business Verification: submit Business Registration + Bank Statement matching legal entity | LEAD & PM (2-7 NGÀY)LEAD & PM (2-7 DAYS) |
| 2. Số điện thoại "Sạch"2. Clean Hotline Number | SIM cá nhân test trong Allowed List Personal test SIM in Allowed List | Bắt buộc xóa tài khoản WhatsApp trên điện thoại. Số kích hoạt Cloud API sẽ KHÔNG THỂ dùng song song với app điện thoại. Must delete WhatsApp account on mobile phone. Numbers on Cloud API cannot run concurrently on phone apps. | RESORT MANAGEMENTRESORT MANAGEMENT |
| 3. Cửa sổ 24h & Templates3. 24h Window & Templates | Nhắn tin text tự do không giới hạn template Freeform text messages without template limits | Sau 24h hoặc bot chủ động liên hệ: bắt buộc dùng Message Template duyệt trước (Utility: Báo giá, Re-engagement: Mở lại hội thoại). After 24h or for outbound outreach: requires pre-approved Message Templates (Utility quote, Re-engagement). | EXTRACTOR POD |
| 4. Vận hành Lễ tân (Handoff)4. Staff Inbox / Handoff |
Cờ paused đã có: GET /v1/channels/whatsapp/threads liệt kê thread đang chờ người thật
(khoá bằng x-verify-token), POST …/threads/<phone>/resume trả thread lại cho bot, và
npm run whatsapp:threads làm cả hai ngay trên terminal. Chưa có giao diện web.
The paused flag exists: GET /v1/channels/whatsapp/threads lists what a
person owes a guest (guarded by x-verify-token), POST …/threads/<phone>/resume hands one
back to the bot, and npm run whatsapp:threads does both from a terminal. No web inbox yet.
|
Khi bot dừng (paused: true), lễ tân dùng Staff Web Inbox trên BFF
hoặc nhận alert Telegram/Slack để tiếp quản.
When bot halts (paused: true), staff uses Staff Web Inbox on BFF
or receives Telegram/Slack alerts to take over.
|
POD & LỄ TÂNPOD & FRONT DESK |
| 5. Hạ tầng Kỹ thuật Stack5. Enterprise Tech Stack | Token 24h tạm thời, InMemoryStore Temporary 24h token, InMemoryStore | System User Permanent Token + HMAC SHA256 verification + Upstash Redis REST (Serverless không nghẽn TCP). System User Permanent Token + HMAC SHA256 verification + Upstash Redis REST (stateless serverless friendly). | EXTRACTOR POD |
Production Thật (Sau Thứ Hai): Kích hoạt quy trình duyệt Meta Business Verification cùng Ban Quản lý Resort và nạp thẻ thanh toán. Monday Demo (18–21/09): Maintain Sandbox + Allowed List + L0/L1/L2 hardening ($0 cost, 100% demo safe).
Production Go-Live (Post-Monday): Trigger Meta Business Verification workflow with Resort Management and attach billing credit card.
Kết Quả Thử Nghiệm Model & Lộ Trình Thực Thi 5 LànModel Benchmarks & 5-Lane Execution Roadmap
So sánh kết quả benchmark tự động 30 cases (10 EN + 10 VI + 10 ZH) và kế hoạch hành động 5 làn đóng băng hệ thống: Benchmark comparison on 30 mock cases (10 EN + 10 VI + 10 ZH) alongside the 5-lane system hardening roadmap:
| Tiêu chí Đánh giáMetric | DeepSeek Flash | Gemini 3.1 Flash-Lite | Ngưỡng PlaybookPlaybook Gate | Kết luận Kỹ thuậtTechnical Verdict |
|---|---|---|---|---|
| Bịa đặt (Fabrication)Fabricated Fields | 0 ✅ | 0 ✅ | 0 (CUTOFF) | ZERO HALLUCINATIONZERO HALLUCINATION |
| Trích dẫn nguyên vănVerbatim Evidence | 135/135 (100%) ✅ | 72/72 (100%) ✅ | ≥ 95% | ĐẠT CHUẨN CẢ 2BOTH PASS |
| Độ trễ p95p95 Latency | 2836ms ✅ | 4449ms ✅ | ≤ 8000ms | PASS (DeepSeek nhanh hơn 36%)PASS (DeepSeek 36% faster) |
| Tính ổn định (Rate limits)Call Reliability | 0 lỗi / 30 cases ✅ | 13 lỗi 429 🔴 | 0 LỖI0 ERRORS | Gemini Free-tier bị nghẽnGemini Free-tier throttled |
Lộ Trình Hành Động 5 Làn (Phê chuẩn 18/09) 5-Lane Action Roadmap (Approved 18/09)
| LànLane | Nhiệm vụ Cốt lõiCore Tasks | Thời gianTimeline | Mục tiêu Hoàn thànhCompletion Target |
|---|---|---|---|
L0 · Đóng băng & ShipL0 · Freeze & Ship
|
Tách 4 commit nguyên tử $\rightarrow$ push main $\rightarrow$ deploy
Vercel prod $\rightarrow$ đồng bộ §6 env vars
Split 4 atomic commits $\rightarrow$ push main $\rightarrow$ deploy
Vercel prod $\rightarrow$ sync §6 env vars
|
Hôm nay (18/09) Today (18/09) | SẠCH WORKING TREECLEAN WORKING TREE |
L1 · Chống tái phátL1 · Defect Prevention
|
GitHub Actions CI, root npm run verify, fix TS2532,
.gitignore logs & dataset
GitHub Actions CI, root npm run verify, fix TS2532,
.gitignore logs & dataset
|
19/09 | KHÓA TRẦN LỖI TYPEZERO TYPECHECK ERRORS |
L2 · Cứng hoá KênhL2 · Channel Hardening
|
Claim TTL 60s, Coalescing 2.5s gộp tin, tin nhắn tĩnh xin lỗi khi 429, Handoff tối thiểu Claim TTL 60s, Coalescing 2.5s rapid msgs, static 429 fallback msg, basic handoff | 20–21/09 | CHỐNG TREO & MẤT TINNO HANGS & NO LOST MSGS |
L3 · Hợp đồng Tất địnhL3 · Deterministic Contracts
|
READY_FIELDS, reply renderer tất định (renderAsk/renderConfirmation), xe đón không tự roundtrip READY_FIELDS, deterministic reply renderer (renderAsk/renderConfirmation), no auto-roundtrip | 22–23/09 | ZERO HALLUCINATION REPLYZERO HALLUCINATION REPLY |
L4 · Chờ bên ngoàiL4 · External Dependencies
|
Nhận Anthropic key từ Anthony $\rightarrow$ Claude adapter $\rightarrow$ chạy 30 tin thật của Eloa $\rightarrow$ ký ADR-005b Receive Anthropic key from Anthony $\rightarrow$ Claude adapter $\rightarrow$ eval 30 real msgs $\rightarrow$ sign ADR-005b | Khi có Key Upon Key Handover | BAKE-OFF CHÍNH THỨCOFFICIAL BAKE-OFF |
2. KHÔNG dựng Odoo Client hay endpoint tính giá ảo trước khi Phillip freeze schema.
3. KHÔNG tự động gán
transportType: roundtrip cho câu hỏi xe đưa đón mơ hồ.
1. NO sliding window or anchor prompt before measuring Turn 1 vs Turn 12 latency (Task
3.7).2. NO mock Odoo client or pricing endpoints before Phillip freezes schema.
3. NO automatic
roundtrip inference for ambiguous transport inquiries.
6 Lỗi Kỹ Thuật Thật Đã Bắt & Khắc Phục Trong Pod6 Real Technical Defects Caught & Hardened in Pod
Các sự cố phát hiện trong quá trình chạy thử nghiệm trực tiếp và giải pháp khắc phục triệt để: Issues uncovered during live webhook runs and rigorous automated test executions:
duplicates: 1) và bị im lặng bỏ qua. Đã sửa: Thêm trần
WHATSAPP_TURN_TIMEOUT_MS = 20s (commit 7c07aeb) và gọi
releaseMessage(wamid) khi thất bại.
When LLM providers lagged or timed out, turns lacked an overarching deadline. Furthermore,
wamid claims were never freed on error, causing Meta redeliveries to be discarded as silent duplicates.
Fixed: Added WHATSAPP_TURN_TIMEOUT_MS = 20s deadline (commit 7c07aeb) and
releaseMessage(wamid) on failure.
evidence: "21 September" nhưng
dates.ts cũ chỉ có regex cho YYYY-MM-DD và DD/MM/YYYY (bắt buộc năm 4
chữ số). Hàm trả về null dẫn đến post-processing xóa sạch trường checkIn thành
missing. Đã sửa: Viết lại bộ phân giải lịch hỗ trợ tên tháng tiếng Anh, định dạng
ngày/tháng không có năm, thứ trong tuần tiếng Việt và chữ Hán.
DeepSeek extracted valid evidence ("21 September"), but legacy dates.ts only
parsed strict 4-digit year dates. The null return wiped checkIn to missing.
Fixed: Implemented comprehensive calendar resolver supporting named months, yearless dates,
Vietnamese weekdays, and Chinese formats.
ExtractionValidationError.
Đã sửa: Phân tách rạch ròi lỗi hạ tầng (429/502) và lỗi dữ liệu Zod (422).
Gemini free-tier quota exhaustion was miswrapped into schema validation errors. Fixed:
Separated infrastructure errors (429/502) from schema validation failures (422).
zod-to-json-schema sinh exclusiveMinimum: true bị gateway từ chối.
Đã sửa: Viết hàm toDeepSeekSchema() chuẩn hóa bounds.
zod-to-json-schema emitted boolean bounds rejected by DeepSeek. Fixed:
Implemented toDeepSeekSchema() stripping unsupported bounds.
default của villa với model hallucination.
Scorer miscounted villa default room numbers as hallucinations. Fixed: Properly
decoupled default states from fabrications.
thinking: { type: "disabled" } triệt tiêu độ trễ thừa.
Conflict between thinking mode and tool calls pushed latency to 16s. Fixed: Enforced
disabled thinking mode to eliminate latency overhead.
guests Sai Khi Câu Có 2 Số
Khách Trần Trụi Cạnh Nhau:
BUG-EXT-07 (New, 20/09, NOT FIXED) — guests Extraction Fails on Two Bare
Guest-Count Numbers:
Câu kiểu "group of 6 but only 4 are staying" trả về guests: missing thay vì
bắt đúng số ở lại — dù đây chính là ví dụ mẫu viết sẵn trong system prompt của cả
gemini.ts và deepseek.ts. Tái lập 4/4 qua hội thoại thật, sau đó chính thức
hoá thành 4 case eval (en-06..en-09 trong dataset.synthetic.json), kéo điểm
required-fields của bộ 14 case từ ~98% xuống 89%. Đã thử sửa bằng cách thêm ví dụ cụ thể vào
prompt — không hiệu quả, xác nhận lại trên 2 model Gemini khác nhau qua preview deploy. Cân nhắc
và từ chối hướng vá bằng regex (rủi ro ghi đè sai lặng lẽ tệ hơn hỏi lại 1 lượt, và chỉ vá được
tiếng Anh). Cập nhật cùng ngày, phát hiện nghiêm trọng hơn: test thật trên WhatsApp cho thấy
cùng lỗi gốc có thể xoá luôn một field đã được xác nhận — khách đã cho biết 3 khách (stated),
hỏi thêm "does the baby count? I have an added person" ở lượt sau → guests bị xoá về
missing, phải khai lại. Tái lập được qua API. Câu kích hoạt này **rất tự nhiên** (khách
hay hỏi về trẻ em/thêm người), tự nhiên hơn nhiều so với câu mẫu ban đầu — nên rủi ro gặp phải trong
demo/thực tế **cao hơn đánh giá lúc đầu**. Hiện trạng: known limitation, an toàn (hỏi lại, không
bịa số, chỉ mất 1 lượt bổ sung), nhưng dễ gặp hơn dự kiến — đã thêm vào danh sách câu tránh dùng khi
demo. Chi tiết đầy đủ trong ADR-005a (3 mục "Update 2026-09-20").
A message like "group of 6 but only 4 are staying" returns guests: missing
instead of extracting the staying count — even though this exact shape is the system prompt's own
worked example in both gemini.ts and deepseek.ts. Reproduced 4/4 via real
conversations, then formalized into 4 eval cases (en-06..en-09), pulling the 14-case
required-fields score from ~98% to 89%. Attempted a prompt fix (concrete worked example) —
did not work, confirmed on two different Gemini models via a preview deploy. Considered and
rejected a regex-based fix (a silent wrong override is worse than one extra clarifying turn, and
it would only cover English). Same-day update, a more concerning trigger found: live WhatsApp
testing showed the same root cause can wipe an already-confirmed field — a guest who already
gave 3 guests (stated), then asked "does the baby count? I have an added person" in a follow-up turn,
had guests reset to missing and had to restate it. Reproduced via direct API
calls. This trigger is **far more natural** than the original phrasing (guests commonly ask about
children/extra people), so the real-world risk is **higher than first assessed**. Status: known
limitation, safe failure mode (asks again, never fabricates, costs one extra turn), but more likely to
occur than initially scoped — added to the demo's phrases-to-avoid list. Full detail in ADR-005a
(3 "Update 2026-09-20" entries).
litellm-production-7402.up.railway.app trả 404 "Application not
found" trên mọi endpoint kể cả /health — lỗi kiểu "app không còn tồn tại" của
Railway, đã xác nhận không phải do sai key. Hệ quả: chưa test được DeepSeek trên bug guests ở trên, và
production hiện đang chạy EXTRACTOR_PROVIDER=gemini thay vì deepseek-flash như
policy đã ghi — nghi vấn ai đó chuyển tạm khi gateway sập, chưa xác nhận với team. Đang có job
theo dõi tự động (hết hạn sau 7 ngày) chờ gateway sống lại để báo về.
litellm-production-7402.up.railway.app returns 404 "Application not
found" on every endpoint including /health — a Railway "app no longer exists"
error, confirmed not a bad-key issue. Consequence: DeepSeek could not be tested against the guests bug
above, and production is currently running EXTRACTOR_PROVIDER=gemini instead of the
documented policy default deepseek-flash — possibly switched as a stopgap when the gateway
went down, unconfirmed with the team. A monitoring job (auto-expires in 7 days) is watching for
the gateway to return.
app.ts/conversationStore.ts.
Hai webhook gần như đồng thời cho cùng 1 khách có thể chạy song song: webhook đầu đọc history khi tin
thứ hai chưa kịp ghi, trả lời hỏi lại đúng thứ khách vừa nói ở tin sau. Đề xuất: debounce ~1.5-2s theo
từng số điện thoại trước khi gọi converse(). Chưa sửa — cân nhắc để sau demo vì đổi timing
trên đúng đường chạy chính. Chi tiết trong roadmap L2.
No per-phone mutex/queue in app.ts/conversationStore.ts. Two
near-simultaneous webhooks for the same guest can run concurrently: the first reads history before the
second message is appended, replying with a question the guest already answered in the second message.
Proposed fix: a ~1.5-2s per-phone debounce before calling converse(). Not fixed — deferred
past the demo since it changes timing on the hot path. Detail in roadmap L2.
Checkpoints Thống Nhất & Điểm Chốt Với LeadAlignment & Sign-off Checkpoints with Lead
Bảng danh mục kiểm tra tương tác lưu trực tiếp trên trình duyệt (tự động đồng bộ localStorage): Interactive review checklist persisted via browser localStorage: