Skip to content

    AI Architect Case Files

    Case: Billing Dispute Assistant and Retry Storms

    A telecom billing-dispute assistant drew its runtime sequence and found three layers retrying one failing call, multiplying load during an outage.

    By Published 8 min read

    • ai-architect
    • case-file
    • industry-telecom
    • pattern-runtime-sequences
    • failure-retry-storm
    • 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 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

    sequenceDiagram accTitle: Original billing lookup sequence with nested retries accDescr: The API gateway retries a failing call to the Orchestrator up to three attempts. Each attempt makes the Orchestrator retry the Tool server up to three attempts. Each of those makes the Tool server retry the billing system up to three attempts. All attempts fail during an outage. participant G as API gateway participant O as Orchestrator participant T as Tool server participant B as Billing system loop up to 3 attempts at the API gateway G->>O: customer question loop up to 3 attempts in the Orchestrator O->>T: get_charge_details(line_id) loop up to 3 attempts in the Tool server T->>B: read charge details Note over T,B: Outage - the call times out end end end Note over G,B: 3 x 3 x 3 = 27 calls reach the billing system for one question

    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

    Retry ownership across containersClient app to API gateway; API gateway to Orchestrator; Orchestrator to Tool server (tool call); Tool server to Billing system (read); Orchestrator to Document store (if billing down)OWNS RETRIESClient appClient appAPI gateway: 1 attempt, no retryAPI gateway1 attempt, noretryOrchestrator: 2 attempts, backoff, budgetOrchestrator2 attempts,backoff, budgetDocument store: nightly copyDocument storenightly copyTool server: 1 attempt, no retryTool server1 attempt, noretryBilling system: existingBilling systemexistingtool callreadif billing down

    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

    sequenceDiagram accTitle: Billing lookup sequence with one retry owner accDescr: The Orchestrator calls the Tool server, which makes one attempt at the billing system. If the call fails the Orchestrator may retry once after a backoff, but only if the retry budget allows it. If there is still no answer, because the retry also failed or the budget was spent, the Orchestrator reads the nightly copy and says how old it is. autonumber participant O as Orchestrator participant T as Tool server participant B as Billing system participant D as Document store participant E as Event bus O->>T: get_charge_details(line_id) with 2 s timeout T->>B: read charge details, one attempt alt billing replies in time B-->>T: charge details T-->>O: charge details else first attempt fails T-->>O: overload status, no retry in the Tool server Note over O: Decision - retry only if the budget allows opt retry budget allows one retry O->>T: get_charge_details(line_id) after 0.5 s backoff T->>B: read charge details, one attempt alt retry replies in time B-->>T: charge details T-->>O: charge details end end opt still no charge details Note over O: Budget spent or retry failed - use the degraded path O->>D: read nightly copy of charges D-->>O: charges with their date Note over O: Tell the customer the data is from the nightly copy end end O-)E: audit event with attempts and outcome

    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".

    One billing question during an outage (interactive when JavaScript is on)

    As designed

    1. Ask. The customer asks, "Why is line 3 charged twice this month?" The API gateway authenticates and forwards the question once. It does not retry this path.
    2. Model requests a tool. The model replies with a request for the charge-details tool.
    3. Call with a timeout. The Orchestrator calls the Tool server with a 2-second timeout.
    4. One attempt. The Tool server makes one attempt to the billing system.
    5. Success path. If billing answers, the model explains the charge, citing the lines it was given.
    6. Fail fast. If the call fails, the Tool server returns an overload status. It does not retry.
    7. Budgeted retry or fallback. If the budget allows, the Orchestrator waits 0.5 seconds and retries once. Otherwise it reads the nightly copy and says how old it is.
    8. Audit. One audit event records the attempts and the outcome.

    Without the fix

    1. Gateway attempt. The API gateway forwards the question and retries up to 3 attempts.
    2. Orchestrator attempt. Each attempt makes the Orchestrator call the Tool server, retrying up to 3 attempts.
    3. Tool server attempt. Each of those makes the Tool server read billing, retrying up to 3 attempts. In an outage every call times out.
    4. Multiplication. 3 x 3 x 3 = 27 calls reach the billing system for one question. At an assumed 40 questions a second that is 1,080 calls a second.

    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

    1. Retries have exactly one owner per call path. Every other layer fails fast and returns a clear overload status.
    2. Draw the sequence with the loops visible and multiply them. If the product is not a number you chose, fix the design.
    3. Cap retries globally with a budget, not only per request.
    4. Total timeouts must fit inside the customer's deadline, from the outermost layer in.
    5. 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

    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