Skip to main content

One Reschedule Touching Four Systems: Consistency Design for Cross-System Agent Calls

· 5 min read
Jack Ning
Maintainer of Bytedesk

"Nobody's home this Friday—change it to Saturday morning." This single sentence, for an agent, touches far more than one system: the order system reschedules, the warehouse re-picks and re-plans, transportation adjusts the delivery route, and if the reschedule fails, after-sales has to catch it. The most embarrassing failure: the order system returns "rescheduled", transportation times out without confirmation, the agent keeps retrying, and the transportation system ends up with two Saturday delivery tasks while the original Friday task is never cancelled—the user asked to "change once", the system delivered "double coverage". This is not the model being dumb; it is cross-system invocation missing a consistency design.

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 a multi-system tool invocation architecture for an AI Agent that calls the order, warehouse, transportation, and after-sales systems at the same time, and how it solves interface timeouts, duplicate execution, state inconsistency, and cross-system transaction failures. This is the engineering gate a logistics agent must pass on the way from "can query" to "can get things done".

Agent proposes a plan → Gateway controls calls → Systems execute → Reconcile and compensate

Five Key Design Points in Cross-System Consistency​

  • Architecture layering: the three layers—agent, tool gateway, business systems—each with cleanly separated responsibilities.
  • Stability design: combining timeouts, rate limiting, degradation, and asynchronization.
  • Idempotency and deduplication: idempotency keys, dedup tables, session locks, pre-execution state checks.
  • Consistency design: state machines, state queries, scheduled reconciliation—accepting eventual consistency rather than forcing strong consistency.
  • Distributed transaction understanding: the applicable boundaries of Saga / TCC, compensating transactions, and human fallbacks.

The Overall Design​

In this effort, I would first cut responsibilities cleanly, then talk consistency—jumping into distributed transactions with muddy layering only stirs the problem further. The overall approach in one sentence: three layers with clear duties, tiered timeouts with fast failure, idempotency against replay, reconciliation for consistency, and compensation as the cross-system safety net.

Step 1: Slice the architecture into three layers​

The agent layer only understands and orchestrates, never touching business state; a middle tool gateway unifies protocol, authentication, rate limiting, routing, logging, and error codes; the order, warehouse, transportation, and after-sales systems are the single source of truth. The core principle: the agent does not cache or re-process business data on its own, avoiding manufacturing state inconsistency itself.

Step 2: Tiered timeouts, slow operations go async​

Set tiered timeout budgets for every tool, covering both a single call and the whole task chain; fail fast on timeout instead of retrying without bound. Slow operations become async tasks + callbacks or polling, querying real state by task ID, paired with degradation strategies—so one slow interface never hangs an entire conversation.

Step 3: Idempotency keys plus dedup tables against duplicate execution​

Build the idempotency key from "business order number + operation type + logical request identifier": a retry of the same request reuses the same key, while a new legitimate reschedule from the user gets a new key—using only "waybill number + operation type" would wrongly block later operations. Persist a dedup table on the server side, paired with parameter fingerprints and result lookup; check the current state before executing—already done, return the result directly. Idempotency solves replay; cross-channel concurrent updates still need object-version checks or equivalent concurrency control.

Step 4: Accept eventual consistency, calibrate with state machines and reconciliation​

Do not chase strong consistency. Manage cross-system flows with a state machine, calibrate real-time state through state queries, then run scheduled reconciliation as the safety net: when order, warehouse, and transportation states disagree, trigger compensation or alerts—instead of finding out from user complaints.

Step 5: Handle cross-system failure by reversibility, human fallback with a summary​

Reversible steps use Saga compensation, each step designed with a reverse action—for example, a failed reschedule restores the original delivery plan; consider TCC only where resource reservation exists and downstream supports it; bridge local transactions and message publishing with a transactional outbox. What truly cannot be compensated goes to humans with a full summary. Finally, add full-link tracing, unified error codes, success-rate dashboards, and alerts, so you can quickly locate which system is slow and which interface has a high error rate.

Practice in Bytedesk​

In the open-source Bytedesk customer service system (GitHub, website https://www.weiyuai.cn ), tool management configures invocation entries for robots and agents to call order, warehouse, and transportation APIs, and invocation logs provide the basis for diagnosing cross-system chain failures; consistency exceptions that cannot be auto-repaired can go into tickets with designated owners and tracked status. The task coordinator, idempotency key storage, object-version checks, and reconciliation compensation belong to the business integration layer—a tool gateway and ticket flows by themselves guarantee no consistency; they must be implemented item by item per the downstream interfaces' guarantees.

Key Takeaways​

  • Layer the architecture first: the agent only orchestrates, the tool gateway centralizes control, business systems are the single source of truth—no caching or re-processing by the agent.
  • Tiered timeouts with fast failure; slow operations become async tasks with callbacks or polling; timeout budgets cover single calls and the whole chain.
  • Idempotency keys (business order number + operation type + logical request identifier) with dedup tables; check state before executing—idempotency guards replay, version checks guard concurrency.
  • Accept eventual consistency: state machine + state query calibration + scheduled reconciliation; compensate or alert when inconsistency is found.
  • Handle cross-system failure by reversibility—Saga compensation or human fallback with a full summary; full-link tracing and unified error codes keep failures locatable.