Skip to content

feat(annotate): content negotiation for Markdown for Agents#557

Merged
backnotprop merged 1 commit intomainfrom
feat/cloudflare-md
Apr 14, 2026
Merged

feat(annotate): content negotiation for Markdown for Agents#557
backnotprop merged 1 commit intomainfrom
feat/cloudflare-md

Conversation

@backnotprop
Copy link
Copy Markdown
Owner

Summary

  • Before hitting Jina Reader or Turndown, try fetching the URL with Accept: text/markdown, text/html;q=0.9
  • If the server returns content-type: text/markdown (e.g. Cloudflare zones with Markdown for Agents enabled), use it directly — one fetch, no conversion
  • Falls through silently to the existing Jina/Turndown pipeline when the server returns HTML
  • Uses a short 5s timeout so slow/unresponsive servers don't delay the fallback
  • New "content-negotiation" source type on UrlToMarkdownResult
  • Adds url-to-markdown.test.ts covering the negotiation path, fallback, local URL skip, and error handling

Ref: Cloudflare Markdown for Agents

Test plan

  • bun test packages/shared/ — all 48 tests pass (7 files)
  • Live test: plannotator annotate https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/ returns markdown via content negotiation (no Jina)
  • Live test: plannotator annotate https://docs.stripe.com/api falls through to Jina/Turndown as before
  • Local URLs (localhost, private IPs) skip content negotiation entirely

Sites that support Cloudflare's "Markdown for Agents" (or similar
content negotiation) now return markdown directly, skipping the Jina
Reader and Turndown conversion entirely. The negotiation attempt uses
a short 5s timeout so failures fall through quickly to the existing
pipeline.

For provenance purposes, this commit was AI assisted.
@backnotprop backnotprop merged commit f1d3a88 into main Apr 14, 2026
7 checks passed
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.

1 participant