agentsclimarketplace

Rate limit no backoff

Skill viditkbhatnagar/immunize/src/immunize/patterns/rate-limit-no-backoff

A curated pattern library that stops AI coding assistants from repeating common runtime errors. No API key. No LLM calls at runtime.

Install
npx -y skills add viditkbhatnagar/immunize --skill rate-limit-no-backoff

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when calling HTTP APIs from Python to retry 429 responses with exponential backoff instead of crashing on the first rate-limit.

SKILL.md

1.8 KB, as published. Nobody here has run it

rate-limit-no-backoff

HTTP APIs return 429 when the caller is rate-limited. Code that ignores the status and calls raise_for_status() immediately crashes the whole script on the first throttle — even though a second attempt a few seconds later would almost always succeed:

requests.exceptions.HTTPError: 429 Client Error: Too Many Requests

Example

Wrong — happy-path only; dies on the first 429:

def fetch_user(client, user_id):
    resp = client.get(f"/users/{user_id}")
    resp.raise_for_status()
    return resp.json()

Right — bounded retry with exponential backoff on 429:

import time

def fetch_user(client, user_id, max_attempts=4):
    resp = None
    for attempt in range(max_attempts):
        resp = client.get(f"/users/{user_id}")
        if resp.status_code != 429:
            break
        time.sleep(2 ** attempt)
    resp.raise_for_status()
    return resp.json()

Respect Retry-After when present

If the server returns a Retry-After header (seconds or HTTP date), honor it instead of your own schedule:

wait = int(resp.headers.get("Retry-After", 2 ** attempt))
time.sleep(wait)

Cap total wait

Never let a backoff loop sleep indefinitely. A bounded attempt count (3–5) plus a ceiling on the delay (e.g. 30 s) keeps a slow upstream from freezing the caller's process forever.

Prefer a real HTTP client retry feature

requests.adapters.HTTPAdapter(max_retries=...), urllib3.Retry, and httpx.Client(transport=...) all support retry policies that cover 429 plus 5xx correctly. Reach for those before rolling your own loop — they handle jitter, connection failures, and Retry-After out of the box.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.