hexdocs icon indicating copy to clipboard operation
hexdocs copied to clipboard

Return Markdown for LLM driven User Agents

Open mikehostetler opened this issue 3 months ago • 5 comments

Inspired by this tweet from Bun: https://x.com/bunjavascript/status/1971934734940098971

When a LLM Agent requests docs from HexDocs, return the Markdown representation instead of the HTML - with the purpose to shrink token usage.

mikehostetler avatar Sep 27 '25 14:09 mikehostetler

Is there an easy way for us to know if one is a LLM Agent or will we have to add one by one manually? 😬

josevalim avatar Sep 27 '25 20:09 josevalim

Probably worth checking how Bun does it. 🤔

Still, there's another approach: accept header. Would be the easiest, if somehow agents would prioritize markdown over html when making request.

Valian avatar Sep 27 '25 21:09 Valian

FYI opencode just added accept header for markdown https://github.com/sst/opencode/commit/c148f10bbd0c5a59160050218bcc850c9fb58056

foucist avatar Sep 29 '25 11:09 foucist

Mintlify also added this. It seems to be based on accept header, Claude Code prefers text/plain over text/html:

https://x.com/rauchg/status/1972347470140379616

Valian avatar Sep 30 '25 08:09 Valian

If we want to serve markdown from hexdocs.pm the first step would be to have ex_doc include it alongside the html in the docs bundle that is uploaded to hexdocs.

After that we can update the hexdocs.pm to serve the markdown based on the accept header.

ericmj avatar Sep 30 '25 18:09 ericmj