Skip to content

fix: enable markdown negotiation for agents#288

Open
GalvinGao wants to merge 2 commits into
mainfrom
codex/markdown-for-agents
Open

fix: enable markdown negotiation for agents#288
GalvinGao wants to merge 2 commits into
mainfrom
codex/markdown-for-agents

Conversation

@GalvinGao

Copy link
Copy Markdown
Contributor

Summary

Agents requesting Accept: text/markdown no longer hit TanStack Start's HTML-only request guard before Cloudflare can convert the response. Browser requests still render HTML by default, while markdown requests are normalized for origin rendering and marked with Vary: Accept so Cloudflare's Markdown for Agents feature can return the converted markdown variant.

The release workflow now enables Cloudflare's content_converter zone setting after deployment and verifies that https://dxrating.net/search responds to markdown requests with Content-Type: text/markdown, logging x-markdown-tokens when Cloudflare provides it.

Testing

  • pnpm --filter @gekichumai/dxrating-web exec vitest run src/setup/__tests__/markdownNegotiation.test.ts
  • pnpm --filter @gekichumai/dxrating-web build
  • pnpm lint
  • Local Wrangler header check: Accept: text/markdown returned 200 OK with Vary: Cookie, Accept-Language, Accept; plain requests returned 200 OK HTML with the existing vary headers.

Compound Engineering
GPT-5

@semanticdiff-com

semanticdiff-com Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  apps/web/src/setup/__tests__/sentry-start.test.ts  75% smaller
  apps/web/vite.config.ts  61% smaller
  apps/web/package.json  50% smaller
  apps/web/src/start.ts  22% smaller
  apps/web/src/server.ts  18% smaller
  .github/workflows/release.yml  0% smaller
  apps/web/scripts/cloudflare-markdown-for-agents.mjs  0% smaller
  apps/web/src/setup/__tests__/markdownNegotiation.test.ts  0% smaller
  apps/web/src/setup/markdownNegotiation.ts  0% smaller
  apps/web/wrangler.jsonc Unsupported file format

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Preview Deployment

Name Link
Latest commit cde9beb
Preview URL https://dxrating-pr-288.galvin.workers.dev

Built and deployed to Cloudflare Workers.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the TanStack Start Cloudflare worker to properly negotiate Accept: text/markdown requests (so Cloudflare can convert HTML → Markdown for Agents), while keeping normal browser requests rendering HTML by default. It also adds release automation to enable Cloudflare’s content_converter setting and verify that /search returns text/markdown for markdown requests.

Changes:

  • Add markdown accept-detection + normalization and ensure responses vary on Accept for markdown requests.
  • Switch the worker/server entry configuration to point at the app’s server entry and configure TanStack Start’s server entry accordingly.
  • Add a Cloudflare API script + release workflow steps to enable and verify “Markdown for Agents”.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
apps/web/wrangler.jsonc Switch worker main entry to the project’s server entry.
apps/web/vite.config.ts Configure TanStack Start to use a custom server entry.
apps/web/src/start.ts Add request middleware to normalize markdown Accept and add Vary: Accept.
apps/web/src/setup/markdownNegotiation.ts Implement markdown Accept detection and normalization helper.
apps/web/src/setup/tests/markdownNegotiation.test.ts Add unit tests for markdown detection/normalization helpers.
apps/web/src/server.ts Normalize markdown Accept before SSR and add Vary: Accept when applicable.
apps/web/scripts/cloudflare-markdown-for-agents.mjs Add script to enable/verify Cloudflare Markdown for Agents via API + HTTP check.
apps/web/package.json Add npm scripts for enabling/verifying Markdown for Agents.
.github/workflows/release.yml Enable Cloudflare content_converter post-deploy and verify markdown response.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/web/src/start.ts
Comment thread apps/web/src/start.ts
Comment thread apps/web/scripts/cloudflare-markdown-for-agents.mjs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants