hotfix: bypass per-IP rate limit for known AI crawler UAs - #617
Merged
Conversation
* feat(rate-limit): bypass per-IP throttle for known AI crawler user agents * rate-limit: expand AI bot allowlist to match robots.txt Adds Meta-ExternalAgent, Meta-ExternalFetcher, cohere-ai, Perplexity-User (all already in robots.txt), plus AI2Bot, Ai2Bot-Dolma, Kagibot, FacebookBot, MistralAI-User, TimpiBot, Webzio-Extended for completeness. Comment now states the regex must stay in sync with src/app/robots.ts. Western LLM coverage is at ~95 percent after this. Chinese models other than ByteDance (Bytespider) do not publish a documented bot UA, so they fetch via generic browser UAs and stay throttled by design.
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 (dev). Bypasses the in-memory token bucket on read-only API endpoints (/api/citable, /api/llm-context, /api/stat, /api/mcp, /api/freshness, /api/series, etc.) when User-Agent matches a known AI crawler pattern (GPTBot, ChatGPT-User, PerplexityBot, Perplexity-User, ClaudeBot, anthropic-ai, Google-Extended, Meta-ExternalAgent, Bytespider, cohere-ai, Diffbot, AI2Bot, etc.).
Pattern matches the full robots.txt allowlist plus a few extras. Western LLM coverage approx 95 percent. Chinese models other than ByteDance (Bytespider) do not publish a documented bot UA, so they remain throttled by design.
UA spoofing is possible but the affected endpoints are read-only and explicitly designed to be cited, so the worst case is what we already want.