feat(rate-limit): bypass per-IP throttle for known AI crawler UAs (cherry-pick) - #616
Closed
Flotapponnier wants to merge 1 commit into
Closed
feat(rate-limit): bypass per-IP throttle for known AI crawler UAs (cherry-pick)#616Flotapponnier wants to merge 1 commit into
Flotapponnier wants to merge 1 commit into
Conversation
Collaborator
Author
|
Superseded. Will cherry pick the merged dev commit dea277d in a fresh PR with the expanded bot list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #615 onto main. SEO-critical, hot path to ship before the
next AI crawl cycle.
AI crawlers (PerplexityBot, GPTBot, ClaudeBot, etc.) often share a small
pool of egress IPs across many user queries. The per-IP rate limit on
/api/citable, /api/llm-context, /llms-full.txt (which re-exports
llm-context), /api/stat/[slug], /api/mcp/[transport] and adjacent
read-only endpoints was triggering 429 responses to legitimate AI
citation fetches, lowering OCB visibility in Perplexity, ChatGPT search,
Claude, and Google AI Overviews.
This change adds a User-Agent allowlist in rate-limit.ts. Requests with
a known AI crawler UA bypass the throttle without consuming a token.
Human traffic and unknown UAs remain throttled. UA spoofing is possible
but the read-only nature of these endpoints makes it a non-concern: we
WANT to be cited.
Allowlist patterns (case-insensitive substring match): GPTBot,
ChatGPT-User, OAI-SearchBot, ClaudeBot, anthropic-ai, Claude-Web,
PerplexityBot, Google-Extended, GoogleOther, CCBot, Bytespider,
Applebot-Extended, Amazonbot, Diffbot, YouBot, DuckAssistBot.
Optional
AI_BYPASS_DEBUG=trueenv var enables a one-line console logper bypass for debugging.
Adds tests covering: known AI UA bypasses a drained bucket, default
Chrome UA still throttled after capacity, missing UA defaults to
throttled, omitting the optional req argument keeps original behaviour.
Validation: