For a week, our own verification tools were the loudest source of 429 on our own API. Every one of them already slept between requests. The sleeps were not lying โ they were just answering the wrong question.
A sleep controls one process's cadence. A server-side rate limit controls a key. If your tool is one process and the key is "this IP on this route group", sleeping is equivalent to limiting only while exactly one thing on that IP is talking. The moment a second process, a retry loop, or your own ad-hoc curl shares the IP, the arithmetic changes and the sleep stops meaning anything.
The limiter we run keys its counters as scope|clientIP. A "scope" is a route group: the catalog read routes, the per-service read routes, the compatibility surface, the paid surface โ each has its own budget, and buckets do not spill into one another. The exemptions are an operator-managed IP allowlist; a User-Agent string is never an exemption, because it is self-reported and therefore free to forge.
As measured on 2026-12-04, the per-IP budgets look like this:
| Surface | Bucket keys on | Budget |
|---|---|---|
/x402/*, /mcp โ anonymous read | that scope + IP | 600/min |
/x402/*, /mcp โ request carries a payment header | that scope + IP | 120/min |
/svc/* โ compatibility surface | that scope + IP | 120/min |
/api/stats, /api/services/:id, /service.html | one shared "global" bucket | 60/min |
Two things in that table do the damage. The paid surface has a smaller budget than the anonymous one, so a client that pays per call has less headroom than a crawler reading listings. And several unrelated paths share one global bucket โ a catalog sweep that reads stats, then per-service JSON, then the HTML detail page is spending from a single 60/min counter the whole way, however many different URLs it thinks it is visiting.
Because the sleep is per process, and the budget is per IP-and-scope. One request every 0.75 s is 80 requests/minute โ already a third over a 60/min bucket before any second process exists. Our catalog sweep slept between requests and still collected 429s, because the paths it walked (per-service JSON, the HTML detail page, stats) all draw from that one shared bucket. Add a second tool on the same IP and the sum only goes up; nothing in either tool's code records that.
This is also why adding a bigger sleep to every tool "worked" for a day and then stopped. The next tool added to the schedule shifts the sum, and nothing in any individual tool's code changes. A per-request sleep has no place to put the aggregate.
429s in a day. The server cannot tell them apart, and should not try: the honest key is the IP.
Before fixing the client, fix the reading. Our origin sits behind Cloudflare, so $remote_addr in the access log is an edge address for every request in the world. The real client is in X-Forwarded-For. If you count 429s by remote_addr, you will attribute the entire internet's throttling to a handful of edge IPs and learn nothing.
The second reading mistake is counting 429s globally. In one 48-minute window we saw 1,065 429s at the origin โ and 1,061 of them were a single third-party liveness crawler bursting on its own. Our own traffic in the same window was 59 requests, none throttled. A complaint ("your agent is flooding us") and the correct answer ("no, that's one crawler; here is the per-client breakdown") both require the same join: filter by client, then group by route scope.
What replaced the per-process sleeps is a tiny file-locked sliding window. Every process that talks to the API asks the same shared state file for a slot, so the budget is enforced across the whole box, not per script. We deliberately budget at half the server's number: the rest of the allowance belongs to interactive calls, retries, and anything else sharing that IP.
import fcntl, json, os, time
LOCK, STATE = "/var/tmp/agent-budget.lock", "/var/tmp/agent-budget.json"
WINDOW = 60.0
def take(key, budget_per_min):
"""Block until a slot is free in the shared (key, 60s) window."""
with open(LOCK, "a+") as lk:
while True:
fcntl.flock(lk, fcntl.LOCK_EX)
try:
st = json.load(open(STATE)) if os.path.exists(STATE) else {}
except ValueError:
st = {} # truncated by a crash: fail open
now = time.time()
hits = [t for t in st.get(key, []) if now - t < WINDOW]
if len(hits) < budget_per_min:
hits.append(now)
st[key] = hits
tmp = STATE + ".%d" % os.getpid()
with open(tmp, "w") as fh:
json.dump(st, fh)
os.replace(tmp, STATE) # atomic: readers never see half a file
fcntl.flock(lk, fcntl.LOCK_UN)
return
wait = WINDOW - (now - hits[0])
fcntl.flock(lk, fcntl.LOCK_UN)
time.sleep(min(wait, 1.0)) # re-check: another process may have gone
Three details matter more than the algorithm. The state write is tmp + os.replace, so a crash never leaves a half-written JSON that every later process has to guess about. The wait loop re-acquires the lock instead of sleeping the full window outside it, otherwise N waiters all wake at once and stampede. And the budget is per scope, because the server's buckets are per scope โ a single global counter would either over-throttle the wide read surface or under-throttle the narrow one.
On 2026-12-04 our host sent 11,562 requests to our own API; 220 came back 429. Four tool families accounted for 214 of them:
| Tool family | Requests | 429s |
|---|---|---|
| catalog sweep | 1,051 | 48 |
| alias registrar | 683 | 47 |
| verification probe suite | 2,418 | 104 |
| description guard | 306 | 15 |
After the shared limiter was wired into those four (21:43Z), the same host sent 1,828 requests before midnight โ including a five-minute scheduled sweep of 1,526 paid-surface probes, peaking at 361 requests in one minute โ and received zero 429s. The change was not "send fewer requests". It was "make the aggregate visible to every process before it sends".
X-Forwarded-For (from a trusted edge) and group by route scope before drawing conclusions.The budgets above are one gateway's, measured on one day; yours will differ, and a well-run API will change them as traffic changes. What does not change is the shape: a limiter is a keyed counter with a window, and every client that shares a key shares the arithmetic. If your agent's politeness is implemented per process, it is not politeness โ it is a coincidence that holds until the second process starts.