Skip to content

feat(md-exports): Serve Markdown to an opt-in list of AI agents - #21036

Open
coolguyzone wants to merge 3 commits into
masterfrom
coolguyzone/feat/ai-agent-ua-list
Open

coolguyzone wants to merge 3 commits into
masterfrom
coolguyzone/feat/ai-agent-ua-list

Conversation

@coolguyzone

@coolguyzone coolguyzone commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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_AGENTS decides who gets Markdown. Names are picked by hand from ai-robots-txt (MIT) and matched as whole tokens, so Claude-User doesn't match ClaudeBot. The list covers clients whose reader is a model:
    • assistants answering a prompt (ChatGPT-User, Claude-User, Perplexity-User, MistralAI-User, Meta-ExternalFetcher, …)
    • notebook sources (NotebookLM, Google-GeminiNotebook)
    • coding agents (Claude-Code, Cursor, Codex, Copilot, Devin, opencode, …)
    • AI crawlers for training and AI search that already get Markdown (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 and specs/llm-friendly-docs.md say so.
  • middleware.ts: routing calls isMarkdownAgent(). The in-app browser check from fix(llm): Stop in-app browser reloads and redirect moved section .md URLs #20990 still applies. A new docs.markdown.served counter records every Markdown response with detection_method (user_agent, accept_header, format_param, md_url) and the matched agent.
  • scripts/sync-ai-agents.mjs + .github/workflows/sync-ai-agents.yml: run weekly and on demand, and sync a snapshot of the upstream list into src/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 in MARKDOWN_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 Accept header says, so an opt-out list would serve Markdown to anything new upstream.

Behavior changes for existing agents:

  • Agents that drive a browser now get HTML, because they need it to navigate: ChatGPT Agent and Claude-Agent used to match chatgpt/claude.
  • Unlisted names that only matched by substring also get HTML: OpenAI and Claude-Web, both of unclear purpose upstream.
  • Everything else AI_AGENT_PATTERN matched keeps getting Markdown, including PerplexityBot and ChatGPT-User from fix(llm): Serve Markdown to recognized AI agents again, whatever their Accept header #20991.
  • Traditional search and link-preview bots (Applebot, facebookexternalhit, Googlebot) keep getting HTML.
  • Trae is left out for now: it's an Electron IDE, so it may have the same in-app browser problem as Cursor.

Caching: checked in production, and HTML and Markdown can't be mixed up:

  • Vercel runs middleware before its cache lookup, and Markdown is a rewrite to /md-exports/….md. The two are cached under different paths (x-matched-path: /product/issues vs /md-exports/product/issues.md).
  • Markdown responses send Vary: Accept, User-Agent, so a downstream shared cache won't serve Markdown to a browser.
  • HTML responses can't carry Vary: User-Agent because the App Router replaces Vary. At worst, a shared cache serves cached HTML to an agent, which is the current behavior. HTML is also max-age=0, must-revalidate.

Measuring: docs.markdown.served ships with this PR. Its agent value 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 of detection_method: user_agent is the increase. For a before/after view of all traffic, the existing Markdown rewrite triggered logs 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, and Devinci (token matching). The counter is checked for agent and Accept requests, 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-DD with the due date. You can update this information later by editing the PR description.

  • Urgent deadline (GA date, etc.): YYYY-MM-DD
  • Other deadline: YYYY-MM-DD
  • No deadline: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've supplied a deadline.

Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
develop-docs Ready Ready Preview Dec 3, 2026 12:07am UTC
sentry-docs Ready Ready Preview Dec 3, 2026 12:07am UTC

Request Review

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 coolguyzone changed the title feat(md-exports): Route agents from the ai-robots-txt list to Markdown feat(md-exports): Serve Markdown to an opt-in list of AI agents Dec 2, 2026
@coolguyzone
coolguyzone force-pushed the coolguyzone/feat/ai-agent-ua-list branch from ed8a670 to 695231b Compare December 2, 2026 23:35
Comment thread .github/workflows/sync-ai-agents.yml Resolved
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>
Comment thread .github/workflows/sync-ai-agents.yml Resolved
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>

This branch was successfully deployed

2 active deployments
Preview – sentry-docs — 38387480 Deployed Dec 3, 2026 by vercel[bot]
Preview – develop-docs — 38387480 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Normal Docs review has no urgent deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants