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 Diagramming AI systems.
Context
- A telecom operator lets customers ask about a line on their bill and, if the charge looks wrong, open a dispute. The assistant runs in the customer app.
- A model reads the question, calls a billing lookup tool, explains the charge in plain language, and can call a second tool to file a dispute.
- The lookup reads from an existing billing system built for batch work and a few thousand human users, never sized for a chat front end.
- Before launch, the design review asks for a runtime sequence for the lookup, including what happens when billing is slow.
Problem statement
The review asks: when billing fails, how many calls does one customer question produce? Nobody can say, because the retry settings sit in three places. Drawing them as a sequence answers it.
Figure 1. Runtime sequence as first designed, with retries in every layer
How to read this: each nested loop is one layer's retry policy, and the note at the bottom is the product of the three loops.
Each setting is reasonable alone: platform default at the gateway, unreliable networks at the Orchestrator, the billing client at the Tool server. No one decided 27 was acceptable, because no one saw all three at once.
| Measure | Now | Goal |
|---|---|---|
| Calls to billing for one failing question | 3 x 3 x 3 = 27 | Retry factor capped at 2 |
| Customer's worst-case wait | Up to 54 s (see Results) | Under 20 seconds |
Constraints
- The billing system cannot be changed or scaled.
- The customer-facing deadline is 20 seconds.
- A failed lookup must not turn into an invented explanation.
- The dispute tool creates records, so repeating it must not create duplicates.
Why the traditional approach fell short
| Approach | Where it fell short |
|---|---|
| Call centre | Agents read the bill on a screen, so billing saw one human-paced request at a time |
| Rules-based bill explainer | Answers a fixed list of charge types and misses the long tail of unusual lines, credits and proration |
| Self-service bill page | Shows the bill and nothing about why |
The assistant fills the gap but changes the load: a model can call the same tool several times in one conversation, and billing must absorb every call.
Options considered
| Option | Idea | Why accepted or rejected |
|---|---|---|
| A. Keep per-layer retries, lower the counts | Two attempts per layer instead of three | Rejected: 2 x 2 x 2 = 8 calls, still multiplicative, and still no owner |
| B. One retry owner, others fail fast | The Orchestrator is the only layer that retries, with backoff and a retry budget. The gateway and Tool server make one attempt and return a clear overload status | Accepted: every failed call gets exactly one decision-maker |
| C. Cache and answer from a nightly extract (non-AI) | Charges are explained from a copy of the bill refreshed overnight, with no live call | Kept as the fallback when billing is down, labelled with the data's age. For many questions it is the simplest design |
Solution architecture
Figure 2. Retry ownership in the container view
How to read this: each box states its retry rule, solid arrows are live calls, and the red dashed arrow is the degraded path.
Figure 3. Runtime sequence with a single retry owner
How to read this: the outer alt separates success from a failed first attempt, the nested blocks show the one budgeted retry and then the degraded answer, and the notes mark the decisions the Orchestrator makes.
How AI solved it, step by step
Step through one question, then compare "Without the fix".
Under the hood
Retries compose multiplicatively. A layer making up to a attempts above a layer making up to b means a failing call at the bottom is made up to a x b times; a third layer with c attempts gives a x b x c.
| Source | What it says |
|---|---|
| Google SRE book | Warns against "amplifying retries by issuing retries at multiple levels". Three layers each allowing 3 retries (4 attempts) give 4^3 = 64 attempts on the database for one user action |
| AWS Builders' Library | A five-deep stack with three retries at each layer raises the load on the database 243x if each layer retries independently. Its best practice is to retry at a single point in the stack |
The sources count differently, so this page uses its own numbers. Both point to limiting retries: the SRE book suggests a server-wide retry budget (its example is 60 retries per minute in a process) and returning a specific status when overloaded so other layers back off; the AWS article describes limiting retries locally with a token bucket.
What went wrong / failure modes
| Failure | Mitigation |
|---|---|
| Timeouts stack: with a 2 s timeout and 3 attempts per layer, the Tool server layer takes 3 x 2 = 6 s, the Orchestrator layer 3 x 6 = 18 s, the gateway layer 3 x 18 = 54 s, and the 20 s deadline passes while the backend works on abandoned requests | One retry owner and a total timeout budget |
| The model asks for the same tool repeatedly, multiplying the load again | A step limit in the agent loop (see the state diagram in Diagramming AI systems) |
| Retry budget starved: during a long outage retries are refused | Intended: users see the degraded mode |
| Duplicate dispute records from a retried dispute call | An idempotency key on the dispute tool, reused across attempts |
| Stale fallback data: the nightly copy can be a day old | Show the date in the answer and never present it as live |
Results
These are illustrative targets, not measurements, at an assumed 40 questions per second.
| Measure | First design | With one retry owner |
|---|---|---|
| Worst-case calls to billing per question | 27 | 2 |
| Calls per second if every call fails | 40 x 27 = 1,080 | 40 x 2 = 80 |
| With a retry budget of 10% of calls | n/a | Retries capped at 4 a second, about 44 a second |
| Worst-case wait of one lookup | Up to 54 s (stacked timeouts) | 2 + 0.5 + 2 = 4.5 s, under the 20 s deadline |
Qualitative result: the multiplication was found on a diagram before launch.
Tradeoffs and when NOT to use this approach
- A single retry owner means lower layers cannot recover from a blip on their own; the Orchestrator must see the overload status.
- A retry budget refuses retries in long incidents. That protects billing but costs some customers an answer, so the degraded mode must carry them.
- If billing already handles high concurrency, the extra machinery may not be worth it. Measure its capacity first.
- Do not use cached data where freshness is the point, such as "was my payment received today?".
Design rules extracted
- Retries have exactly one owner per call path. Every other layer fails fast and returns a clear overload status.
- Draw the sequence with the loops visible and multiply them. If the product is not a number you chose, fix the design.
- Cap retries globally with a budget, not only per request.
- Total timeouts must fit inside the customer's deadline, from the outermost layer in.
- Every action that creates a record carries an idempotency key that survives retries.
Assumptions
- 3 attempts per layer includes the first attempt, so 3 layers give 3 x 3 x 3 = 27 attempts. (The Google SRE example counts 3 retries as 4 attempts per layer.)
- The 2 s timeout, 0.5 s backoff, 20 s deadline, 40 questions per second and 10% retry budget are chosen for illustration. 4 retries per second is 10% of 40.
- The timeout arithmetic assumes every attempt fails after the full 2 s, each layer waits for the layer below to finish all its attempts, and the first design has no backoff.
- In the second design the Tool server's own timeout is shorter than the Orchestrator's 2 s, so it can return the overload status in time; 4.5 s is an upper bound.
- The operator, billing system and layer settings are invented.
Last verified: 2026-10-21