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
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
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".
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.
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.
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
- Cost the request with the production prompt, not the pilot prompt.
- Put stable text first and variable text last; tests protect the prefix.
- Route by risk with rules first, by confidence second, and send unknown cases up a tier.
- Track cache hit rate and escalation rate, each with a stated break-even.
- 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