Skip to main content

Policies via RAG, Orders via Live APIs: Dividing Knowledge from Facts in Logistics Agents

· 5 min read
Jack Ning
Maintainer of Bytedesk

Asked "how much will my insured shipping pay out", the bot instantly replies "up to three times the freight"—unaware this order was never insured; asked "why hasn't my package arrived", the bot recites the delivery-time policy—while tracking shows the parcel was held at customs last night. Both failures share one root cause: mixing "rules" and "facts" into a single knowledge base, letting retrieval substitute for queries. Logistics support knowledge is far more tangled than e-commerce: service policies, delivery rules, historical tickets, and live order data swirl together—without a clear division of labor, answers will always be wrong.

This post is part of the "AI Customer Service Product and Engineering Practices" experience-sharing series, drawn from a practice review of an AI customer service product at a leading logistics company. In this post I want to share how to coordinate RAG retrieval and live APIs when the knowledge base contains service policies, logistics rules, historical tickets, and real-time order data at the same time — resolving knowledge conflicts, stale information, and answer accuracy. This is the foundation of logistics agent accuracy.

Policies via RAG → Orders via live APIs → Arbitrate by authority and scope → Cite evidence and respond

Five Key Design Points in Dividing Knowledge from Facts​

  • Knowledge layering: how static rules, dynamic data, and historical cases divide responsibilities, instead of dumping everything into a vector store.
  • Retrieval design: combining hybrid retrieval, metadata filtering, time decay, and re-ranking.
  • Knowledge governance: versioning, validity periods, ownership, and update mechanisms must form a system.
  • Conflict arbitration: priorities and fallbacks when sources disagree.
  • Accuracy assurance: citation tracing, structured output, and evaluation regression.

The Overall Design​

The overall approach in one sentence: static knowledge goes through RAG, dynamic facts go through APIs, conflicts are arbitrated by authority, and answers carry citations.

Step 1: Layer the knowledge first​

  • Static knowledge: service policies, logistics rules, service SOPs—retrieved via RAG, governed by versions and validity periods.
  • Dynamic facts: order status, tracking trails, compensable amounts—must call live APIs; never answer from "memory" at any moment.
  • Historical tickets: serve only as similar-case references, never as factual evidence—fitting another user's case onto the current one is the classic mix-up in logistics support.

Step 2: Knowledge governance precedes accuracy​

Every knowledge entry needs a source, version, validity period, and owner; policies update synchronously when changed, expired entries trigger alerts, and indexes update incrementally. You cannot wait for user complaints to discover the rules are stale—logistics delivery policies shift between peak and off-peak seasons; without governance, the more accurately RAG retrieves, the more confidently it errs.

Step 3: Hybrid retrieval plus re-ranking​

Combine vector and keyword retrieval, filter by business line, region, and validity via metadata, weight recent rules higher, and re-rank to ensure ordering. Balance recall and precision—avoid "the outdated policy retrieved and ranked first".

Step 4: Arbitrate conflicts by priority​

The most critical layer. My priority: live business data > latest official policy > historical tickets. When retrieved rules conflict with system data, the system data wins, with the rationale stated in the answer; when undecidable, transfer to a human rather than force an answer. For "when will my package arrive", the answer comes from the latest tracking trail via API, not the standard delivery promise in the knowledge base.

Step 5: Answers with citations, regression by evaluation​

Answers must state which rule and which data source they rely on, organized as "conclusion + evidence + next action"; when uncertain, ask back or transfer to humans. Turn timeliness, conflict, and boundary questions into an evaluation set for regular regression, ensuring answers stay accurate after knowledge updates.

Practice in Bytedesk​

In the open-source Bytedesk customer service system (GitHub, website https://www.weiyuai.cn ), the knowledge base supports category and tag management, maintaining metadata such as business line and validity per entry to carry RAG retrieval of static policies; tool management connects live order and tracking APIs for agents to fetch dynamic facts by intent; conflicts between policies and states that cannot be auto-resolved can be assigned to owners via tickets. Policy metadata, pre-retrieval permission filtering, and arbitration priorities need to be implemented in the knowledge and business adapter layers per this post—a live query tool must not decide on its own which policy version applies.

Key Takeaways​

  • Knowledge splits into three layers: static rules via RAG, dynamic facts via live APIs, historical tickets for reference only—layering is the premise of accuracy.
  • Every entry carries source, version, validity period, and owner; expired entries alert automatically, and indexes update incrementally.
  • Arbitration priority: live business data > latest official policy > historical tickets; when system data conflicts with rules, the system wins with the rationale stated.
  • Organize answers as "conclusion + evidence + next action" with citations; ask back or transfer to humans when uncertain—never force an answer.
  • Turn timeliness and conflict questions into evaluation sets for regular regression; answers must stay accurate after knowledge updates.