An AI agent is software that decides what to do next and then does it, usually by calling external APIs in a loop. The calls go to an LLM provider for completions, GitHub for pull requests, a ticketing system for updates, or a search service for context. Every call counts against a rate limit, the provider’s cap on how many requests or tokens it accepts from you in a time window. When you hit the cap, the provider answers with HTTP 429 Too Many Requests and rejects the call.
Agent workloads hit those caps faster than human-driven software because the loop removes the human. A person reads a response, thinks, and acts slowly; an agent retries immediately, fans out across subtasks, and keeps going when an API fails. In an LLM loop, every retry also appends tokens to the conversation context, so each attempt costs more than the last. One runaway agent can burn through a large share of a monthly budget in a single unattended run, and several agents retrying at the same instant can exhaust a provider’s hourly quota in 90 seconds.
The fix is layered budget enforcement. Cap what each user and each workload can spend, handle 429s with disciplined backoff instead of blind retries, and cache and batch to cut the request count. Circuit breakers stop runaway loops, and coordinating concurrent agents keeps them from retrying as a synchronized herd. Each layer covers a failure mode the others do not.
Why agents exhaust quotas faster than human-driven traffic
The most common production failure for LLM agents is the runaway loop: the agent decides to retry, each retry is a full provider call, each call appends to the context, and nothing stops it because no human is watching. TrueFoundry’s analysis walks through the arithmetic. A 4,000-token initial context that doubles at each step reaches 128,000 tokens at step 5, and the per-step cost is 32 times the first call. By step 15 the context overflows the model’s window and every call bills at the maximum-context rate. By step 30 the loop has spent more than a competent engineer’s monthly salary.
Multiple agents make the problem worse through synchronization. In one documented incident, nine agents launched simultaneously opened 10 pull requests in 22 minutes, but at minute 8 GitHub started returning 429s. Because every agent retried at the same time, the retry wave triggered a second 429 wave, then a third, and within 90 seconds the system burned through GitHub’s 5,000 requests per hour limit and was locked out entirely. The operator’s conclusion: "Rate limiting in multi-agent systems is a coordination problem, not a retry problem." That writeup also documents two follow-on failure modes. A cascade happens when rate-limited agents queue pending work and flush it all at once when the limit lifts, turning a single 429 into a system-wide outage that took up to 60 minutes to recover from. Priority inversion happens when a background agent consumes quota that a critical agent needs; in that incident a low-priority triage agent ate the remaining completions and blocked the decisions that mattered.
Because LLM providers bill per token, the cost of these loops compounds in a way request-based rate limits miss. A request cap stops a loop only when the loop is fast enough to hit the cap; a slower loop can grind through a large budget one expensive call at a time. With no per-user cap, one user’s runaway agent can exhaust a month of budget before anyone notices.
Budget tokens and requests per user
To budget for AI spend directly, use a token bucket, a rate limiting structure that maps onto how providers bill. Estimate the cost of each request in tokens and deduct it from the user’s bucket. When the bucket is empty, deny the request. The bucket refills over time, so each user gets a sustained allowance with room to burst. Arcjet’s example for the Microsoft Agent Framework uses a refill rate of 2,000 tokens per hour and a capacity of 5,000 tokens, tracked per user, so a user who has not spent recently can burst up to 5,000 tokens in one request or a short burst.
Cap more than tokens. A per-consumer limit should cover requests per minute, tokens per hour, concurrent requests, and input sequence length, because each dimension covers a failure mode the others do not. Requests per minute protects the provider quota and the deployment’s throughput, while tokens per hour tracks cost, since the same request count can carry wildly different token bills. Concurrency caps stop an agent from piling up parallel calls, and input length stops a single oversized context from consuming a large chunk of the budget.
Choose the bucket key by what you want to isolate. A single bucket per user is too coarse: one rogue script can starve all of that user’s legitimate work, including the work they need to debug the rogue script. A bucket per request protects nothing, because there is no sustained allowance to throttle. For agent workloads, key by user, workload, and model: a coding agent and a support agent for the same user should not share a bucket, and different models have different token prices. In a multi-tenant product, key by tenant and workload so one tenant’s runaway agent throttles only that tenant’s traffic, and set a platform-wide cost ceiling as a backstop for several tenants misbehaving at the same time.
Not every request should cost the same number of tokens. Baidu’s example service uses a 20-hour window with 80 base credits, charges 1 credit for simple Q&A and 4 credits for logical reasoning, and reserves 30% of quota for critical requests. The same shape works for agent APIs: a quick lookup costs one unit, a long multi-step reasoning call costs four, and the reserved slice guarantees that critical traffic is not starved by cheap high-volume calls.
For typical English text, estimate one token per four characters. That is accurate enough for budget enforcement where a small margin of error is acceptable. When the exact count matters, run the request through a real tokenizer such as tiktoken, which counts tokens the way the model does, instead of guessing from characters.
Handle 429s with backoff and jitter
When a provider returns 429, it has stopped processing your requests and tells you when to try again. Zendesk’s best practices are a good model for any API: read the rate limit headers on every response and check the account-wide limit before retrying, then pause until the reset time. The 429 response includes a Retry-After header with the number of seconds to wait.
Some APIs also expose their current quota in response headers. The RateLimit header fields proposal from the IETF, still a draft rather than a ratified standard, defines RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset, and RateLimit-Policy so servers can advertise how much quota is left. Two caveats matter. If a response contains both Retry-After and RateLimit-Reset, Retry-After wins and you should ignore the reset time. And a positive RateLimit-Remaining is a hint, not a guarantee: the draft is explicit that remaining quota does not guarantee further requests will be served and is not a service level agreement.
Handle 429s with exponential backoff and randomized delays: take the Retry-After value, add random jitter scaled by the attempt number, and wait that long before retrying. Baidu’s rate limiting guide recommends this shape, and the randomness is the important part. Every client that received a 429 got the same Retry-After value; if they all wait the same number of seconds and retry at the same instant, the herd hits the API again at the same moment. Jitter spreads the retries out. Set alert thresholds before you need them: a warning at 20% of quota remaining and a critical alert at 10%, while monitoring request rate, 429 frequency, and the share of high-cost requests. A client that keeps hammering past the limit eventually gets responses with no diagnostic value, which makes the outage harder to investigate.
Cut the request count with caching and batching
Before tuning backoff, look at what the agent fetches repeatedly. A request you never send is the cheapest one. If several agents read the same repository state, ticket list, or search results in a short window, cache the data with a short time-to-live (TTL) and let the agents read the cache. Zendesk’s guidance for reducing API requests is to eliminate unnecessary calls, cache frequently used data, and use bulk endpoints where they exist. Its Update Many Tickets endpoint, for example, updates up to 100 tickets in a single request. Combining several operations into one client-side request does not reduce the number of API calls the server processes; only a server-side bulk endpoint does. The same principle applies to any provider: check for a bulk variant before writing a loop that calls the single-item endpoint.
For model calls, the same approach is a semantic cache, which stores the answer to an earlier query and serves it when a new query is similar enough. It cuts spend and request volume, and it keeps the service alive when the provider is degraded.
Break runaway loops with circuit breakers and fallbacks
A token bucket caps how much a loop can spend, but it does not stop the loop; a runaway agent that stays under the cap can still waste money and quota. A circuit breaker is a switch that opens when API calls show a failure pattern, and while it is open the agent stops calling the provider and takes a different path. TrueFoundry’s guidance is to trip the breaker on pattern rather than volume: consecutive 429s above a threshold, which means the agent is not backing off correctly; an error rate above 50% in the last 60 seconds; cost velocity exceeding the planned budget times a configurable multiplier; and unusual call shape such as repeated identical prompts, loop signatures, or identical contexts with monotonically growing token counts.
When the breaker opens, route the agent through a fallback chain: primary model, then a cheaper model, then the semantic cache, then a clear 503 failure. Different routes need different chains. A coding pipeline may use a short chain because a degraded result is sometimes worse than a clear failure, while a legal or financial workflow may have no fallback chain at all so a human makes the call. The semantic cache makes the chain survivable: hit rates of 20-40% are typical in agent workloads, and a 30% hit rate can carry a service through most short provider outages by serving stored responses for similar queries.
Set the cost-velocity threshold relative to the workload’s planned budget, such as 10 times the planned rate, rather than a static dollar amount. Static dollar thresholds go stale as traffic and pricing change. Page on breaker trips, not on 429s. A 429 is a normal signal, and the breaker opening is the anomaly that deserves a human.
Coordinate concurrent agents sharing one quota
Several agents sharing one quota turns throttling into a coordination problem. They need a shared view of what quota remains and a policy for who gets it. The shared token pool approach gives each agent a reservation and a priority tier. Critical agents always get a completion if any quota remains. Standard agents use their reservation first, then draw from a donation pool. Background agents yield when the pool drops below 30% capacity, and idle agents donate their unused reservations automatically. A background agent denied for five minutes or more gets promoted to standard priority so it does not starve.
Two mechanisms make the pool safe. Leases prevent phantom allocations: each reservation is tagged with a timestamp and tied to the agent’s heartbeat, and a background sweep every 30 seconds reclaims reservations from agents whose heartbeat is stale by more than two minutes. Without leases, an agent that crashes mid-round keeps its reservation forever, so other agents get denied even though API quota is available. Priority retry windows prevent the herd from forming: critical agents retry first, standard agents next, and background agents last, so critical traffic consumes the available quota before lower tiers begin retrying.
A cascade detector is the final guard. When three or more agents get rate-limited within a 30-second window, the system switches from parallel to sequential mode: agents take an ordered lock and run one at a time. This stops the thundering herd before it forms. The same incident that produced the 429 waves showed why: the first wave came from the agents working in parallel, and the second and third waves came from the synchronized retries.
A shared quota state store that relies on file locking works only on a single machine. For multi-node deployments, use a distributed store with atomic operations and lease-based expiry, such as Redis or Valkey with TTL-based leases, or etcd with its lease mechanism, or run a sidecar governor on each node that coordinates centrally.
Roll out limits without breaking legitimate traffic
Enforcement has two failure modes: limits that are too tight break legitimate workloads, and limits that are too loose spend money. The safe sequence is to observe before you enforce. Run the buckets and breakers in audit mode first, where they log what they would have blocked but do not block anything. Then set thresholds at the 99th percentile (P99) of observed legitimate traffic plus a margin, and enable enforcement on one workload class at a time rather than across the whole system at once. Re-tune the thresholds quarterly as traffic changes, and default new workloads to audit mode until they have a traffic history.
DataRobot’s load test shows what sane enforcement buys. For a gpt-oss-20b deployment with 1,000 requests per minute of capacity and enforcement triggered at 80% utilization, normal traffic at around 600 requests per minute ran at 100% success with zero 429s. At 20 times overload, the rate limiter rejected 95% of requests while the model stayed healthy, with GPU utilization staying high and end-to-end latency stable after a brief spike. The limiter absorbed the overload instead of the model doing it.
When you reserve capacity for specific tenants or teams, leave headroom. DataRobot’s quota reservations guidance is to keep 10-20% of capacity unreserved for ad-hoc traffic, overflow, and new consumers. Size each reservation to the minimum throughput the consumer needs during peak contention, matching the reservation to business criticality rather than team size. A reservation guarantees the consumer a minimum slice of capacity that other consumers cannot take away; the unreserved pool absorbs everything else.
The common configuration mistakes are a bucket key that is too coarse, no fallback chain so every 429 hard-fails the agent, paging on every 429, and cost thresholds set as static dollar amounts instead of multiples of the planned budget. These four mistakes only show up after enforcement goes live, which is why audit mode matters.