Skip to content

    Forward Deployed Engineer

    Integrating AI With Customer Order and Policy Systems

    Choose how an AI assistant reaches systems you do not own: API read, export, events or file drop, plus one approved, idempotent write behind an adapter.

    By Published 9 min read

    • fde
    • solution-architect
    • integration
    • idempotency
    • anti-corruption-layer
    Share

    This lesson is part of AI Solution Architect: Design Method and Patterns. Enroll for free, then sign in, to read it in full.

    What you'll learn: how to pick an integration style for each system the assistant must read from or write to, how an adapter keeps the customer's model out of your design, and how a write runs exactly once after a person approves it.

    At a glance

    Figure 1. How the Order and Policy Assistant reaches the customer's systems

    Assistant integrations: adapter to the order system, export for policies, approval before writesOrchestrator to Tool server (reads status); Orchestrator to Approval service (proposes); Approval service to Tool server (approved, key); Tool server to API gateway (OMS calls); API gateway to Order system (same token); Policy library to Document store (export)OUR SERVICECUSTOMER'S ESTATEOrchestrator: assistant modelOrchestratorassistant modelApproval service: one useApprovalserviceone useTool server: adapterTool serveradapterDocument store: policy copyDocument storepolicy copyAPI gateway: platform teamAPI gatewayplatform teamOrder system: REST APIOrder systemREST APIPolicy library: owner: CommercialPolicy libraryowner: Commercialreads statusproposesapproved, keyOMS callssame tokenexport

    How to read this: statuses are read live; policy text arrives as a copy; the only write waits for approval and passes through the adapter.

    • Pick a style per system: freshness and failure differ.
    • An adapter translates; it holds no business rules.
    • A write needs approval and an idempotency key (a unique id that makes a repeat change nothing).
    • Your artifact: an integration map.

    Scenario

    Composite scenario, not a real company. Lumen Industrial Supply, a fictional distributor, has an order management system (OMS) with a REST API behind a gateway owned by the platform team. The policy library (62 documents) is owned by Commercial. The assistant is read-only in the MVP; phase 2 adds an address change. The platform team asks: "What will you call, and what happens when we are down?" Numbers are illustrative.

    What you will be able to do

    • Choose among five integration styles for a system and defend the choice.
    • Design an adapter so tools speak the assistant's model.
    • Describe a write that runs once after approval, including a retry.

    Prerequisites

    Core ideas

    Five ways to reach a system you do not own

    Figure 2. Integration styles for the assistant

    Style Fits when Freshness If it fails Customer changes Risk
    Live API read Current facts: order status Live Say so, never guess A read role, if none exists OMS load
    Replica or export Large or slow queries Age of copy Show the copy time A copy job Old data looks current
    Event subscription React to a change Seconds, if healthy Reconcile by reading A publisher, a topic Duplicates, gaps
    File drop Documents with no API Age of last drop Keep last good copy A folder, a schedule Superseded versions
    Approved write Phase 2 actions Live Outcome unknown: check A write role, a key Wrong or repeated change

    How to read this: lower rows ask more of the customer and cost more when they fail.

    Default: live API read, file drop for documents, events only when a use case needs them.

    Keep the customer's model out of the assistant

    Place an adapter between the assistant and the OMS. The Azure Architecture Center calls this the anti-corruption layer pattern: a facade or adapter between subsystems that do not share semantics, translating requests so one system stays unchanged without compromising the other's design. Tools speak the assistant's model; the adapter maps it.

    {
      "tool": "get_order_status",
      "input": { "order_id": "string" },
      "output": { "order_id": "string", "stage": "confirmed", "on_hold": true, "hold_reason": "credit", "as_of": "ISO time" }
    }
    OMS says Assistant model
    Status picked, held flag set stage: picked, on_hold: true
    Fields the tool does not need Dropped
    Error or empty body A named error, never an empty order

    The page lists costs: added latency and an extra service to manage. It also advises focusing the layer on translation and avoiding business rules or orchestration in it. So P-ORD-04 (changes after picked need warehouse approval) lives in the policy logic.

    Spot the flaw. A tool update_order is exposed straight to the model. On a timeout the orchestrator retries it, using a status cached ten minutes earlier. What breaks?

    Answer

    The model writes without approval, the retry has no key, and the cache may say confirmed for a picked order. Fix: read-only model tools, propose-approve-execute with a key, as_of on every status.

    A write that runs once

    Approval is a gate in code the model cannot press: see the approval gate. This page adds what the OMS must support. The key is created with the proposal and bound to the exact arguments the approver sees.

    Figure 3. Address change: propose, approve, execute once

    sequenceDiagram accTitle: Address change from proposal to one execution accDescr: The orchestrator asks the approval service to record a proposal with an idempotency key. An approver sees the exact arguments and approves. The approval service sends the execute call to the adapter. The adapter reads the order status again, sends the change to the OMS with the key, and stores the result under the key. A retry with the same key returns the stored result and does not call the OMS again. participant O as Orchestrator participant A as Approval service participant P as Approver participant T as Adapter participant S as OMS O->>A: propose change, key K A->>P: show exact arguments P->>A: approve A->>T: execute with K T->>S: read status again S-->>T: confirmed T->>S: change address, key K S-->>T: done T->>T: store result under K A->>T: retry with K T-->>A: stored result, no OMS call

    How to read this: the model appears only in the first step. Approval covers exactly the arguments shown, once. The second status read is the guard, because the order may have moved to picked since the proposal; it narrows the window, so also ask whether the OMS refuses the change itself.

    Stripe's API reference (as of 2026-11-04, API v1): the client generates the key, V4 UUIDs are suggested, a retry with the same key returns the saved response, different parameters under one key are an error, and keys may be removed after 24 hours. That is one provider's design, not a rule for the OMS.

    The IETF draft draft-ietf-httpapi-idempotency-key-header-08 is an active Internet-Draft, not a standard. It says a key must not be reused with a different payload (server should reply 422) and that a repeat while the original is in flight should get 409. Check both pages before relying on them.

    Questions for the customer's integration team

    Each answer goes in the integration map.

    1. Is there a read-only role for the OMS API, and what can it see?
    2. What are the rate limits and the busiest hour?
    3. Does the write endpoint accept an idempotency key or client reference, and does it refuse a change after picked itself?
    4. What does a timeout mean: applied or not?
    5. Can the OMS publish events, ordered and de-duplicated?
    6. How are policy files versioned, and who removes old ones?
    7. Which test environment has realistic data?
    8. Who is paged when the OMS is down?

    If the OMS accepts no key, the adapter can store keys itself, but it may crash after the OMS applied the change and before saving. Ask for a client reference or a way to read the order back.

    If you use MCP

    The Model Context Protocol (MCP) is one way to expose tools; this page does not require it. Its Tools page (as of 2026-11-04) says there should always be a human able to deny tool invocations, and that servers must validate inputs, enforce access controls and rate limit. It does not mention idempotency: the key is your design.

    Worked example

    Assumptions: illustrative; one lookup per order contact. Of 9,600 contacts a month, 5,280 (55 percent) are order contacts. The assistant handles 70 percent: 5,280 x 0.70 = 3,696 lookups, 154 per agent across 24 agents.

    That load is small: no replica, no events. Policy documents have no API: file drop.

    Integration Style Failure The assistant says
    Order status Live API read OMS timeout "I could not read order 10482 just now. Try again or check the OMS. I changed nothing."
    Policy library File drop Drop missing Answers from the last good copy and shows its date
    Address change Approved write Outcome unknown "The change may or may not have applied. Do not resend; check the order."
    Address change Approved write Order now picked "The order is picked: P-ORD-04 needs warehouse approval."

    The unknown outcome is the dangerous failure: the adapter retries only with the same key, then reports "unknown".

    At the customer: "Can you just read our database?" Say: "Not directly. The API enforces the permissions and rules you maintain, and you can change the database without breaking us."

    Practice task

    Build the failure table for the address change.

    1. Write what the agent sees when: approval is down; the OMS times out after the change was sent; the OMS rejects it; the approver clicks twice.
    2. Name the check or key that makes each safe.
    3. Add the eight questions to your integration map, each with an acceptable answer and a fallback.

    Check yourself: a double click returns the stored result; a rejection is reported, not retried; with approval down, nothing runs.

    Integration calls (interactive when JavaScript is on)

    The OMS is slow in the afternoon. Order status must be current. Which style do you keep?

    • A replica, with the copy time shown
    • The live API read, with an as_of time
    • Events instead of the API read
    Answer

    The live API read, with an as_of time. Status must be live and 154 lookups per agent a month is small. A replica is only as fresh as its copy.

    After approval the OMS call times out and the outcome is unknown. What does the adapter do?

    • Resend with a new key to be safe
    • Resend with the same key, then report unknown
    • Mark it failed so the agent proposes it again
    Answer

    Resend with the same key, then report unknown. If the OMS supports keys, the same key lets it recognise a repeat. A new key or proposal could apply it twice.

    Exercise

    Decision exercise. Choose a Figure 2 style for each Lumen integration: (1) order status during a call; (2) the policy library; (3) shipment tracking updates the OMS already publishes as events; (4) the address change. Defend one in four sentences: freshness, failure, what the customer changes, risk.

    Acceptance criteria: each choice names the style and what the assistant says on failure; the defended choice names a rejected alternative. Done when the platform team could read your four rows and know what to build or grant.

    Hint 1: freshness first

    How old may an answer be before it misleads?

    Hint 2: events are not free

    Events need a publisher and a topic on the customer side.

    Model answer for the defended row

    Address change: approved write through the API, because it must act on live state. Rejected: a file drop, which is stale and returns no result. The customer grants a write role and accepts a key. Risk: a repeated or wrong change, controlled by approval, key and a second read.

    Common mistakes

    • One style everywhere. Status and documents need different freshness.
    • Business rules in the adapter. They hide in translation.
    • Retrying a write with a new key. A new key is a new change.
    • Trusting a cached status for a write. Read again at execution.

    Knowledge check

    1. Why read order status live instead of from a replica?

    A stale status misleads agents and the load is small. A replica is only as fresh as its last copy.

    2. What does the adapter do and not do?

    It translates between the two models and limits the fields that pass. It holds no business rules.

    3. Why read the status a second time in the sequence?

    The order may have changed since the proposal. The second read catches a move to picked at execution. It is not atomic with the write, so the OMS should enforce the rule too.

    4. What happens when a retry arrives with the same key?

    The stored result returns and the OMS is not called again. Stripe describes this for a repeated key.

    5. Why call the IETF header a draft?

    It is an Internet-Draft (version 08), not a standard, so wording and status codes may still change.

    You can now

    • Add an integration map to your design pack.
    • Choose among five integration styles for a system you do not own.
    • Describe a write that runs once after approval.

    Further reading

    Last verified: 2026-11-04

    Next

    Latency, Capacity and Availability Targets for AI Design

    Enroll to keep reading

    Lesson 5 of 6 · AI Solution Architect: Design Method and Patterns

    Choose how an AI assistant reaches systems you do not own: API read, export, events or file drop, plus one approved, idempotent write behind an adapter.

    In the rest of this lesson

    • Worked example
    • Practice task
    • Exercise
    • Common mistakes
    • Knowledge check
    • You can now

    Enrolling is free. It unlocks every lesson in AI Solution Architect: Design Method and Patterns, tracks your progress across devices and keeps your quiz scores. The newsletter is optional.

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments