Rate‑Limiting AI Agent Egress to Already‑Allowed APIs
说明与用途
问题:允许列表不限制请求频率,导致 AI 代理压垮 API。解决方案:在网关路由上应用本地请求速率限制,限制为 5 次请求/秒,初始突发 20 次。
问题
An egress allowlist does not control how often an AI agent can hit an allowed API, leading to excessive traffic that can overwhelm the target.
结果
The guarded route limited traffic to the configured burst and steady‑state rate, while the unguarded route allowed all traffic, demonstrating that a route‑level rate limit effectively protects an allowed API from agent overuse.
工作流
- 1. Configure agentgateway with a localRateLimit policy (maxTokens:20, tokensPerFill:5, fillInterval:1s, type:requests).
- 2. Deploy two gateway instances: one guarded, one unguarded.
- 3. Send 60 requests via curl to each route.
- 4. Verify guarded route returns 429 for excess requests and upstream receives only 20 requests.
- 5. Verify unguarded route forwards all 60 requests to upstream.
证据
An egress allowlist decides whether an agent can reach a destination. It has no opinion about how often.
The guarded route: localRateLimit { maxTokens: 20, tokensPerFill: 5, fillInterval: 1s, type: requests } Same 40 requests, same speed: 20 x 200, 20 x 429
scripts/verify.sh asserts the claim directly rather than eyeballing the demo output: it fires 60 requests through each route and checks that the unguarded upstream received all 60, the guarded upstream received fewer, and only the guarded route ever returned a 429.
- 记录日期: 2026-10-09T18:41:27.937Z