Our AI agent wasn't slow. It was arguing with the rate limiter.
A support bot we maintained started feeling sluggish. No errors. No failed requests. Just... slow. Then expensive. Then "the AI is being weird":page tickets.
It took four days and a histogram nobody had thought to look at.
This is the postmortem of a silent failure — the kind where nothing crashes, nothing alerts, and the damage compounds quietly while every dashboard stays green. If you maintain anything with a language model in it, the shape of this story will feel familiar.
The symptom
Latency p95 climbed from about 4 seconds to 31 seconds over a week. Cost per request tripled. The failure rate stayed at 0.02%, so no alert fired. Users didn't report wrong answers — the answers were fine — they reported "it's slow now" and then, later, "it's slow again".
The histogram that broke the case
When we finally pulled the latency breakdown, the shape was wrong:
- p50: 3.1s (normal)
- p95: 31s (way up)
- provider-side round-trip time, measured separately: 2–3s (unchanged)
The round trip was fine. So the time was being spent between attempts, not inside them. That was the tell: this was not a slow model. This was our own client, looping.
We counted attempts per request and found the smoking histogram: a third of all requests were making 3–7 attempts, each one sleeping about a second in between.
What was actually happening
The provider had tightened per-minute quotas — a change on their side, invisible on ours. Our 429 handling was this:
for attempt in range(8): r = post(...) if r.status_code == 429: sleep(1) # <-- the bug continue return r A fixed one-second sleep against a per-minute quota is a busy-wait. Every retry landed inside the same quota window, burned a token, and re-triggered the limit. Eight attempts per request, eight quota tokens, at roughly eight seconds each. The system was not slow. It was politely arguing with the rate limiter — and losing, in a loop, at full price.
Worse: two of those attempts eventually succeeded, so the error rate stayed low enough that nothing paged. The only thing that looked wrong was cost — and cost alarms were on the daily budget, which absorbed the damage in silence.
The fix
def call_with_backoff(req, max_attempts=5): delay = 0.5 for attempt in range(1, max_attempts + 1): r = post(req) if r.status_code != 429: return r retry_after = r.headers.get("Retry-After") wait = float(retry_after) if retry_after else delay log({"attempt": attempt, "wait_s": wait, "quota_remaining": r.headers.get("X-RateLimit-Remaining")}) sleep(wait * (0.5 + random.random())) # jitter delay = min(delay * 2, 30) return r Three rules I extracted from this one incident and now apply everywhere:
- Honor
Retry-After. If the server tells you when to come back, that isn't a suggestion. And log the quota headers on every 429 — they tell you whether you're approaching a wall or already inside it. - Add jitter. Two workers waking from a synchronized backoff collide and re-trigger the limit together. Jitter de-synchronizes them.
- Alert on attempt count, not just error count.
p95(attempts) > 1.5is an early warning of a quota problem days before the error rate moves. Attempts are the fuel gauge; errors are only the smoke.
The general problem
This incident is one member of a family I've now seen enough times to have a taxonomy. I call them silent failures — they don't throw, they don't alert, and they're invisible to uptime monitoring, because every metric says the system is doing exactly what it should. Meanwhile the output is quietly wrong, stale, or far too expensive.
The seven families I keep running into:
- Retry storms — looks like a slow model; actually your client arguing with a rate limiter (the one above)
- Cached stale context — yesterday's truth served with today's timestamp
- Tool-call degeneracy — the agent asks the same dead tool 400 times, every failure "handled", none acted on
- Silent truncation — the JSON that parsed beautifully and lost half its data
- Quota swallow — HTTP 200 with a degraded brain behind it
- Context poisoning — one early hallucination becomes canonical truth that every later turn cites back
- Eval drift — your eval set stopped measuring anything
Every one of them survived our validation layer, our dashboards, and our on-call rotation — because all of those check the wrong thing.
The free excerpt
The full retry-storm chapter — including the detection one-liners and the fix — is in the repo of a field guide I've put together from a year of chasing these:
👉 https://github.com/derbaroser-eng/agent-reliability-forensics
The repo has the chapter as markdown, plus the observability layer that goes with it: the log envelope (log the request before you parse the body — if parsing throws, the envelope survives), response fingerprints, a tool-argument hash degeneracy counter, and the four one-liner queries that answer most incidents:
# Q1: anything stopped abnormally? rg '"finish_reason":\s*"(length|max_tokens|content_filter)"' calls.jsonl | tail # Q2: retry pressure — what share of traffic retried? rg -c '"attempt":\s*[2-9]' calls.jsonl # Q3: stale or canned responses — one fingerprint, many prompts jq -r .resp_fp calls.jsonl | sort | uniq -c | sort -rn | head # Q4: degenerate tools — same argument hash, repeated failures jq -r '.tool_calls[]? | [.tool,.arg_fp,.ok]|@tsv' calls.jsonl | sort | uniq -c | sort -rn | head The Python watchdog that ships with the guide is stdlib-only, has 11 passing tests, and runs python watchdog.py calls.jsonl to print every alert over a log. No dependencies, no services, no account.
If you take one thing from this
The failure that costs you the most is never the one that threw an exception. Detect latency dominates everything else: a failure caught in five minutes is a rounding error; the identical failure caught in five days is an incident. Optimise for time-to-detect, not for never-fail — because you cannot never-fail. You can always fail fast and loud.
If you've chased one of these seven families yourself, I'd genuinely like to hear which one got you — the comments are open.
