Repository navigation
feat(md-exports): Serve Markdown to an opt-in list of AI agents - #21036
Open
coolguyzone wants to merge 3 commits into
Open
coolguyzone wants to merge 3 commits into
coolguyzone wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Page URLs are served as Markdown to AI agents, but "AI agent" meant a hard-coded regex of 11 names. Add an opt-in allowlist, MARKDOWN_AGENTS, of assistants and coding agents that fetch pages to read them for a person (Devin, MistralAI-User, NotebookLM, opencode, and others). The names come from the ai-robots-txt list, which lists bots site owners may want to block rather than clients that want Markdown, so it's used as a discovery feed only. A weekly workflow syncs a snapshot of it into src/data/ai-robots-txt.json and opens a PR listing new names and what they do. Nothing reads the snapshot at runtime, so a new upstream name never changes routing until someone adds it to MARKDOWN_AGENTS. Add a docs.markdown.served counter, tagged with detection method and agent, to measure Markdown traffic before and after the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coolguyzone
force-pushed
the
coolguyzone/feat/ai-agent-ua-list
branch
from
December 2, 2026 23:35
ed8a670 to
695231b
Compare
MARKDOWN_AGENT_PATTERN still included AI_AGENT_PATTERN, whose substring matches also sent Markdown to agents the policy leaves out, such as the browser-driving ChatGPT Agent and Claude-Agent. Build the pattern from MARKDOWN_AGENTS alone, and list by name the clients AI_AGENT_PATTERN covered that fit the policy: assistants and coding agents (ChatGPT-User, Claude-User, Cursor, Codex) and the AI crawlers that already get Markdown (GPTBot, ClaudeBot, PerplexityBot). AI_AGENT_PATTERN and OTHER_AI_BOT_PATTERN are now for traffic classification and Profound reporting only; update their comments and the LLM-friendly docs spec to say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match sync-ea-features.yml: read-only default permissions, no persisted checkout credentials, a pinned setup-node, and an app token scoped to sentry-docs contents and pull requests. Mint the token with `client-id` (v3 dropped `app-id`) only after the sync script runs, and configure git to push with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
coolguyzone
marked this pull request as ready for review
December 3, 2026 23:12
This branch was successfully deployed
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.
DESCRIBE YOUR PR
Page URLs are served as Markdown to AI agents, but "AI agent" meant a hard-coded regex of 11 names (
claude|anthropic|gptbot|…), matched as substrings. That regex also drives traffic classification, so it couldn't change without changing metrics. This PR gives Markdown routing its own opt-in list and adds a metric to measure Markdown traffic.src/lib/trafficClassification.ts:MARKDOWN_AGENTSdecides who gets Markdown. Names are picked by hand from ai-robots-txt (MIT) and matched as whole tokens, soClaude-Userdoesn't matchClaudeBot. The list covers clients whose reader is a model:ChatGPT-User,Claude-User,Perplexity-User,MistralAI-User,Meta-ExternalFetcher, …)NotebookLM,Google-GeminiNotebook)Claude-Code,Cursor,Codex,Copilot,Devin,opencode, …)GPTBot,ClaudeBot,PerplexityBot, …)AI_AGENT_PATTERN/OTHER_AI_BOT_PATTERN: unchanged, but now only used for traffic classification, 100% trace sampling and Profound reporting. Their comments andspecs/llm-friendly-docs.mdsay so.middleware.ts: routing callsisMarkdownAgent(). The in-app browser check from fix(llm): Stop in-app browser reloads and redirect moved section .md URLs #20990 still applies. A newdocs.markdown.servedcounter records every Markdown response withdetection_method(user_agent,accept_header,format_param,md_url) and the matchedagent.scripts/sync-ai-agents.mjs+.github/workflows/sync-ai-agents.yml: run weekly and on demand, and sync a snapshot of the upstream list intosrc/data/ai-robots-txt.json(each name and what upstream says it does). Nothing reads the snapshot at runtime. When upstream changes, the workflow opens a PR listing the new names so a reviewer can decide whether any belong inMARKDOWN_AGENTS.Why opt-in: ai-robots-txt lists bots that site owners may want to block, not clients that want Markdown. Since #20991, a recognized agent gets Markdown whatever its
Acceptheader says, so an opt-out list would serve Markdown to anything new upstream.Behavior changes for existing agents:
chatgpt/claude.OpenAIandClaude-Web, both of unclear purpose upstream.AI_AGENT_PATTERNmatched keeps getting Markdown, including PerplexityBot and ChatGPT-User from fix(llm): Serve Markdown to recognized AI agents again, whatever their Accept header #20991.Caching: checked in production, and HTML and Markdown can't be mixed up:
/md-exports/….md. The two are cached under different paths (x-matched-path: /product/issuesvs/md-exports/product/issues.md).Vary: Accept, User-Agent, so a downstream shared cache won't serve Markdown to a browser.Vary: User-Agentbecause the App Router replacesVary. At worst, a shared cache serves cached HTML to an agent, which is the current behavior. HTML is alsomax-age=0, must-revalidate.Measuring:
docs.markdown.servedships with this PR. Itsagentvalue is the full matched name (claude-user,gptbot,devin, …), so the agents this PR adds show up apart from the ones that already got Markdown. Their share ofdetection_method: user_agentis the increase. For a before/after view of all traffic, the existingMarkdown rewrite triggeredlogs cover the period before deploy.Tests: middleware cases cover listed agents getting Markdown even with
Accept: text/html(Devin, MistralAI-User, NotebookLM, opencode, ChatGPT-User, Claude Code, GPTBot, ClaudeBot). They also cover these getting HTML: unlisted crawlers (Amazonbot, PetalBot), search and link-preview bots (Applebot, facebookexternalhit, Googlebot), browser agents (ChatGPT Agent, NovaAct), VS Code, andDevinci(token matching). The counter is checked for agent andAcceptrequests, and shouldn't fire for HTML.After merge: trigger the workflow manually once to confirm the app token can push a branch and open a PR. That can't be tested before merge.
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace
YYYY-MM-DDwith the due date. You can update this information later by editing the PR description.SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
🤖 Generated with Claude Code