Triển khai NVIDIA Retail Agentic Commerce Blueprint: Merchant-Controlled

Agentic commerce đang mở ra một cách tiếp cận mới cho thương mại điện tử: AI agent không chỉ trả lời câu hỏi, mà còn có thể hỗ trợ tìm kiếm sản phẩm, đề xuất lựa chọn, điều phối giỏ hàng, áp dụng khuyến mãi và khởi tạo checkout theo ngữ cảnh hội thoại.

Tuy nhiên, trong một hệ thống commerce thực tế, không phải mọi quyết định đều nên giao cho LLM. Các thành phần như giá cuối cùng, tồn kho, thuế, phí vận chuyển, biên lợi nhuận, thanh toán, trạng thái checkout và order record phải được kiểm soát bởi merchant backend. Đây là những phần cần tính xác định, khả năng audit và ràng buộc nghiệp vụ rõ ràng.

NVIDIA Retail Agentic Commerce Blueprint là một reference implementation cho mô hình agentic commerce, tập trung vào cách AI agent có thể tham gia vào trải nghiệm mua hàng nhưng không thay thế vai trò authoritative của merchant system.

Repository chính thức:

git clone https://github.com/NVIDIA-AI-Blueprints/Retail-Agentic-Commerce.git
cd Retail-Agentic-Commerce

Source code:

https://github.com/NVIDIA-AI-Blueprints/Retail-Agentic-Commerce

1. Tư duy kiến trúc: agent hỗ trợ, merchant kiểm soát

Điểm cốt lõi của blueprint nằm ở boundary giữa AI agent và commerce backend.

Agent có thể hỗ trợ:

  • Hiểu intent của người dùng.
  • Tìm kiếm sản phẩm theo ngữ nghĩa.
  • Đề xuất sản phẩm phù hợp với ngữ cảnh.
  • Chọn promotion action trong tập hành động được phép.
  • Điều phối checkout flow thông qua tool call.
  • Hỗ trợ post-purchase messaging.

Merchant backend phải kiểm soát:

  • Catalog source of truth.
  • Pricing và inventory.
  • Tax, shipping và fulfillment option.
  • Discount eligibility và margin constraint.
  • Checkout session state.
  • Payment orchestration.
  • Order record và audit trail.

Nói cách khác, agent có thể hỗ trợ reasoning và orchestration, nhưng không được là nơi quyết định cuối cùng cho các trạng thái ảnh hưởng trực tiếp đến tiền, tồn kho, thanh toán hoặc đơn hàng.


2. Kiến trúc tổng thể

NVIDIA Retail Agentic Commerce Blueprint có thể được nhìn theo các lớp chính sau:

Layer Thành phần Trách nhiệm
Experience Layer Demo UI, Protocol Inspector, merchant widget Hiển thị checkout flow, agent activity, webhook event và trạng thái giao dịch.
Agent Interface Layer Apps SDK MCP server, MCP tools Cung cấp tool interface để agent host gọi search, cart, recommendation và checkout.
Protocol Layer ACP REST, UCP/A2A surfaces Chuẩn hóa contract cho checkout negotiation và commerce operations.
Commerce Backend Merchant API, checkout domain service Quản lý catalog, cart, checkout session, totals, discounts, order state và business rules.
Payment Layer PSP service Mô phỏng delegated payment, vault token và payment intent.
Agent Layer Promotion, Search, Recommendation, Post-Purchase agents Thực hiện reasoning hoặc workflow theo từng nghiệp vụ cụ thể.
Retrieval Layer Vector store, product embeddings Hỗ trợ semantic search và recommendation retrieval.
Observability Layer Phoenix, logs, metrics, UI activity Trace agent execution, protocol call, latency và state transition.
Inference Layer NVIDIA NIM / hosted API Cung cấp LLM và embedding inference.

Thiết kế này giúp agent tham gia vào trải nghiệm mua sắm mà không làm mất quyền kiểm soát nghiệp vụ của merchant backend.


3. Merchant-Controlled Checkout

Checkout là nơi thể hiện rõ nhất nguyên tắc merchant-controlled architecture. Một checkout flow tiêu chuẩn có thể được mô hình hóa như sau:

Product discovery
  -> Cart update
    -> Create checkout session
      -> Update fulfillment/payment context
        -> Delegate payment
          -> Complete checkout
            -> Create order record
              -> Trigger post-purchase workflow

Trong flow này, agent có thể hỗ trợ điều phối bước tiếp theo, nhưng checkout service phải là thành phần quyết định trạng thái cuối cùng.

Thành phần Agent có thể hỗ trợ Merchant backend phải kiểm soát
Product search Một phần
Recommendation Một phần
Promotion reasoning
Pricing Không
Inventory validation Không
Tax/shipping calculation Không
Discount enforcement Không
Payment orchestration Không
Checkout state Không
Order record Không

LLM không nên là nguồn tính toán cuối cùng cho giá, chiết khấu, tồn kho hoặc trạng thái thanh toán. Mọi output từ agent cần được backend validate trước khi ảnh hưởng đến checkout session.


4. ACP, UCP và A2A: protocol layer không phải business logic layer

Blueprint hỗ trợ nhiều protocol surface để agent hoặc external client tương tác với merchant system, bao gồm Agentic Commerce Protocol, Universal Commerce Protocol và A2A-style transport.

Kiến trúc nên được tổ chức theo hướng:

ACP REST
  -> Merchant API
    -> Checkout domain service

UCP / A2A
  -> Protocol adapter
    -> Checkout domain service

Điểm quan trọng là protocol adapter không nên chứa business logic riêng. Pricing, inventory check, promotion enforcement và checkout completion phải hội tụ về cùng một commerce domain service.

Cách thiết kế này giúp tránh sai lệch nghiệp vụ giữa các surface khác nhau. Dù client đi qua REST, MCP, A2A hay embedded widget, kết quả cuối cùng vẫn phải được quyết định bởi cùng một backend logic.


5. Apps SDK MCP và merchant-owned widget

Apps SDK MCP server đóng vai trò bridge giữa agent host và merchant backend. Thay vì để agent gọi trực tiếp vào nhiều internal API, MCP server expose một tập tool có kiểm soát.

Nhóm tool Trách nhiệm
Search tools Tìm sản phẩm theo query hoặc semantic intent.
Cart tools Thêm, xóa, cập nhật số lượng và đọc cart state.
Recommendation tools Gọi recommendation workflow.
Checkout tools Tạo, cập nhật và hoàn tất checkout session.
Tracking tools Ghi nhận impression, click hoặc conversion attribution.

Merchant-owned widget là một điểm thiết kế quan trọng. Agent có thể khởi tạo hoặc điều phối trải nghiệm, nhưng phần UI liên quan đến cart, checkout, payment confirmation hoặc merchant policy nên được render bởi merchant-controlled component.

Agent host
  -> MCP tool call
    -> Apps SDK MCP server
      -> Merchant API
        -> Checkout domain service
          -> Merchant-owned widget state

Cách tiếp cận này giúp merchant giữ quyền kiểm soát UX, validation, policy và audit trail ở các bước có rủi ro cao.


6. Promotion Agent: reasoning không thay thế enforcement

Promotion là ví dụ rõ nhất cho boundary giữa LLM reasoning và deterministic backend logic.

Một implementation an toàn nên đi theo pipeline:

Checkout context
  -> Merchant backend computes constraints
  -> Merchant backend generates allowed_actions
  -> Promotion Agent selects an action
  -> Merchant backend validates selected action
  -> Merchant backend applies discount
  -> Checkout totals are recalculated deterministically

Agent không nên tự tạo mã giảm giá, tự quyết định phần trăm giảm hoặc tự sửa tổng tiền. Agent chỉ được chọn trong tập action mà merchant backend cho phép.

Ví dụ cấu trúc allowed action:

[
  {
    "type": "apply_discount",
    "discount_code": "BUNDLE_10",
    "max_discount_cents": 1500,
    "reason": "Eligible bundle promotion"
  },
  {
    "type": "no_discount",
    "reason": "Margin constraint not satisfied"
  }
]

Các constraint phải được backend enforce:

Constraint Enforced by
Minimum margin Merchant backend
Promotion eligibility Merchant backend
Discount cap Merchant backend
SKU/category constraints Merchant backend
Final total recalculation Merchant backend
Audit log Merchant backend

Pattern này tận dụng LLM cho arbitration và natural-language reasoning, nhưng không giao quyền quyết định tài chính cho model.


7. Search RAG và Recommendation ARAG

Blueprint tách search và recommendation thành hai workflow riêng, dù cả hai có thể dùng chung retrieval infrastructure.

Tiêu chí Search Recommendation
Input chính User query User/cart/session context
Mục tiêu Tìm sản phẩm phù hợp với intent Gợi ý sản phẩm có khả năng bổ sung hoặc chuyển đổi tốt
Retrieval Semantic/vector search Context-aware retrieval
Ranking Relevance-oriented Relevance + business/context signals
Output Candidate products Ranked recommendations
Vai trò trong checkout Product discovery Cross-sell, upsell, personalization

Search nên tối ưu cho intent matching. Recommendation nên kết hợp nhiều signal hơn, bao gồm cart content, category affinity, product compatibility, prior interaction và business constraints.

Kiến trúc tổng quát:

Product catalog
  -> Embedding pipeline
    -> Vector store

User query/session context
  -> Retrieval
    -> Ranking
      -> Agent reasoning
        -> Product candidates / recommendations
          -> Merchant API validation

Kể cả khi recommendation agent đề xuất sản phẩm, merchant backend vẫn cần kiểm tra inventory, price, eligibility và policy trước khi sản phẩm được đưa vào cart hoặc checkout.


8. Delegated payment

Payment flow cần được thiết kế để agent không tiếp xúc trực tiếp với raw payment credentials.

Mô hình delegated payment:

Buyer payment method
  -> PSP service
    -> Vault token / delegated payment artifact
      -> Merchant checkout complete
        -> Payment intent / order record

Agent hoặc MCP tool có thể điều phối flow, nhưng PSP service và merchant backend mới là các thành phần chịu trách nhiệm với payment state.

Nguyên tắc Mục tiêu
Không để LLM xử lý raw card data Giảm rủi ro bảo mật và compliance.
Dùng delegated token Tách payment authorization khỏi agent reasoning.
Merchant backend xác nhận payment artifact Đảm bảo checkout completion có kiểm soát.
Idempotency key cho payment operation Tránh double charge hoặc duplicate payment intent.
Audit trail đầy đủ Hỗ trợ debug, reconciliation và compliance.

9. Checkout completion và order state

Checkout completion không chỉ là một API call thành công. Đây là bước chuyển trạng thái nghiệp vụ từ checkout session sang order.

Các điều kiện nên được validate trước khi complete:

Session exists
  -> Session is not expired/cancelled/completed
  -> Items are valid
  -> Inventory is available
  -> Totals are current
  -> Fulfillment option is selected
  -> Payment artifact is valid
  -> Promotion constraints are satisfied
  -> Order can be created

Kết quả cần kiểm tra:

Field / Signal Ý nghĩa
checkout_session.status = completed Session đã được đóng đúng trạng thái.
order.id tồn tại Merchant đã tạo order record.
totals khớp với backend calculation Không có can thiệp từ agent vào giá cuối.
Payment artifact được consume hợp lệ Payment flow được nối đúng.
Post-purchase event được trigger Downstream workflow hoạt động.
Trace/log có đầy đủ span Có khả năng debug và audit.

Agent có thể gọi checkout tool, nhưng checkout service phải là thành phần quyết định trạng thái cuối cùng.


10. Observability

Agentic commerce cần observability ở cả agent layer và commerce backend layer. Nếu chỉ nhìn response cuối, rất khó xác định lỗi đến từ retrieval, model reasoning, MCP tool, protocol adapter, checkout service hay payment service.

