Content negotiation: markdown for AI agents
One URL can serve HTML to browsers and markdown to agents via content negotiation. Where RFC 9110 already answers this, why most agents never send the Accept header, and the Vary: Accept caching trap.

A pricing page has two readers now. One opens it in Firefox and gets the layout you shipped. The other sends a bare GET request, receives the same HTML, strips every script, nav block and consent banner, and then has to guess which div holds the price. The second reader never sees your design. It sees tokens.
HTTP has had an answer for serving both readers from one URL since long before agent frameworks existed: content negotiation.
What the model actually reads
When an agent consumes your page, no browser ever runs. The fetcher gets raw HTML: stylesheets, analytics beacons, cookie widgets, JSON-LD blobs, and somewhere in the middle the actual answer. Conversion to plain text happens downstream, and its quality depends entirely on your markup. Semantic headings and tables convert cleanly. Wrappers turn into noise. A price sitting in a styled span inside three nested divs may not survive the trip at all.
The cost is not just bytes. Every wrapper is a chance for the model to quote the wrong number, and agents pay per token, so the wrappers get paid for twice: once in bandwidth, once in extraction quality. A markdown rendering of the same words carries none of that weight, which is why agent authors keep asking for it.
Machine audiences arrive whether you invite them or not. The SQLite maintainer watching the flood of AI-generated bug reports is dealing with the same shift from the other side: machine output aimed at a human interface. Here the direction is reversed, machines consuming a human interface, but the mismatch is the same shape.
Content negotiation for AI agents
The mechanism is standard HTTP, documented in section 12 of RFC 9110, and DZone’s piece on serving markdown beside HTML argues it is the right tool for this exact audience. The client states what representations it accepts in the Accept header. The server picks one, sends it, and says which one it sent in Content-Type. Nothing in that design requires the client to be a browser. A crawler that sends Accept: text/markdown and gets text/markdown back has done a clean negotiation: one URL, two representations, no duplicate pages to keep in sync.
The media type is old too: RFC 7763 registered text/markdown back in 2016, so nothing on the client side waits for a new spec. Browsers never send it. They keep receiving HTML and nothing breaks. The nginx implementation is one map and one try_files:
map $http_accept $page_repr {
default html;
"~*text/markdown" md;
}
server {
location = /pricing {
root /var/www/site;
try_files /pricing.$page_repr /pricing.html =404;
}
}Read it top to bottom. The $http_accept variable holds whatever the client declared, and a browser’s normal Accept: text/html falls straight through to the default, html. Only a client that explicitly declares text/markdown flips the switch to md, which makes try_files pick pricing.md first while still serving pricing.html whenever the markdown file was never written, so no request ever 404s and no second URL needs separate linking or indexing.
A fair objection: structured data already exists. JSON-LD blocks give machines a parseable channel inside the HTML, and schema.org covers products, events and breadcrumbs. That helps for facts with a schema. A changelog, a pricing table, a troubleshooting guide: there is no schema for those, and the agent still has to read the prose. Markdown is the prose format that already exists.
The Accept header agents never send
Negotiation has a dependency the HTML side never had: the client has to ask. Most agent stacks today send Accept: */* or no Accept header at all, which resolves to HTML every time, followed by the same sloppy conversion you were trying to avoid. Until agent frameworks start announcing text/markdown as a preference, your markdown representation serves an audience of zero. So the real question is how agents reach the markdown while they still don’t ask for it.
| Approach | Server logic | Cache risk | Where it breaks |
|---|---|---|---|
| Single HTML for everyone | None | None | Bad extraction, token cost paid on every fetch |
| llms.txt at the root | One static file | None | Drifts from the live pages; a pointer, not a copy |
| A .md twin URL like /pricing.md | Static file | Low | Splits links and search signals across two URLs |
| User-Agent sniffing | Rules on every edge | High unless keyed by UA | UA strings churn; one stale rule serves HTML to agents |
| Accept negotiation | One map rule | Needs Vary: Accept | Most agents don’t send the header yet |
I would skip User-Agent rules entirely. UA strings churn constantly, one stale rule on the edge serves HTML to every agent that rotated its client string, and debugging a representation that differs per request is miserable. llms.txt is a better signpost, but a signpost only. Copying full page content into it guarantees drift, and a stale llms.txt is worse than none, because the agent trusted it. Machine-readable discoverability files get forgotten after launch; it’s the same failure mode I flagged for security.txt in AI-built apps.
Vary: Accept, the caching trap
This is the part that reaches production broken. An edge cache that keys only on the URL stores whatever representation arrived first. A deploy goes out, a browser hits /pricing, HTML gets cached. The next request arrives with Accept: text/markdown and the cache cheerfully returns HTML with Content-Type: text/html. The agent then converts HTML it was promised markdown for. Reverse the order and a browser renders raw markdown as a wall of plain text with asterisks in it.
A cache that ignores Vary is worse than no negotiation at all, because it fails silently.
One response header fixes the keying: Vary: Accept. It tells every compliant cache to keep separate entries per Accept value. Most reverse proxies honor it. Some CDNs ignore it by default, which is why the two-curl check matters: one plain request, one with -H 'Accept: text/markdown', both after the cache is warm, then compare the Content-Type headers. If both come back identical, your edge has collapsed the two representations into one and every agent on the network is getting whichever landed first.
What I would ship first
My order is short. Keep HTML canonical for browsers. Add the markdown twin to the handful of URLs where extraction actually matters: pricing, docs, changelog. Set Vary: Accept and verify it with the two curls, because an unverified cache rule is a guess. Then write a llms.txt that points at those endpoints instead of duplicating their content.
Scope the twin by content type, not by site. Docs and changelogs win the most, because agents lift their sentences whole. Marketing pages gain less, since the model compresses them into a sentence anyway. Wire the endpoints you would hate to see misquoted, wire nothing else, and revisit when the log entries show a pattern instead of a rumor.
Measure before expanding. Grep a week of access logs for the Accept header. Zero text/markdown requests means you’ve bought time and the twin is plumbing for later. The first one that arrives is your deadline for the cache config, because everything after it runs through the edge.