Repository navigation
feat(llm): Follow Vercel's Markdown and agent discovery guidance - #20930
Merged
Merged
Conversation
Honor Accept quality values when choosing HTML or Markdown, so a recognized agent that asks for text/html gets HTML. Set Vary: Accept and canonical and describedby Link headers on Markdown responses. Advertise each page's Markdown export and llms.txt with Link headers and <link> tags on HTML pages. Generate /sitemap.md with every page and its description, and link it and llms.txt from the footer of every page export. Co-Authored-By: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Getting ready to monitor this change · Rollout details
|
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4dae439. Configure here.
Co-Authored-By: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
sergical
approved these changes
Nov 24, 2026
sergical
left a comment
Member
There was a problem hiding this comment.
@sfanahata @coolguyzone cool to ship this?
KyleTryon
approved these changes
Nov 24, 2026
1 of 6 tasks
sergical
added a commit
that referenced
this pull request
Nov 28, 2026
…t header ChatGPT-User and PerplexityBot send a browser's Accept header, so since #20930 they got HTML. A recognized AI agent now gets Markdown again, matching sentry.io and the blog. Requests a browser marks Sec-Fetch-Dest: document or empty are not treated as agents, so in-app browsers keep getting normal pages. Negotiated Markdown responses set Vary: Accept, User-Agent. Co-authored-by: Claude <claude@anthropic.com>
sergical
added a commit
that referenced
this pull request
Nov 28, 2026
…r Accept header (#20991) **Stacked on #20990. Merge that one first; GitHub then retargets this PR to `master`.** ## DESCRIBE YOUR PR Since #20930 went live on Nov 24, ChatGPT-User and PerplexityBot get HTML from docs instead of Markdown. Both send a browser's `Accept` header, and #20930 made an `Accept` that prefers HTML win over the user agent. Now a recognized AI agent (`AI_AGENT_PATTERN`, the same list as before #20930) gets Markdown whatever its `Accept` header says, which is what sentry.io and the blog already do (`static-sites` `packages/www-astro/middleware.ts`). Every other client keeps #20930's quality-value rule. ``` shouldServeMarkdown(accept, isAIAgent) before: formatPreference(accept) == 'none' ? isAIAgent : formatPreference(accept) == 'markdown' after: isAIAgent || formatPreference(accept) == 'markdown' ``` **Why this goes against Vercel's guidance.** Vercel's [Markdown and Agent Discovery](https://vercel.com/docs/agent-resources/markdown-access) page says "A recognized AI agent receives HTML when it requests `text/html`", and #20930 followed it. But the two biggest AI fetchers on docs ask for HTML in every request (from the `Middleware request processed` logs, last 2 days): | Agent | `Accept` it sends | Requests | |---|---|---| | ChatGPT-User | `text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,…` | 8,936, all HTML | | PerplexityBot | `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8` | 1,234, all HTML | ChatGPT-User makes about 4,400 docs requests a day. Vercel request logs for ChatGPT-User on Nov 24 (UTC, page URLs), with #20930 live from 21:14: | Hour | Markdown | HTML | |---|---|---| | 19:00 | 202 | 37 | | 20:00 | 219 | 28 | | 21:00 | 51 | 160 | | 22:00 | 2 | 227 | | 23:00 | 0 | 175 | **In-app browsers keep #20990's fix.** The Claude and Cursor desktop apps and Gemini iOS put the app name in their user agent (`Claude/6.28899.6 Chrome/…`, `Cursor/3.32.4 Chrome/… Electron/…`, `GeminiiOS/…`), so they match `AI_AGENT_PATTERN`. Since the user agent now wins over `Accept`, a page load in those apps would get Markdown too, not just the background fetch #20990 fixed. So those user agents are recognized as in-app browsers and never treated as agents, and any request marked `Sec-Fetch-Dest: empty` (the router's background fetch) stays exempt as in #20990. `Sec-Fetch-Dest: document` is not used as a browser signal, because PerplexityBot sends it on every request. **`Vary: Accept, User-Agent`** on Markdown served from a page URL, since the user agent now picks the format. The Markdown "page not found" reply sets it itself: on production it had no `Accept` in `Vary` at all, because the route's response replaces the middleware's. Direct `.md` URLs keep `Vary: Accept`; their content doesn't depend on either header, and adding `User-Agent` would split their cache by browser version. Checked on the preview (`/platforms/javascript/`): | Request | Production | Preview | |---|---|---| | ChatGPT-User, browser `Accept` | `text/html` | `text/markdown`, `Vary: Accept, User-Agent` | | PerplexityBot, browser `Accept`, `Sec-Fetch-Dest: document` | | `text/markdown`, `Vary: Accept, User-Agent` | | Chrome page load | | `text/html` | | No AI user agent, `Accept: text/markdown` | | `text/markdown`, `Vary: Accept, User-Agent` | | Claude app router fetch (`RSC: 1`, `Accept: */*`, `Sec-Fetch-Dest: empty`) | | `text/x-component` (page data) | | Claude app page load (browser `Accept`, `Sec-Fetch-Dest: document`) | | `text/html` | | Missing page, `Accept: text/markdown` (`/platforms/apple/cocoa/`) | `Vary` without `Accept` | `Vary: Accept, User-Agent` added | Tests: the updated content-negotiation and middleware tests (agent asking for HTML gets Markdown, `Vary: Accept, User-Agent`) fail on the old rule and pass now. The "asks for HTML" test now covers ChatGPT-User and PerplexityBot with their real headers, and the in-app browser test covers both the page load and the link-click fetch. ### Special things to note - Any client whose user agent matches `AI_AGENT_PATTERN` gets Markdown on page URLs, even with `Accept: text/html` only, unless it's one of the in-app browsers or sends `Sec-Fetch-Dest: empty`. The pattern is broad (`claude|cursor|gemini|openai|…`); narrowing it to named bots, as static-sites and the changelog do, is a separate change. - The in-app browser list is three apps seen in the docs logs. Another app whose user agent matches `AI_AGENT_PATTERN` would get Markdown on page loads; the new `secFetchDest` log field shows which browsers hit this. Created with Claude Opus 5.5 in Claude Code. ## 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 - [x] 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](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude <claude@anthropic.com>
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
Brings docs.sentry.io in line with Vercel's Markdown and Agent Discovery guidance and the llms.txt v2 link relations. We already had the
.mdexports, content negotiation,llms.txt, and the View as Markdown button. This PR adds the parts that were missing.Content negotiation honors quality values. The middleware used to serve Markdown whenever
Acceptcontainedtext/markdown, and to any recognized AI user-agent regardless ofAccept. Now (src/lib/contentNegotiation.ts):Acceptrankstext/markdownat or abovetext/html. A tie goes to Markdown, sotext/markdown, text/html, */*(Claude Code's WebFetch) still gets Markdown, buttext/html, text/markdown;q=0.9now gets HTML.Acceptnames neither format (*/*, empty) gets Markdown. One that explicitly asks fortext/htmlgets HTML.Markdown responses (negotiated or
.md) setVary: Acceptand aLinkheader withrel="canonical"(the HTML page) andrel="describedby"(/llms.txt). Before, the canonical link was only on.mdURLs.HTML pages advertise their Markdown version two ways: a
Linkresponse header (rel="alternate"; type="text/markdown"plusrel="describedby"), and the same links as<link>tags in<head>. The header lets agents that runcurl -Ifind the Markdown without parsing HTML.Discovery index.
scripts/generate-llms-txt.mjsnow also writes/sitemap.md: every visible page, nested like the sidebar, with its description and.mdURL (~340 KB, ~2,000 pages; Vercel's is ~540 KB). Every page export ends with a footer linking/sitemap.mdand/llms.txt, andllms.txtand the Markdown soft-404 link the sitemap.specs/llm-friendly-docs.mdandAGENTS.mdare updated to match.Notes for review
Acceptheaders. An agent matchingAI_AGENT_PATTERNthat sendstext/html,...,*/*;q=0.8now gets HTML, not Markdown. This is what Vercel's guidance asks for ("A recognized AI agent receives HTML when it requeststext/html"). Before merging, checkdocs.request.classified/ theMiddleware request processedlogs for which agents sendtext/htmlwithouttext/markdown, to see how much traffic moves to HTML. If that's too much,shouldServeMarkdowncan keep the user-agent override for agents.Vary: Accepton HTML responses. The App Router page renderer callsres.setHeader('Vary', …), which replaces anyVarythe middleware sets, so a middlewareVaryon HTML is dropped (confirmed onnext dev). Markdown responses keepVary: Accept, which stops caches from serving Markdown to browsers. Vercel's own docs setVary: Acceptonly on Markdown responses too.graph.json/.graph.mdcross-link maps, thevercel docsCLI,.well-known/ai-catalog.json), the extra frontmatter fields (last_updated,type,prerequisites,related) that we don't have data for, andllms-full.txt.IS YOUR CHANGE URGENT?
PRE-MERGE CHECKLIST
via @sergical.
--
View Session [Sentry]