Stateless RAG Architecture for Cross-Border E-Commerce Email Sales Agents

    This article presents a practical architecture for an email sales agent in cross-border e-commerce, built on stateless RAG and a layered memory design. It explains why static knowledge bases alone fail, how to separate static policies from dynamic user profiles, and how to combine an orchestration layer, a retrieval layer, and a four-part memory layer. It also covers context assembly, tool calling with human fallback, evaluation metrics, and a phased rollout plan.

    1. The Automation Gap in Cross-Border E-Commerce

    Across many offline industry discussions, a clear divide stands out: general AI capabilities have advanced rapidly over the past two years, while day-to-day cross-border e-commerce operations still rely heavily on manual work and spreadsheets. Many teams have not even automated order, logistics, and after-sales workflows, let alone made them intelligent. As competition shifts from “listing volume” and “creative quality” toward refined operations, the most underestimated link with the most direct impact on ROI is the quality of pre-sales and after-sales email handling.

    Email is one of the highest-information-density touchpoints in cross-border e-commerce. Customers often mix sizing questions, shipment follow-ups, return or exchange requests, and discount inquiries in the same email or across a few consecutive emails. Manual replies are costly and inconsistent, pure rule engines are rigid, and most deployed AI customer service solutions are still fundamentally one-shot question answering.

    2. Why Static Knowledge Bases Fall Short: Three Hard Limits of Stateless Retrieval

    First, context breaks. After loading return policies and size charts into a vector index, the model can answer “how do I return an item” but cannot answer “the last one was tight, should I size up this time,” because it does not know what “last time” refers to.

    Second, no user profile. Information a customer provides, such as height, weight, and a preference for loose fits, is discarded when the session ends. The next email starts from zero, so recommendations stay generic.

    Third, misaligned goals. Customer-service answers only aim to be correct; sales answers must be correct and move the conversation forward. That requires cross-selling and conversion guidance based on historical behavior, which depends on long-term state rather than a single retrieval.

    The conclusion is straightforward: introduce a readable and writable memory layer that can accumulate over time, and govern static specifications and dynamic profiles separately.

    3. Target Architecture: Orchestration Layer + Retrieval Layer + Layered Memory

    The design uses three decoupled layers so components can be replaced and rolled out gradually:

    • Orchestration layer: handles email triggers, task decomposition, tool calls, and human fallback. It can be provided by an automation platform with visual orchestration or a self-built service.
    • Retrieval layer: retrieval augmentation over enterprise specification documents, supporting common document format parsing, chunking, vectorization, and reranking.
    • Memory layer: four categories, static knowledge, short-term session memory, long-term user profiles, and behavior events, with unified writes and scenario-based recall.

    Illustrative pseudocode:

    1. # 1. Parse the email and history thread
    2. mail = parse_mail(raw)
    3. thread = memory.short_term.load(mail.thread_id)
    4. # 2. Extract and update the user profile (incremental, auditable)
    5. profile = extractor.update(mail.body, existing=memory.profile.get(mail.sender_id))
    6. # 3. Hybrid recall: specs + profile + behavior
    7. docs = rag.search(mail.body, top_k=8, rerank=True)
    8. facts = memory.profile.recall(mail.sender_id)
    9. events = memory.behavior.recent(mail.sender_id, days=90)
    10. # 4. Assemble context and generate
    11. answer = llm.compose(mail, thread, docs, facts, events,
    12. goal="resolve_and_convert")
    13. # 5. Write back to memory and audit log
    14. memory.short_term.append(mail.thread_id, answer)
    15. audit.log(mail.id, profile_delta=extractor.diff)

    4. Layered Memory Design: Profiles That Can Be Extracted, Updated, and Revoked

    A long-term profile works best as a dual track of structured fields plus a natural-language summary. Structured fields support rules and tool calls; the summary helps the language model understand tone and preferences. Fields can include baseline sizing, fit preference, category interest, price sensitivity, active region, and language style.

    Updates should follow three principles. First, incremental updates: write only new or corrected information from the current turn. Second, conflict resolution: when a new statement contradicts an old field, the newer timestamp wins and the change record is kept. Third, revocability: when a user says “do not remember this,” the system must be able to delete by field. This is both a compliance requirement and the basis of trust.

    5. Context Assembly and Prompt Constraints

    Context should be ordered by fixed priority: compliance and safety constraints first, then the task goal and output format, then retrieved specification snippets, and finally the user profile and recent behavior. Conflicting information needs an explicit arbitration rule, for example, policy terms take precedence over a user’s subjective description.

    On the output side, constrain the reply to “conclusion first, then evidence, then next step,” and require one clear next action, such as a sizing recommendation, an exchange link with a price difference, or a coupon explanation. This avoids polite filler that does not move anything forward.

    6. Tool Calls and Human Fallback

    The email scenario requires interaction with business systems. The tool layer should be abstracted into read-only and write categories. Read-only includes order lookup, shipment tracking, inventory, and size charts. Write includes creating exchange orders, granting benefits, and tagging tickets. All write operations need thresholds and a second confirmation. Low confidence or higher monetary amounts automatically route to a human, and the human conclusion is fed back into memory to close the loop.

    7. Evaluation and the Operations Loop

    Evaluation should cover at least four layers: factual correctness (whether policy is violated), memory hit rate (whether the profile is correctly referenced), conversion effectiveness (whether a next action is produced), and risk rate (unauthorized promises and privacy leaks). Before launch, build a replay set from historical emails for regression testing. After launch, sample and review weekly, and automatically turn bad cases into new specification documents or evaluation cases.

    Phase one: only “specification retrieval + thread memory” to stabilize accuracy first. Phase two: add profile extraction and sizing recommendations. Phase three: enable cross-selling and benefit granting, and gradually increase the share of automated handling. If using general cloud capabilities, object storage can hold documents, a message queue can smooth traffic peaks, a container platform can deploy the orchestration service, and logging plus monitoring and alerting can ensure observability.

    9. Conclusion

    The core difference of an email sales agent lies not in the model itself but in whether it has a memory that keeps evolving and a clear objective function. Governing static specifications and dynamic profiles in separate layers, then using the orchestration layer to connect tools and fallback, moves replies from “answering correctly” to “selling well.” This pattern also transfers to more digital-worker scenarios.