Skip to content

    AI Architect Case Files

    Case: Support Chat Costs Tripled, Routing and Caching

    A retail support assistant sent every message to its largest model and cost tripled after launch. A rules deflector, a router and prefix caching cut it back.

    By Published 7 min read

    • ai-architect
    • case-file
    • industry-retail-ecommerce
    • pattern-model-routing
    • failure-cost-overrun
    • kind-composite
    Share

    Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.

    This case belongs to Models, routing and inference for AI Architects.

    Context

    • An online retailer adds a support assistant (orders, returns, delivery, damage, payments) with two tools: order lookup and return label.
    • The budget came from a pilot with a 1,000-token system prompt; before launch it grew to 3,000 tokens.
    • Traffic reached 80,000 messages a day instead of 45,000, all on the largest approved model.

    Problem statement

    Measure Value
    Forecast 1,305 cost units (cu) a day
    First week's bill, implied 3,920 cu a day (3.0 times the forecast)
    Goal: cost At or below 1,305 cu a day at 80,000 messages
    Goal: quality On a 300-conversation review set, within 2 points of the largest-model-only baseline
    Goal: speed 95th percentile time to first text under 3 s

    Constraints

    • Answers about returns and refunds must match current policy.
    • Complaints, legal threats and payment disputes never go to a weaker model.
    • Customer data goes only to the approved provider.

    Why the traditional approach fell short

    Approach Where it breaks
    Rules or FAQ deflector Instant and almost free, but fails on mixed messages ("my parcel is late and I want to change the address") and anything that needs the customer's own order
    Classic intent classifier Needs labelled examples for every intent; fails quietly on new products
    Human agents Handle all of it, at the cost and queue time the assistant was meant to cut

    Options considered

    Option Verdict Reason
    A. Rules and FAQ deflector only (non-AI) Kept as the first stage Exact for about a quarter of messages; cannot handle the rest
    B. Largest model for every message Rejected The current design; 3.0 times the forecast
    C. Deflector, then a router (rules by risk, small model by default, escalation on low confidence), plus prefix caching Accepted Cuts expensive calls and the price of the long prompt
    D. One small model for everything Rejected Breaks the rule that sensitive intents never go to a weaker model

    Solution architecture

    Figure 1. Components of the routed support assistant

    Routed support assistant componentsClient app to API gateway; API gateway to Orchestrator; Orchestrator to Document store (FAQ first); Orchestrator to Model gateway; Model gateway to LLM provider; Model gateway to LLM provider; LLM provider to Model gateway (low confidence); Orchestrator to Trace store; Trace store to Eval service (sample)Client appClient appAPI gatewayAPI gatewayOrchestrator: deflector and routerOrchestratordeflector androuterDocument store: FAQ answersDocument storeFAQ answersModel gateway: stable prompt prefixModel gatewaystable promptprefixLLM provider: small tierLLM providersmall tierLLM provider: large tierLLM providerlarge tierTrace storeTrace storeEval service: sampled reviewEval servicesampled reviewFAQ firstlow confidencesample

    How to read this: the Orchestrator owns the routing decisions, the Model gateway owns the prompt prefix, and the arrow from the small tier back to the gateway is the escalation path.

    Figure 2. One message, with the escalation path

    sequenceDiagram accTitle: Runtime path for one support message accDescr: The Orchestrator checks the FAQ store first. If there is no match, rules decide whether the intent is sensitive. Sensitive intents go to the large tier. Others go to the small tier, which returns an answer and a confidence score. A low score escalates the message to the large tier. The result and the route are traced. autonumber participant C as Client app participant O as Orchestrator participant D as Document store participant M as Model gateway participant L as LLM provider participant T as Trace store C->>O: customer message O->>D: FAQ lookup alt FAQ match D-->>O: fixed answer O-->>C: answer, no model call else no match Note over O: Decision - sensitive intent goes to the large tier O->>M: prompt with stable prefix first, tier chosen M->>L: request to the chosen tier L-->>M: answer and confidence opt small tier and confidence below threshold M->>L: same request to the large tier L-->>M: answer end M-->>O: answer O-->>C: answer end O-)T: route, tier, tokens read from cache

    How to read this: the outer alt separates the free path from the model path, and the opt block is the only place a message costs two model calls.

    How AI solved it, step by step

    Step through one message, then switch to "Without the fix".

    One support message, routed and cached (interactive when JavaScript is on)

    As designed

    1. Message arrives. A customer writes, "My blender arrived cracked, can I return it?"
    2. FAQ lookup. The Orchestrator looks for an FAQ match. There is none, because the message names an order.
    3. Rules check risk. Rules test for sensitive intents (refund exceptions, complaints, legal, payment). A cracked item is a return, so the message goes to the small tier.
    4. Build the prompt. The Model gateway puts the 3,000-token prefix (policy, tone, tools) first and the order details and conversation last, so the prefix can be cached.
    5. Small tier answers. The small tier asks for the return-label tool and reports a confidence score.
    6. Escalate if unsure. Below the threshold, the same request is repeated on the large tier. This is the FrugalGPT cascade: a scoring function rates an answer, and it is returned if the score is above a threshold, otherwise the next model is queried.
    7. Trace it. The Orchestrator traces the route, tier and cached token count. A sample goes to review.

    Without the fix

    1. Message arrives. Every message goes straight to the model, FAQ questions included.
    2. Largest model, always. No router: a simple return question gets the largest approved model, like a payment dispute.
    3. Full-price prefix. The 3,000-token prompt is paid at the normal input price every time.
    4. The bill. At 80,000 messages a day the cost is 3,920 cu, 3.0 times the 1,305 cu forecast.

    Under the hood

    The key step is prefix caching (Under the hood: Prompt caching and prefix stability). As of 2026-10-22:

    • Anthropic's page says a cache covers the prompt in the order tools, system, messages, up to a marked block, and that hits "require 100 percent identical prompt segments".
    • The default lifetime is 5 minutes, refreshed on each use. Prompts shorter than a per-model minimum are processed without caching and without an error.
    • OpenAI's page says reuse requires the entire rendered prefix to match: stable content first, dynamic content last.
    • Both report cached tokens in the usage. Neither promises a hit.

    With write multiplier w, read multiplier r and hit rate h, the prefix costs h x r + (1 - h) x w times normal. With Anthropic's multipliers for its default 5-minute cache (1.25 write, 0.1 read, exceptions for some models), caching wins only above h = (1.25 - 1) / (1.25 - 0.1) = 21.7%.

    Try it: a write plus a read costs 1.25 + 0.1 = 1.35 against 2 uncached, so caching wins from the second request if the entry survives.

    Prefix cache break-even (5-minute cache, multipliers as of 2026-10-22) (interactive when JavaScript is on)
    Break-evenfrom request 2
    After 1 request(s): with cache / without1.25 / 1
    After 2 request(s): with cache / without1.35 / 2
    After 5 request(s): with cache / without1.65 / 5
    After 10 request(s): with cache / without2.15 / 10

    The router is a cascade: the 48,000 non-sensitive messages start on a small call (0.1 of a large one) and 15% escalate. Set escalation to 0.4.

    Small-tier cascade (cost relative to one large call, no caching) (interactive when JavaScript is on)
    Cascade cost per request0.25
    Always-large cost per request1
    Break-even escalation rate90.0%

    What went wrong / failure modes

    Failure What happens Mitigation
    Unstable prefix A timestamp or customer name at the top changes every request: hit rate zero, every request pays the write multiplier, 1,356 cu a day, above the 1,176 cu of the routed design without caching Static content first, a cached-token alarm, a test that the first 3,000 tokens are identical
    Prefix below the minimum Caching is silently skipped Check the minimum; alarm on zero cached tokens
    Confidently wrong small tier The score is itself a model output Calibrate the threshold on labelled conversations, keep sensitive intents on rules, sample weekly
    Escalation creep At 40% escalation instead of 15% the day costs 916.2 cu, still under the forecast, but 52% of model messages use the large tier (31,200 of 60,000) and escalated ones wait for two calls Track the escalation rate
    Quiet hours Low traffic lets the 5-minute lifetime lapse, so the first requests pay the write multiplier Hourly cached-token alarm; 942 cu at 50% hits

    Results

    These are illustrative targets, not measurements. Daily model cost at 80,000 messages:

    Design Daily cost (cu) Against the 3,920 baseline
    Everything on the large tier 3,920 100%
    Plus FAQ deflector (25% of messages) 2,940 75%
    Plus router (32% of model messages large) 1,176 30%
    Plus prefix caching at a 90% hit rate 610.8 15.6%

    The final design is 46.8% of the 1,305 cu forecast; at a 50% hit rate it costs 942 cu, still under. Quality and latency targets are untested until the review set is run.

    Tradeoffs and when NOT to use this approach

    • Practitioners disagree on whether one mid-tier model with caching is simpler and good enough; at lower volume it often is.
    • At low volume the saving may not pay for evaluation. Estimate it with the LLM cost estimator first.
    • Never route sensitive or regulated answers by confidence alone.

    Design rules extracted

    1. Cost the request with the production prompt, not the pilot prompt.
    2. Put stable text first and variable text last; tests protect the prefix.
    3. Route by risk with rules first, by confidence second, and send unknown cases up a tier.
    4. Track cache hit rate and escalation rate, each with a stated break-even.
    5. Keep the non-AI deflector for what it answers exactly.

    Assumptions

    Invented cost units (cu) per million tokens, not any provider's prices. Large tier: 10 input, 40 output. Small tier: 1 input, 4 output.

    • Pilot: 45,000 messages, 1,900 input (1,000 prefix plus 900), 250 output: (1,900 x 10 + 250 x 40) / 1,000,000 = 0.029 cu; x 45,000 = 1,305 cu.
    • Launch: 80,000 messages, 3,900 input, 250 output: 0.049 cu each; x 80,000 = 3,920 cu; 3,920 / 1,305 = 3.0.
    • Deflector: 25% (20,000) need no model call, its own cost excluded; 60,000 reach a model.
    • Router: 20% (12,000) sensitive, to the large tier; 48,000 to the small tier first, 15% (7,200) escalate. Large calls 19,200 (32%), small 48,000. Without caching: 19,200 x 0.049 + 48,000 x 0.0049 = 940.8 + 235.2 = 1,176 cu. A small call is 0.1 of a large call, so the 48,000 cost 0.1 + 0.15 = 0.25 of large-only (588 of 2,352 cu).
    • Caching: write 1.25, read 0.1, Anthropic's default 5-minute cache as of 2026-10-22 (others differ). Prefix multiplier = h x 0.1 + (1 - h) x 1.25. At h = 0.9: 0.215, so the 3,000 prefix tokens count as 645, 1,545 input-equivalent tokens: large 0.02545 cu, small 0.002545 cu; 19,200 x 0.02545 + 48,000 x 0.002545 = 610.8 cu. At h = 0.5: 2,925 tokens, 942 cu. At h = 0: 4,650 tokens, 1,356 cu.
    • The 900 history tokens are not cached; the tiers keep separate caches (assumed: the cited page does not say how caches are shared across models).
    • Escalation at 40%: large calls 31,200 (52%), cost 31,200 x 0.02545 + 122.16 = 916.2 cu.
    • The shares, hit rate, retailer, tools and review set are invented.

    Last verified: 2026-10-22

    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