AI Agents, Evergreen

How AI Agents Handle Rate Limits and Quotas

Cartoon robot agent bumping into a 429 ceiling barrier with a queue of tasks waiting behind it

What ai agent rate limits and quotas are, and why agents hit them harder

Understanding how ai agent rate limits work matters before an agent can be trusted with real work, because an agent does not make one careful request and stop. It loops, retries, calls tools in parallel and carries long conversations forward, and each step can consume requests, tokens or money. A limit that a single chat message would never approach can therefore stop an agent mid-task, leaving work half done and the user with no clear explanation.

Rate limits and quotas are often described with a simple working distinction: a rate limit caps use in a short window, while a quota caps use over a longer window or budget. That is useful, but it is not a universal definition. Providers use the terms differently, measure different things, and reset them at different times, so this article treats it as a working distinction and establishes the actual unit, scope, window and reset behaviour from each provider’s documentation for every example.

OpenAI’s documentation describes limits using requests per minute, requests per day, tokens per minute, tokens per day, images per minute and, for some streaming audio models, audio minutes per minute, and states that limits can be hit across any of those options depending on what occurs first. Google’s Gemini API documentation describes limits usually measured in requests per minute, input tokens per minute and requests per day, and states that exceeding any one of them triggers a rate limit error. Anthropic’s Messages API, as summarised from its documentation by several secondary sources, measures requests per minute, input tokens per minute and output tokens per minute separately for each model class. The providers agree on the shape of the problem — several independent ceilings, any one of which can stop a request — while differing on what is measured.

Agents hit those ceilings harder because one user request can become many model calls: a plan is broken into steps, each step calls the model, and each tool result is sent back for another round of reasoning. Retries and parallel work multiply demand when the system is already under pressure, and long tasks accumulate context, so later calls carry more input tokens than the first. A builder cannot treat a headline allowance as a guarantee for a whole run: configured limits and observed responses can differ, so live headers and the provider console are the reliable check for what is actually available. A self-imposed budget, such as a monthly spend cap set by the team, is a third kind of ceiling that must be kept distinct from provider and downstream API limits, because each calls for a different response.

How an agent knows it is being limited

The primary signal is HTTP status code 429, meaning too many requests. An agent should treat a 429 as a statement about pace or allowance, not that the request itself was wrong. The usual response is to wait and try again in a controlled way, while a 400 bad request or a 401 authentication failure should be fixed, not retried unchanged, since retrying a permanent error wastes the allowance the agent is trying to conserve.

The response headers turn a bare 429 into actionable information. OpenAI responses can include a Retry-After header giving the minimum seconds to wait before retrying a temporary rate-limit error, when present, plus headers for the request and token limits, the amounts remaining, and the time until each resets. Anthropic responses, as summarised from its documentation, carry a parallel set for requests, tokens, input tokens and output tokens, each reporting the limit, the amount remaining and a reset time in RFC 3339 format, with a retry-after header on a rate-limit 429. Reading the remaining and reset headers on successful responses too lets an agent see a limit approaching before a request is refused.

Not every 429 means the same thing. OpenAI distinguishes a 429 with the slow_down code, meaning the request rate increased too quickly, from a 503 overload response for a temporarily overloaded model; both should follow Retry-After when present. A spend-cap 429 is different: Anthropic’s documentation, as summarised by secondary sources, describes one carrying the same rate_limit_error type but an enforced_spend_limit_reached code and no retry-after header, where retrying cannot work until access resumes. OpenAI similarly warns that Retry-After does not mean quota, billing or other errors requiring user action can be resolved by retrying. A 529 response from Anthropic is provider overload across all users, not the caller’s own limit. The rule is to inspect the status code, error type and code, and headers together, and to log the request identifier providers include.

Backoff and retry: waiting without making it worse

Cartoon robot waiting calmly beside an hourglass while arrows bounce off a wall, with retry attempts spaced wider apart

When a request has been refused for a temporary limit, honour the wait time supplied. OpenAI advises treating Retry-After as a minimum, waiting at least that long and adding a small random delay so multiple clients do not retry at the same time. If Retry-After is missing or invalid, fall back to exponential backoff with jitter: wait briefly, then double the wait after each failure up to a cap, with randomness added so retries spread out. Without jitter, clients that failed together retry together and arrive in coordinated waves that keep the system overloaded.

A retry policy also needs a budget: limit the number of attempts and the total time spent retrying, so a background agent does not retry indefinitely. Choose a bounded number of attempts, a cap on the delay, and a total retry time for the workload — an interactive chat cannot wait as long as an overnight batch job. Each official OpenAI SDK automatically retries eligible 429 and 503 responses subject to its settings, and OpenAI notes that handling of Retry-After varies by SDK version and configuration. A builder adding their own retry layer must therefore disable the SDK’s retries or account for them, so nested loops do not multiply requests. Retry in one layer only, and know which layer owns the retry.

Retries must be safe to repeat. Reading information can usually be retried without harm, but sending an email, charging a card or writing a record cannot simply be sent again, because the first attempt may have succeeded even though its response was lost. Where a tool has side effects, the agent needs idempotency: a way to recognise a repeated request as the same operation, for example an idempotency key or a check that the effect already happened. If idempotency cannot be established, pause and ask a human, or record the uncertainty honestly, rather than retrying and hoping. Never retry errors that require user action, such as an exhausted spend cap.

Staying under the limit: pacing, queuing and concurrency caps

Recovery is only half the answer; the other half is shaping demand so the provider does not have to refuse it. A token bucket holds tokens up to a capacity, refills continuously at a fixed rate, and spends one token per request; an idle client banks tokens up to the cap and can then spend them in a burst. A leaky bucket, in its queue form, releases requests at a constant drain rate, so traffic leaves steadily no matter how it arrived. The token bucket tolerates bursts within a bounded average, while the leaky bucket guarantees smooth output. Either can be built on the client side as a gate in front of model and tool calls, set below the provider’s ceiling so normal variation does not push the agent over it.

Queues preserve work as well as pacing it: when demand exceeds the allowed rate, a queue holds the excess and the agent can prioritise an interactive request before a background refresh. A queue without a bound is dangerous, because latency climbs as work piles up, so it needs a bound and a clear policy for when it fills, such as deferring low-priority work or telling the user plainly. Concurrency caps address parallel demand: an agent that fans out to several tools at once can exhaust a per-minute allowance in a single second. Anthropic’s documentation, as summarised by secondary sources, makes this concrete: a 60 requests-per-minute limit may be enforced as one request per second, so a burst of 20 requests in one second can fail with plenty of minute-level headroom. Capping simultaneous calls and staggering parallel branches reduces bursts, and staying within an enforced rate also requires pacing calls and accounting for the relevant request and token allowances alongside concurrency control.

Reducing demand: fewer, cheaper calls for the same work

Demand reduction only helps if it is clear which resource is being reduced, because request count, token use and spend are different allowances. Caching repeated results reduces request count: a stored answer avoids a new call. Batching has a similar effect when several small pieces of work can be combined into one call, provided the combined call does not exceed a token or output limit. Trimming prompts and tool payloads reduces token use rather than request count: the agent still makes the call, but each call carries fewer input tokens.

Prompt caching needs precise description. For Anthropic, secondary summaries of its documentation state that tokens read from the prompt cache do not count toward the input tokens per minute limit, while uncached input and cache writes do count. Caching a long stable prefix therefore raises effective input throughput for an agent repeating the same system prompt or context, without reducing request count, and a cache write still costs input tokens once. Choosing a smaller model or cheaper tool path mainly reduces spend. Switching alone does not create a separate allowance when limits are shared, but a replacement that consumes fewer counted tokens or requests can still reduce pressure on that shared allowance, so assess whether the replacement reduces the resource actually being limited. In short, caching and batching mainly attack request count, trimming and prompt caching mainly attack token use, and model choice mainly attacks spend. Measure which allowance is binding before choosing.

Working across a quota: budgets, degradation and escalation

Cartoon robot checking a nearly full quota gauge and deferring task envelopes into a calendar window

A quota spans a whole window, so an agent that spends its daily allowance on its first tasks will have nothing left for the rest of the day. It must track spend and remaining quota across the window, not per call, and record how much work remains and what it is expected to cost. Gemini’s documentation shows why the window matters: requests-per-day quotas reset at midnight Pacific time, and spend-based limits are evaluated on a rolling ten-minute window — 10 dollars for Tier 1 and 200 dollars for Tiers 2 and 3 — returning a 429 RESOURCE_EXHAUSTED error when exceeded. An agent watching only per-minute rates will be surprised by both resets.

When the budget will not stretch to the full task, degrade gracefully rather than failing silently or retrying: produce a partial result and say so, give a simpler answer, or defer the rest to the next window with a note of what was deferred. OpenAI warns that quota, billing or other errors requiring user action cannot be resolved by retrying, so a quota, billing or spend-cap error that requires user action is an instruction to stop and resolve the cap, not to wait and retry. A temporary spend-based rate limit is different: Gemini’s spend-based limit is evaluated on a rolling ten-minute window, so work hit by it can be deferred until sufficient allowance is available and retried under the bounded retry policy. Some cases should escalate to a human: a cap only a person can raise, side effects that cannot safely be repeated, or a run that has consumed much of a quota without reaching its goal. Pausing only helps if state is preserved — completed steps, results obtained, requests sent, and the stopping point — so the run can resume from the last completed step rather than paying twice. No provider source found for this research describes resume as a built-in feature, so treat checkpointing and idempotency keys as a design requirement, not a provider guarantee.

Common mistakes and limits

The most damaging mistake is the retry storm: many clients, or many branches of one agent, retrying at fixed intervals without jitter, without a budget and without honouring Retry-After, so a brief overload becomes sustained. The second is ignoring the headers: retrying after a fixed sleep regardless of what the provider said, or retrying a spend-cap 429 with no retry-after header that cannot succeed until the cap is resolved. The third is applying one global limit to providers and tools with different ceilings, which will be too generous for a stricter downstream API and too cautious for a more generous one.

Silent failure is the mistake users forgive least. An agent that swallows a 429, drops a step and reports success has hidden the limit, not handled it. Every refusal that changes what the user receives should be recorded and, where it affects the answer, disclosed. Nested retries are a quieter version of the same problem: an SDK retrying inside a framework retry inside an application retry multiplies attempts beyond anything intended, and the defence is to decide which single layer owns retries. Finally, client-side controls cannot remove provider change: limits, enforcement and pricing can change, so read live headers and the console rather than hard-coding a copied table. The realistic goal is not an agent that never sees a 429, but one that detects it quickly, waits sensibly, paces itself, spends its quota deliberately, and tells the user honestly when it cannot finish in the allowance it has.