Layer Signal cần theo dõi
Agent workflow Input, output, selected action, latency, model call.
MCP tools Tool name, payload, response, error rate.
Protocol adapter ACP/UCP/A2A request, status code, schema validation.
Merchant API Checkout state transition, totals calculation, discount application.
Payment service Delegation request, token creation, payment intent status.
Retrieval Query, top-k results, score distribution, ranking output.
UI activity User action, widget state, webhook events.
Infrastructure Container logs, service health, resource usage.

Một demo kỹ thuật nên có ít nhất các bằng chứng sau:

  • Architecture diagram.
  • Protocol call trace.
  • Agent workflow trace.
  • Checkout state transition.
  • Payment delegation trace.
  • Order creation response.
  • Post-purchase event hoặc log.

Nếu chưa có runtime trace thật, không nên trình bày screenshot hoặc log như bằng chứng triển khai. Nên phân biệt rõ expected flow và observed flow.


11. Production hardening checklist

Blueprint là reference implementation. Trước khi áp dụng vào môi trường production-like, cần harden ở nhiều lớp.

Security

  • Không commit .env, API key hoặc webhook secret.
  • Rotate MERCHANT_API_KEY, PSP_API_KEYWEBHOOK_SECRET.
  • Thêm authentication và authorization cho internal API.
  • Không expose vector DB, tracing UI hoặc internal service trực tiếp ra Internet.
  • Bật webhook signature verification.
  • Kiểm soát CORS, CSP và widget origin.
  • Dùng secret manager thay vì plain environment file.

Data and state

  • Thay in-memory hoặc SQLite state bằng database phù hợp.
  • Dùng Redis hoặc durable store cho session/cache nếu chạy multi-instance.
  • Thiết kế idempotency cho checkout và payment operations.
  • Có migration strategy cho schema.
  • Có reconciliation job cho payment/order mismatch.

Reliability

  • Health check cho từng service.
  • Timeout và retry policy rõ ràng cho agent/tool calls.
  • Circuit breaker cho LLM, PSP và retrieval service.
  • Graceful degradation nếu recommendation hoặc search agent lỗi.
  • Queue hoặc event bus cho post-purchase workflow.

AI safety and control

  • Không để LLM tự quyết định giá, tồn kho hoặc discount.
  • Tool schema phải chặt chẽ.
  • Validate mọi model output trước khi mutate state.
  • Log prompt/input/output ở mức phù hợp với privacy policy.
  • Tách reasoning trace khỏi customer-facing response khi cần.

Observability

  • Trace end-to-end từ UI/MCP đến Merchant API và PSP.
  • Correlation ID cho checkout session, order và payment intent.
  • Metrics cho conversion, latency, error rate, tool failure và recommendation attribution.
  • Alert cho payment failure, duplicate checkout, webhook failure và inventory mismatch.

12. Kết luận

NVIDIA Retail Agentic Commerce Blueprint minh họa một kiến trúc phù hợp cho agentic commerce: AI agent tham gia vào interaction và orchestration, nhưng không sở hữu business-critical state.

Boundary cần giữ rõ:

LLM / Agent:
  - Intent understanding
  - Product discovery assistance
  - Recommendation reasoning
  - Promotion arbitration
  - Workflow orchestration
  - Post-purchase messaging

Merchant Backend:
  - Catalog source of truth
  - Pricing
  - Inventory
  - Tax/shipping
  - Discount enforcement
  - Checkout state
  - Payment orchestration
  - Order record
  - Audit trail

Đây là pattern quan trọng khi đưa AI agent vào thương mại điện tử theo hướng production-grade. Agent có thể cải thiện trải nghiệm mua sắm và giảm friction trong checkout, nhưng merchant backend vẫn phải là authoritative system cho mọi quyết định liên quan đến tiền, tồn kho, thanh toán, compliance và trạng thái đơn hàng.


Tài liệu tham khảo

____
Bài viết liên quan
TAG: , ,