feat: harden Agent Ready discovery surface - #28
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1dd6de34f3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| accept = request.headers.get("accept", "").lower() | ||
| if request.method == "GET" and "text/markdown" in accept: |
There was a problem hiding this comment.
Honor Accept quality weights when selecting Markdown
When a client sends an Accept header such as text/html, text/markdown;q=0 or prefers HTML with a higher quality value, this substring check still returns Markdown—even though Markdown may be explicitly unacceptable. Parse the media ranges and quality weights so Markdown is selected only when it is acceptable and preferred.
Useful? React with 👍 / 👎.
| @app.api_route("/", methods=["GET", "HEAD"], response_class=HTMLResponse, include_in_schema=False) | ||
| def playground(request: Request) -> Response: | ||
| accept = request.headers.get("accept", "").lower() | ||
| if request.method == "GET" and "text/markdown" in accept: |
There was a problem hiding this comment.
Negotiate HEAD requests consistently with GET
For HEAD / with Accept: text/markdown, the method guard skips the Markdown branch and reports HTML headers, while the corresponding GET selects Markdown. Clients and discovery scanners commonly use HEAD to inspect a representation, so apply the same content negotiation to HEAD while allowing the server to suppress the body.
Useful? React with 👍 / 👎.
| return PlainTextResponse( | ||
| PLAYGROUND_MD, | ||
| media_type="text/markdown", | ||
| headers=MARKDOWN_HEADERS, |
There was a problem hiding this comment.
Mark the negotiated root response as varying on Accept
The Markdown representation returned from / is cacheable but does not include Vary: Accept. An intermediary that caches a Markdown request can therefore reuse that response for a later ordinary browser request to the same URL and serve Markdown instead of HTML. Add Vary: Accept to the negotiated root responses.
Useful? React with 👍 / 👎.
| python -m venv .venv | ||
| pip install -e \".[dev]\" |
There was a problem hiding this comment.
Install dependencies through the newly created virtualenv
When these documented commands are run in a fresh shell, creating .venv does not activate it, so the subsequent bare pip resolves to the caller's existing environment and installs the package globally or into another environment despite the isolation claim. Activate .venv first or invoke .venv/bin/python -m pip directly.
Useful? React with 👍 / 👎.
Closes #27
Changes
<lastmod>to the canonical sitemap entry;Accept: text/markdowncontent negotiation;/index.mdmarkdown mirror with frontmatter and sitemap section;0.6.0;/;Invariants preserved
Baseline
Agent Ready before this PR: overall 45/100, site 13/15, llms.txt 100/100, accessibility 100/100.