Repository navigation
fix(llm): Serve Markdown to recognized AI agents again, whatever their Accept header - #20991
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Getting ready to monitor this change · Rollout details
|
rahulchhabria
approved these changes
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>
…ocument PerplexityBot sends Sec-Fetch-Dest: document, so that check kept it on HTML. Recognize the Claude, Cursor and Gemini apps by user agent instead, and keep the Sec-Fetch-Dest: empty check for the router's background fetch. The Markdown not-found reply now sets its own Vary, since middleware's is lost. Co-authored-by: Claude <claude@anthropic.com>
sergical
force-pushed
the
fix/agent-markdown-ua-wins
branch
from
November 28, 2026 00:04
ccf083c to
7cd0067
Compare
sergical
enabled stacked auto-merge (squash)
November 28, 2026 00:04
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.
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
Acceptheader, and #20930 made anAcceptthat prefers HTML win over the user agent. Now a recognized AI agent (AI_AGENT_PATTERN, the same list as before #20930) gets Markdown whatever itsAcceptheader says, which is what sentry.io and the blog already do (static-sitespackages/www-astro/middleware.ts). Every other client keeps #20930's quality-value rule.Why this goes against Vercel's guidance. Vercel's Markdown and Agent Discovery 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 theMiddleware request processedlogs, last 2 days):Acceptit sendstext/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,…text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8ChatGPT-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:
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 matchAI_AGENT_PATTERN. Since the user agent now wins overAccept, 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 markedSec-Fetch-Dest: empty(the router's background fetch) stays exempt as in #20990.Sec-Fetch-Dest: documentis not used as a browser signal, because PerplexityBot sends it on every request.Vary: Accept, User-Agenton 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 noAcceptinVaryat all, because the route's response replaces the middleware's. Direct.mdURLs keepVary: Accept; their content doesn't depend on either header, and addingUser-Agentwould split their cache by browser version.Checked on the preview (
/platforms/javascript/):Accepttext/htmltext/markdown,Vary: Accept, User-AgentAccept,Sec-Fetch-Dest: documenttext/markdown,Vary: Accept, User-Agenttext/htmlAccept: text/markdowntext/markdown,Vary: Accept, User-AgentRSC: 1,Accept: */*,Sec-Fetch-Dest: empty)text/x-component(page data)Accept,Sec-Fetch-Dest: document)text/htmlAccept: text/markdown(/platforms/apple/cocoa/)VarywithoutAcceptVary: Accept, User-AgentaddedTests: 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
AI_AGENT_PATTERNgets Markdown on page URLs, even withAccept: text/htmlonly, unless it's one of the in-app browsers or sendsSec-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.AI_AGENT_PATTERNwould get Markdown on page loads; the newsecFetchDestlog 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-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: