Skip to content

[doc] llms.txt: tell agents the page links also serve Markdown - #65461

Merged
dstrodtman merged 1 commit into
masterfrom
doc-llms-txt-markdown-pointer
Aug 28, 2026
Merged

dstrodtman merged 1 commit into
masterfrom
doc-llms-txt-markdown-pointer

Conversation

@ronny-anyscale

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #64458. Adds one line to llms.txt telling agents that the page links also serve Markdown.

Read the Docs serves a Markdown rendering of any page from that page's own .html URL, under an Accept: text/markdown request. There is no separate .md file to link to — page.md, page.html.md, /md/<page>.md, and ?format=md all 404, and no Link: rel=alternate header advertises one.

So the .html links llms.txt already emits are the Markdown links. Nothing in the file says so, and an agent has no way to discover it.

# Ray

> Ray is an open-source unified compute framework for scaling AI and Python workloads…

Full page text, grouped by section, is in [llms-full.txt](https://docs.ray.io/en/master/llms-full.txt).

Request the links that follow with the HTTP header `Accept: text/markdown` to retrieve a Markdown rendering of the page.

## Overview
…

The header has to be explicit

Measured against docs.ray.io/en/master/data/data.html:

Accept: sent returns
*/* — the default for curl, requests, httpx text/html
text/html,application/xhtml+xml,*/*;q=0.8 — browser default text/html
text/plain text/html
text/markdown text/markdown
text/markdown, */* text/markdown
text/markdown;q=1.0, text/html;q=0.9 text/markdown

A wildcard isn't enough; the type has to be named. A client gets Markdown only by asking deliberately, so the pointer has a real audience.

Config-gated

New llms_txt_markdown_hint, default False. Content negotiation is a property of the host, not of the generator — a build served from somewhere that doesn't negotiate Markdown would otherwise advertise a representation that doesn't exist. conf.py sets it True for Ray.

Wording note

It says "a Markdown rendering of the page", deliberately not "the source". What comes back is the built page converted to Markdown — front matter, then site chrome (Skip to main content, theme switcher, version picker), then the content. That is not what _sources/<page>.<ext>.txt returns, and _sources genuinely exists, so calling it "the source" would point agents at the wrong artifact.

Why not link _sources/<page>.<ext>.txt instead

Considered and rejected:

  • It leaks the source format to the consumer. master is 363 .rst to 232 .md, so most pages would hand back reStructuredText, not Markdown — noisier for an agent than the HTML→Markdown conversion.
  • The URL isn't derivable from the page URL — it depends on each page's source suffix (index.md.txt vs installation.rst.txt).
  • It isn't human-clickable.
  • It would churn. As pages migrate to MyST, each link would change from .rst.txt to .md.txt. Negotiation happens on the rendered HTML, so it's identical for both source formats and survives the migration.
  • It's redundant — the verbatim source is already in the llms-full.txt shards.

Testing

$ python doc/source/_ext/test_llms_txt.py
PASS: llms_txt extension produced a correct index, Optional section, llms-full shards,
excludes notebooks by source type, gates the Markdown pointer, and honors the llms_txt_build gate.

$ ruff check doc/source/_ext/llms_txt.py doc/source/_ext/test_llms_txt.py
All checks passed!

New test_markdown_hint covers both directions: the pointer appears in the header (asserted to sit before the first ## section) when the config is on, and is absent when it's off. The header table above was produced by probing the live docs.ray.io.

All three changed files route to @ doc doc_api under the current .buildkite/test.rules.txt, so doc: test llms.txt extension runs on this PR.

Not a duplicate: gh pr list --state open finds no other open PR touching llms.txt or Markdown content negotiation.

AI assistance

Drafted with Claude Code. The behavioural claims here (which Accept values return what, which .md URL forms 404, the negotiated output including page chrome) were each verified against the live site rather than assumed.

Read the Docs serves a Markdown rendering of any page from that page's own
`.html` URL, under an `Accept: text/markdown` request. There is no separate
`.md` file: `page.md`, `page.html.md`, `/md/<page>.md` and `?format=md` all
404, and no `Link: rel=alternate` header advertises one.

So the `.html` links llms.txt already emits *are* the Markdown links -- but
nothing in the file says so, and an agent has no way to discover it. Add a
one-line pointer under the existing llms-full.txt line.

The header has to name the type explicitly. Measured against docs.ray.io:
`*/*` (the default for curl, requests and httpx), a browser's
`text/html,...,*/*;q=0.8`, and `text/plain` all return `text/html`; only an
Accept naming `text/markdown` returns `text/markdown`. A client gets Markdown
only by asking for it deliberately, so the pointer has a real audience.

Gated behind a new `llms_txt_markdown_hint` config, default False, because
content negotiation is a property of the host rather than of the generator: a
build served from somewhere that doesn't negotiate Markdown would otherwise
advertise a representation that doesn't exist. conf.py sets it True for Ray.

The wording says "a Markdown rendering of the page", not "the source": what
comes back is the built page converted to Markdown, chrome included, and it is
not what `_sources/<page>.<ext>.txt` returns.

Linking `_sources` instead was the alternative considered and rejected. It
leaks the source format to the consumer -- master is 363 .rst to 232 .md, so
most pages would hand back reStructuredText -- it requires knowing each page's
source suffix to build the URL, it isn't human-clickable, and the URL would
churn from `.rst.txt` to `.md.txt` as pages migrate to MyST. Negotiation
happens on the rendered HTML, so it is identical for both source formats and
survives that migration. The verbatim source an agent might want `_sources`
for is already in the llms-full.txt shards.

Test covers both directions: the pointer appears in the header (before the
first section) when the config is on, and is absent when it is off.

Signed-off-by: Ronny Roland <[email protected]>
@ronny-anyscale
ronny-anyscale requested review from a team as code owners August 13, 2026 15:06

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new configuration option, llms_txt_markdown_hint, to the llms_txt Sphinx extension. When enabled, this option appends a hint to the generated llms.txt file informing LLM agents that they can request the listed URLs with an Accept: text/markdown HTTP header to receive a Markdown rendering of the pages. The PR includes tests for this new configuration and enables it in doc/source/conf.py for Read the Docs integration. There are no review comments, and I have no feedback to provide.

@ronny-anyscale ronny-anyscale added go add ONLY when ready to merge, run all tests docs-go RtD-only checks for docs-only changes. Doesn't run full library doc-test suites. labels Aug 13, 2026

@dstrodtman dstrodtman 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.

stamp

@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Aug 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Aug 28, 2026
@dstrodtman dstrodtman added unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Aug 28, 2026
@dstrodtman
dstrodtman merged commit 7bbef5a into master Aug 28, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-llms-txt-markdown-pointer branch August 28, 2026 05:06
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…roject#65461)

## Summary

Follow-up to ray-project#64458. Adds one line to `llms.txt` telling agents that the
page links also serve Markdown.

Read the Docs serves a Markdown rendering of any page **from that page's
own `.html` URL**, under an `Accept: text/markdown` request. There is no
separate `.md` file to link to — `page.md`, `page.html.md`,
`/md/<page>.md`, and `?format=md` all 404, and no `Link: rel=alternate`
header advertises one.

So the `.html` links `llms.txt` already emits *are* the Markdown links.
Nothing in the file says so, and an agent has no way to discover it.

```
# Ray

> Ray is an open-source unified compute framework for scaling AI and Python workloads…

Full page text, grouped by section, is in [llms-full.txt](https://docs.ray.io/en/master/llms-full.txt).

Request the links that follow with the HTTP header `Accept: text/markdown` to retrieve a Markdown rendering of the page.

## Overview
…
```

## The header has to be explicit

Measured against `docs.ray.io/en/master/data/data.html`:

| `Accept:` sent | returns |
|---|---|
| `*/*` — the default for curl, `requests`, `httpx` | `text/html` |
| `text/html,application/xhtml+xml,*/*;q=0.8` — browser default |
`text/html` |
| `text/plain` | `text/html` |
| `text/markdown` | **`text/markdown`** |
| `text/markdown, */*` | **`text/markdown`** |
| `text/markdown;q=1.0, text/html;q=0.9` | **`text/markdown`** |

A wildcard isn't enough; the type has to be named. A client gets
Markdown only by asking deliberately, so the pointer has a real
audience.

## Config-gated

New `llms_txt_markdown_hint`, **default `False`**. Content negotiation
is a property of the host, not of the generator — a build served from
somewhere that doesn't negotiate Markdown would otherwise advertise a
representation that doesn't exist. `conf.py` sets it `True` for Ray.

## Wording note

It says "a Markdown rendering of **the page**", deliberately not "the
source". What comes back is the built page converted to Markdown — front
matter, then site chrome (`Skip to main content`, theme switcher,
version picker), then the content. That is not what
`_sources/<page>.<ext>.txt` returns, and `_sources` genuinely exists, so
calling it "the source" would point agents at the wrong artifact.

## Why not link `_sources/<page>.<ext>.txt` instead

Considered and rejected:

- **It leaks the source format to the consumer.** master is **363 `.rst`
to 232 `.md`**, so most pages would hand back reStructuredText, not
Markdown — noisier for an agent than the HTML→Markdown conversion.
- **The URL isn't derivable from the page URL** — it depends on each
page's source suffix (`index.md.txt` vs `installation.rst.txt`).
- **It isn't human-clickable.**
- **It would churn.** As pages migrate to MyST, each link would change
from `.rst.txt` to `.md.txt`. Negotiation happens on the rendered HTML,
so it's identical for both source formats and survives the migration.
- **It's redundant** — the verbatim source is already in the
`llms-full.txt` shards.

## Testing

```
$ python doc/source/_ext/test_llms_txt.py
PASS: llms_txt extension produced a correct index, Optional section, llms-full shards,
excludes notebooks by source type, gates the Markdown pointer, and honors the llms_txt_build gate.

$ ruff check doc/source/_ext/llms_txt.py doc/source/_ext/test_llms_txt.py
All checks passed!
```

New `test_markdown_hint` covers both directions: the pointer appears in
the header (asserted to sit before the first `##` section) when the
config is on, and is absent when it's off. The header table above was
produced by probing the live `docs.ray.io`.

All three changed files route to `@ doc doc_api` under the current
`.buildkite/test.rules.txt`, so `doc: test llms.txt extension` runs on
this PR.

Not a duplicate: `gh pr list --state open` finds no other open PR
touching `llms.txt` or Markdown content negotiation.

## AI assistance

Drafted with Claude Code. The behavioural claims here (which `Accept`
values return what, which `.md` URL forms 404, the negotiated output
including page chrome) were each verified against the live site rather
than assumed.

Signed-off-by: Ronny Roland <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 20, 2026
…heir files

Both entries name files that have moved, so each has silently stopped
applying:

- CODEOWNERS names doc/source/data/working-with-llms.rst, which #66375
  converted to working-with-llms.md. ray-project/ray-llm hasn't been
  requested on the page since.
- test.rules.txt routes doc/test_llms_txt.py to `doc` alone, but the test
  moved to doc/source/_ext/ in #65461. There it matches the _ext/ directory
  rule and also emits doc_api, which runs both API-consistency checks for a
  hermetic Sphinx test that imports no Ray code. It now gets its own rule
  ahead of the directory entry, the same way api_sidebar.py does, and the
  test.rules.test.txt case follows it to the new path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 21, 2026
…heir files

Both entries name files that have moved, so each has silently stopped
applying:

- CODEOWNERS names doc/source/data/working-with-llms.rst, which #66375
  converted to working-with-llms.md. ray-project/ray-llm hasn't been
  requested on the page since.
- test.rules.txt routes doc/test_llms_txt.py to `doc` alone, but the test
  moved to doc/source/_ext/ in #65461. There it matches the _ext/ directory
  rule and also emits doc_api, which runs both API-consistency checks for a
  hermetic Sphinx test that imports no Ray code. It now gets its own rule
  ahead of the directory entry, the same way api_sidebar.py does, and the
  test.rules.test.txt case follows it to the new path.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation docs-go RtD-only checks for docs-only changes. Doesn't run full library doc-test suites. go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants