Skip to content

feat(llm): Follow Vercel's Markdown and agent discovery guidance - #20930

Merged
sergical merged 3 commits into
masterfrom
feat/agent-markdown-discovery
Nov 24, 2026
Merged

sergical merged 3 commits into
masterfrom
feat/agent-markdown-discovery

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

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 .md exports, 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 Accept contained text/markdown, and to any recognized AI user-agent regardless of Accept. Now (src/lib/contentNegotiation.ts):

  • Markdown is served when Accept ranks text/markdown at or above text/html. A tie goes to Markdown, so text/markdown, text/html, */* (Claude Code's WebFetch) still gets Markdown, but text/html, text/markdown;q=0.9 now gets HTML.
  • A recognized AI agent whose Accept names neither format (*/*, empty) gets Markdown. One that explicitly asks for text/html gets HTML.

Markdown responses (negotiated or .md) set Vary: Accept and a Link header with rel="canonical" (the HTML page) and rel="describedby" (/llms.txt). Before, the canonical link was only on .md URLs.

HTML pages advertise their Markdown version two ways: a Link response header (rel="alternate"; type="text/markdown" plus rel="describedby"), and the same links as <link> tags in <head>. The header lets agents that run curl -I find the Markdown without parsing HTML.

Discovery index. scripts/generate-llms-txt.mjs now also writes /sitemap.md: every visible page, nested like the sidebar, with its description and .md URL (~340 KB, ~2,000 pages; Vercel's is ~540 KB). Every page export ends with a footer linking /sitemap.md and /llms.txt, and llms.txt and the Markdown soft-404 link the sitemap.

specs/llm-friendly-docs.md and AGENTS.md are updated to match.

Notes for review

  • Behavior change for agents that send browser-style Accept headers. An agent matching AI_AGENT_PATTERN that sends text/html,...,*/*;q=0.8 now gets HTML, not Markdown. This is what Vercel's guidance asks for ("A recognized AI agent receives HTML when it requests text/html"). Before merging, check docs.request.classified / the Middleware request processed logs for which agents send text/html without text/markdown, to see how much traffic moves to HTML. If that's too much, shouldServeMarkdown can keep the user-agent override for agents.
  • No Vary: Accept on HTML responses. The App Router page renderer calls res.setHeader('Vary', …), which replaces any Vary the middleware sets, so a middleware Vary on HTML is dropped (confirmed on next dev). Markdown responses keep Vary: Accept, which stops caches from serving Markdown to browsers. Vercel's own docs set Vary: Accept only on Markdown responses too.
  • The footer changes every export once, so the first build after merge re-uploads every file to R2 and logs the ">10% different hash" warning.
  • Left out on purpose: the Vercel-specific parts (graph.json / .graph.md cross-link maps, the vercel docs CLI, .well-known/ai-catalog.json), the extra frontmatter fields (last_updated, type, prerequisites, related) that we don't have data for, and llms-full.txt.

IS YOUR CHANGE URGENT?

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

PRE-MERGE CHECKLIST

  • 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

via @sergical.

--

View Session [Sentry]

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>
@vercel

vercel Bot commented Nov 21, 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 Nov 21, 2026 4:56pm UTC
sentry-docs Ready Ready Preview Nov 21, 2026 4:56pm UTC

Request Review

@github-actions github-actions Bot added the Priority: Normal Docs review has no urgent deadline label Nov 21, 2026
@sergical
sergical marked this pull request as ready for review November 21, 2026 01:13
@sentry-junior
sentry-junior Bot requested a review from sergical November 21, 2026 01:13
@cursor

cursor Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Getting ready to monitor this change · Rollout details

Status Service Environment
⏳ Getting ready to monitor this change

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread scripts/generate-md-exports.mjs Resolved
Comment thread middleware.ts Resolved
Co-Authored-By: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>

@sergical sergical left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfanahata @coolguyzone cool to ship this?

@sergical
sergical merged commit cb3092c into master Nov 24, 2026
31 checks passed
@sergical
sergical deleted the feat/agent-markdown-discovery branch November 24, 2026 20:38
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

2 active deployments
Preview – sentry-docs — d04b562e Deployed Nov 21, 2026 by vercel[bot]
Preview – develop-docs — d04b562e Deployed Nov 21, 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